Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6285,6 +6285,7 @@ std::string Tokenizer::dumpTypedefInfo() const
std::string outs = " <typedef-info>";
outs += '\n';
for (const TypedefInfo &typedefInfo: mTypedefInfo) {
const bool toks = !typedefInfo.typedefInfoTokens.empty();
outs += " <info";

outs += " name=\"";
Expand All @@ -6310,8 +6311,10 @@ std::string Tokenizer::dumpTypedefInfo() const
outs += " isFunctionPointer=\"";
outs += std::to_string(typedefInfo.isFunctionPointer);
outs += "\"";

outs += "/>";
if (toks)
outs += ">";
else
outs += "/>";
outs += '\n';
for (const auto& t : typedefInfo.typedefInfoTokens) {
outs += " <token ";
Expand All @@ -6323,6 +6326,8 @@ std::string Tokenizer::dumpTypedefInfo() const
outs += "\"/>";
outs += '\n';
}
if (toks)
outs += " </info>\n";
}
outs += " </typedef-info>";
outs += '\n';
Expand Down
6 changes: 4 additions & 2 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4556,7 +4556,7 @@ class TestSimplifyTypedef : public TestFixture {
" typedef fp16 ( *pfp16 ) ( void );\n"
"}\n");
ASSERT_EQUALS(" <typedef-info>\n"
" <info name=\"fp16\" file=\"file.c\" line=\"2\" column=\"1\" used=\"1\" isFunctionPointer=\"1\"/>\n"
" <info name=\"fp16\" file=\"file.c\" line=\"2\" column=\"1\" used=\"1\" isFunctionPointer=\"1\">\n"
" <token column=\"1\" str=\"typedef\"/>\n"
" <token column=\"9\" str=\"void\"/>\n"
" <token column=\"14\" str=\"(\"/>\n"
Expand All @@ -4567,8 +4567,9 @@ class TestSimplifyTypedef : public TestFixture {
" <token column=\"25\" str=\"int16_t\"/>\n"
" <token column=\"33\" str=\"n\"/>\n"
" <token column=\"35\" str=\")\"/>\n"
" </info>\n"
" <info name=\"int16_t\" file=\"file.c\" line=\"1\" column=\"1\" used=\"1\" isFunctionPointer=\"0\"/>\n"
" <info name=\"pfp16\" file=\"file.c\" line=\"4\" column=\"20\" used=\"0\" isFunctionPointer=\"1\"/>\n"
" <info name=\"pfp16\" file=\"file.c\" line=\"4\" column=\"20\" used=\"0\" isFunctionPointer=\"1\">\n"
" <token column=\"4\" str=\"typedef\"/>\n"
" <token column=\"12\" str=\"void\"/>\n"
" <token column=\"12\" str=\"(\"/>\n"
Expand All @@ -4586,6 +4587,7 @@ class TestSimplifyTypedef : public TestFixture {
" <token column=\"35\" str=\"short\"/>\n"
" <token column=\"35\" str=\"n\"/>\n"
" <token column=\"35\" str=\")\"/>\n"
" </info>\n"
" </typedef-info>\n",xml);
}

Expand Down