* Go deep in a Stmt if necessary and look to all childs for a DeclRefExpr. */
| 1501 | * Go deep in a Stmt if necessary and look to all childs for a DeclRefExpr. |
| 1502 | */ |
| 1503 | const DeclRefExpr* FindDeclRef(const Stmt* stmt) |
| 1504 | { |
| 1505 | if(const auto* dref = dyn_cast_or_null<DeclRefExpr>(stmt)) { |
| 1506 | return dref; |
| 1507 | } else if(const auto* arrayInitExpr = dyn_cast_or_null<ArrayInitLoopExpr>(stmt)) { |
| 1508 | const auto* srcExpr = arrayInitExpr->getCommonExpr()->getSourceExpr(); |
| 1509 | |
| 1510 | if(const auto* arrayDeclRefExpr = dyn_cast_or_null<DeclRefExpr>(srcExpr)) { |
| 1511 | return arrayDeclRefExpr; |
| 1512 | } |
| 1513 | } else if(const auto func = dyn_cast_or_null<CXXFunctionalCastExpr>(stmt)) { |
| 1514 | // TODO(stmt, ""); |
| 1515 | } |
| 1516 | |
| 1517 | if(stmt) { |
| 1518 | for(const auto* child : stmt->children()) { |
| 1519 | if(const auto* childRef = FindDeclRef(child)) { |
| 1520 | return childRef; |
| 1521 | } |
| 1522 | } |
| 1523 | } |
| 1524 | |
| 1525 | return nullptr; |
| 1526 | } |
| 1527 | //----------------------------------------------------------------------------- |
| 1528 | |
| 1529 | std::string GetName(const VarDecl& VD) |
no test coverage detected