logic: fixed recording of Cxx field usage

* fixed recording reference to field inside TemporaryObjectExpr as usage edge instead of call edge
This commit is contained in:
malte_langkabel
2017-08-11 15:05:44 +02:00
parent 855f0cbbbf
commit cbbcc98832
2 changed files with 30 additions and 1 deletions
@@ -113,7 +113,7 @@ void CxxAstVisitorComponentDeclRefKind::beginTraverseConstructorInitializer(clan
void CxxAstVisitorComponentDeclRefKind::beginTraverseCXXTemporaryObjectExpr(clang::CXXTemporaryObjectExpr* s)
{
m_thisRefKind = REFERENCE_CALL;
m_childRefKind = REFERENCE_CALL;
m_childRefKind = REFERENCE_USAGE;
}
void CxxAstVisitorComponentDeclRefKind::visitVarDecl(clang::VarDecl* d)
+29
View File
@@ -2024,6 +2024,35 @@ public:
));
}
void test_cxx_parser_finds_usage_of_member_in_temporary_object_expression()
{
std::shared_ptr<TestParserClient> client = parseCode(
"class Foo\n"
"{\n"
"public:\n"
" Foo() { }\n"
" Foo(const Foo& i, int d) { }\n"
"};\n"
"\n"
"class Bar\n"
"{\n"
"public:\n"
" Bar(): m_i() {}\n"
"\n"
" void baba()\n"
" {\n"
" Foo(m_i, 4);\n"
" }\n"
"\n"
" const Foo m_i;\n"
"};\n"
);
TS_ASSERT(utility::containsElement<std::string>(
client->usages, "void Bar::baba() -> const Foo Bar::m_i <15:7 15:9>"
));
}
void test_cxx_parser_finds_return_type_use_in_function()
{
std::shared_ptr<TestParserClient> client = parseCode(