Skip to content

Commit

Permalink
Fix #13358: Add 'isFriend' to DumpFile (#7224)
Browse files Browse the repository at this point in the history
  • Loading branch information
olabetskyi authored Jan 17, 2025
1 parent bb81a66 commit 10bab82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4267,6 +4267,8 @@ void SymbolDatabase::printXml(std::ostream &out) const
outs += " isInlineKeyword=\"true\"";
if (function->isStatic())
outs += " isStatic=\"true\"";
if (function->isFriend())
outs += " isFriend=\"true\"";
if (function->isAttributeNoreturn())
outs += " isAttributeNoreturn=\"true\"";
if (const Function* overriddenFunction = function->getOverriddenFunction()) {
Expand Down
15 changes: 15 additions & 0 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,8 @@ class TestSymbolDatabase : public TestFixture {
TEST_CASE(incomplete_type); // #9255 (infinite recursion)
TEST_CASE(exprIds);
TEST_CASE(testValuetypeOriginalName);

TEST_CASE(dumpFriend); // Check if isFriend added to dump file
}

void array() {
Expand Down Expand Up @@ -11073,6 +11075,19 @@ class TestSymbolDatabase : public TestFixture {
ASSERT(tok->valueType()->constness == 0);
}
}

void dumpFriend() {
GET_SYMBOL_DB("class Foo {\n"
" Foo();\n"
" int x{};\n"
" friend bool operator==(const Foo&lhs, const Foo&rhs) {\n"
" return lhs.x == rhs.x;\n"
" }\n"
"};");
std::ostringstream ostr;
db->printXml(ostr);
ASSERT(ostr.str().find(" isFriend=\"true\"") != std::string::npos);
}
};

REGISTER_TEST(TestSymbolDatabase)

0 comments on commit 10bab82

Please sign in to comment.