diff --git a/lib/clangastdump.cpp b/lib/clangastdump.cpp index 204de306d..dcb8d733e 100644 --- a/lib/clangastdump.cpp +++ b/lib/clangastdump.cpp @@ -116,18 +116,22 @@ namespace clangastdump { def->varId(++mVarId); def->variable(var); var->setValueType(ValueType(ValueType::Sign::SIGNED, ValueType::Type::INT, 0)); + notFound(addr); } void funcDecl(const std::string &addr, Token *nameToken, Function *function) { Decl decl(nameToken, function); mDeclMap.insert(std::pair(addr, decl)); nameToken->function(function); + notFound(addr); } void ref(const std::string &addr, Token *tok) { auto it = mDeclMap.find(addr); if (it != mDeclMap.end()) it->second.ref(tok); + else + mNotFound[addr].push_back(tok); } std::vector getVariableList() const { @@ -141,7 +145,17 @@ namespace clangastdump { } private: + void notFound(const std::string &addr) { + auto it = mNotFound.find(addr); + if (it != mNotFound.end()) { + for (Token *reftok: it->second) + ref(addr, reftok); + mNotFound.erase(it); + } + } + std::map mDeclMap; + std::map> mNotFound; int mVarId = 0; }; diff --git a/test/testclangastdump.cpp b/test/testclangastdump.cpp index cc1b3d949..acff6a071 100644 --- a/test/testclangastdump.cpp +++ b/test/testclangastdump.cpp @@ -186,7 +186,7 @@ private: "| | `-CXXThisExpr 0x428e9c0 'C *' this\n" "| `-IntegerLiteral 0x428ea10 'int' 0\n" "`-FieldDecl 0x428e958 col:30 referenced x 'int'"; - ASSERT_EQUALS("void C ( ) { this . x = 0 ; } int x@1", parse(clang)); + ASSERT_EQUALS("void C ( ) { this . x@1 = 0 ; } int x@1", parse(clang)); } void cxxMemberCall() {