Preprocessor; do not write macro usage in dump output if it is empty

This commit is contained in:
Daniel Marjamäki 2021-07-08 16:53:25 +02:00
parent 447bea5c18
commit 140aa6afb4
1 changed files with 14 additions and 12 deletions

View File

@ -958,19 +958,21 @@ void Preprocessor::dump(std::ostream &out) const
}
out << " </directivelist>" << std::endl;
out << " <macro-usage>" << std::endl;
for (const simplecpp::MacroUsage &macroUsage: mMacroUsage) {
out << " <macro "
<< " name=\"" << macroUsage.macroName << "\""
<< " file=\"" << macroUsage.macroLocation.file() << "\""
<< " line=\"" << macroUsage.macroLocation.line << "\""
<< " column=\"" << macroUsage.macroLocation.col << "\""
<< " usefile=\"" << macroUsage.useLocation.file() << "\""
<< " useline=\"" << macroUsage.useLocation.line << "\""
<< " usecolumn=\"" << macroUsage.useLocation.col << "\""
<< " known-value=\"" << (macroUsage.macroValueKnown ? 1 : 0) << "\"/>" << std::endl;
if (!mMacroUsage.empty()) {
out << " <macro-usage>" << std::endl;
for (const simplecpp::MacroUsage &macroUsage: mMacroUsage) {
out << " <macro "
<< " name=\"" << macroUsage.macroName << "\""
<< " file=\"" << macroUsage.macroLocation.file() << "\""
<< " line=\"" << macroUsage.macroLocation.line << "\""
<< " column=\"" << macroUsage.macroLocation.col << "\""
<< " usefile=\"" << macroUsage.useLocation.file() << "\""
<< " useline=\"" << macroUsage.useLocation.line << "\""
<< " usecolumn=\"" << macroUsage.useLocation.col << "\""
<< " known-value=\"" << (macroUsage.macroValueKnown ? 1 : 0) << "\"/>" << std::endl;
}
out << " </macro-usage>" << std::endl;
}
out << " </macro-usage>" << std::endl;
}
static const std::uint32_t crc32Table[] = {