data: fixed crash when parsing initialization of global variable

handled visiting of global variable usage in initialization of another global variable.
This commit is contained in:
malte_langkabel
2015-02-09 11:20:01 +01:00
parent af1462f955
commit 4da51180ca
9 changed files with 82 additions and 23 deletions
+18
View File
@@ -875,6 +875,17 @@ public:
TS_ASSERT_EQUALS(client->usages[0], "int main() -> bar <5:2 5:4>");
}
void test_cxx_parser_finds_usage_of_global_variable_in_global_variable_initialization()
{
std::shared_ptr<TestParserClient> client = parseCode(
"int a = 0;\n"
"int b[] = {a};\n"
);
TS_ASSERT_EQUALS(client->usages.size(), 1);
TS_ASSERT_EQUALS(client->usages[0], "int [] b -> a <2:12 2:12>");
}
void test_cxx_parser_finds_usage_of_global_variable_in_method()
{
std::shared_ptr<TestParserClient> client = parseCode(
@@ -1692,6 +1703,13 @@ private:
return 0;
}
virtual Id onGlobalVariableUsageParsed(
const ParseLocation& location, const ParseVariable& user, const std::vector<std::string>& usedNameHierarchy)
{
usages.push_back(addLocationSuffix(variableStr(user) + " -> " + utility::join(usedNameHierarchy, "::"), location));
return 0;
}
virtual Id onEnumFieldUsageParsed(
const ParseLocation& location, const ParseFunction& user, const std::vector<std::string>& usedNameHierarchy)
{