Skip to content

Commit aa8b2a9

Browse files
committed
Fix the typedef info in dump file
1 parent 233c016 commit aa8b2a9

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/tokenize.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6285,6 +6285,9 @@ std::string Tokenizer::dumpTypedefInfo() const
62856285
std::string outs = " <typedef-info>";
62866286
outs += '\n';
62876287
for (const TypedefInfo &typedefInfo: mTypedefInfo) {
6288+
bool tinfotoks = true;
6289+
if (typedefInfo.typedefInfoTokens.empty())
6290+
tinfotoks = false;
62886291
outs += " <info";
62896292

62906293
outs += " name=\"";
@@ -6310,8 +6313,10 @@ std::string Tokenizer::dumpTypedefInfo() const
63106313
outs += " isFunctionPointer=\"";
63116314
outs += std::to_string(typedefInfo.isFunctionPointer);
63126315
outs += "\"";
6313-
6314-
outs += "/>";
6316+
if (tinfotoks)
6317+
outs += ">";
6318+
else
6319+
outs += "/>";
63156320
outs += '\n';
63166321
for (const auto& t : typedefInfo.typedefInfoTokens) {
63176322
outs += " <token ";
@@ -6323,6 +6328,8 @@ std::string Tokenizer::dumpTypedefInfo() const
63236328
outs += "\"/>";
63246329
outs += '\n';
63256330
}
6331+
if (tinfotoks)
6332+
outs += " </info>\n";
63266333
}
63276334
outs += " </typedef-info>";
63286335
outs += '\n';

test/testsimplifytypedef.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4556,7 +4556,7 @@ class TestSimplifyTypedef : public TestFixture {
45564556
" typedef fp16 ( *pfp16 ) ( void );\n"
45574557
"}\n");
45584558
ASSERT_EQUALS(" <typedef-info>\n"
4559-
" <info name=\"fp16\" file=\"file.c\" line=\"2\" column=\"1\" used=\"1\" isFunctionPointer=\"1\"/>\n"
4559+
" <info name=\"fp16\" file=\"file.c\" line=\"2\" column=\"1\" used=\"1\" isFunctionPointer=\"1\">\n"
45604560
" <token column=\"1\" str=\"typedef\"/>\n"
45614561
" <token column=\"9\" str=\"void\"/>\n"
45624562
" <token column=\"14\" str=\"(\"/>\n"
@@ -4567,8 +4567,9 @@ class TestSimplifyTypedef : public TestFixture {
45674567
" <token column=\"25\" str=\"int16_t\"/>\n"
45684568
" <token column=\"33\" str=\"n\"/>\n"
45694569
" <token column=\"35\" str=\")\"/>\n"
4570+
" </info>\n"
45704571
" <info name=\"int16_t\" file=\"file.c\" line=\"1\" column=\"1\" used=\"1\" isFunctionPointer=\"0\"/>\n"
4571-
" <info name=\"pfp16\" file=\"file.c\" line=\"4\" column=\"20\" used=\"0\" isFunctionPointer=\"1\"/>\n"
4572+
" <info name=\"pfp16\" file=\"file.c\" line=\"4\" column=\"20\" used=\"0\" isFunctionPointer=\"1\">\n"
45724573
" <token column=\"4\" str=\"typedef\"/>\n"
45734574
" <token column=\"12\" str=\"void\"/>\n"
45744575
" <token column=\"12\" str=\"(\"/>\n"
@@ -4586,6 +4587,7 @@ class TestSimplifyTypedef : public TestFixture {
45864587
" <token column=\"35\" str=\"short\"/>\n"
45874588
" <token column=\"35\" str=\"n\"/>\n"
45884589
" <token column=\"35\" str=\")\"/>\n"
4590+
" </info>\n"
45894591
" </typedef-info>\n",xml);
45904592
}
45914593

0 commit comments

Comments
 (0)