MCPcopy Create free account
hub / github.com/andreasfertig/cppinsights / FindDeclRef

Function FindDeclRef

InsightsHelpers.cpp:1503–1526  ·  view source on GitHub ↗

* Go deep in a Stmt if necessary and look to all childs for a DeclRefExpr. */

Source from the content-addressed store, hash-verified

1501 * Go deep in a Stmt if necessary and look to all childs for a DeclRefExpr.
1502 */
1503const 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
1529std::string GetName(const VarDecl& VD)

Callers 3

InsertArgMethod · 0.85
GetNameFunction · 0.85

Calls 1

childrenMethod · 0.80

Tested by

no test coverage detected