Skip to content

Commit a423574

Browse files
authored
Fix #14224: Fix the typedef info in dump file (danmar#7912)
1 parent 387d7d8 commit a423574

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/tokenize.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6285,6 +6285,7 @@ std::string Tokenizer::dumpTypedefInfo() const
62856285
std::string outs = " <typedef-info>";
62866286
outs += '\n';
62876287
for (const TypedefInfo &typedefInfo: mTypedefInfo) {
6288+
const bool toks = !typedefInfo.typedefInfoTokens.empty();
62886289
outs += " <info";
62896290

62906291
outs += " name=\"";
@@ -6310,8 +6311,10 @@ std::string Tokenizer::dumpTypedefInfo() const
63106311
outs += " isFunctionPointer=\"";
63116312
outs += std::to_string(typedefInfo.isFunctionPointer);
63126313
outs += "\"";
6313-
6314-
outs += "/>";
6314+
if (toks)
6315+
outs += ">";
6316+
else
6317+
outs += "/>";
63156318
outs += '\n';
63166319
for (const auto& t : typedefInfo.typedefInfoTokens) {
63176320
outs += " <token ";
@@ -6323,6 +6326,8 @@ std::string Tokenizer::dumpTypedefInfo() const
63236326
outs += "\"/>";
63246327
outs += '\n';
63256328
}
6329+
if (toks)
6330+
outs += " </info>\n";
63266331
}
63276332
outs += " </typedef-info>";
63286333
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)