summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-11-05 20:55:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-11-05 20:55:14 +0000
commit85f93f34cbc21873e77efe1f47abb573352ff6b4 (patch)
tree9fd7214a95f5ab9cf4aeacbbdb83cefc30989c4a
parent2a7a94a65504399e6b425a92c63330da7de4de8a (diff)
downloadbcm5719-llvm-85f93f34cbc21873e77efe1f47abb573352ff6b4.tar.gz
bcm5719-llvm-85f93f34cbc21873e77efe1f47abb573352ff6b4.zip
Improve macro dumping to preserve semantically-relevant spelling information.
llvm-svn: 252206
-rw-r--r--clang/lib/Lex/MacroInfo.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp
index 109b6c12b89..0b4292fbeae 100644
--- a/clang/lib/Lex/MacroInfo.cpp
+++ b/clang/lib/Lex/MacroInfo.cpp
@@ -154,16 +154,20 @@ void MacroInfo::dump() const {
Out << ")";
}
+ bool First = true;
for (const Token &Tok : ReplacementTokens) {
- Out << " ";
+ // Leading space is semantically meaningful in a macro definition,
+ // so preserve it in the dump output.
+ if (First || Tok.hasLeadingSpace())
+ Out << " ";
+ First = false;
+
if (const char *Punc = tok::getPunctuatorSpelling(Tok.getKind()))
Out << Punc;
- else if (const char *Kwd = tok::getKeywordSpelling(Tok.getKind()))
- Out << Kwd;
- else if (Tok.is(tok::identifier))
- Out << Tok.getIdentifierInfo()->getName();
else if (Tok.isLiteral() && Tok.getLiteralData())
Out << StringRef(Tok.getLiteralData(), Tok.getLength());
+ else if (auto *II = Tok.getIdentifierInfo())
+ Out << II->getName();
else
Out << Tok.getName();
}
OpenPOWER on IntegriCloud