summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
index 10480a2eb9d..6ce42429dbf 100644
--- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -904,8 +904,6 @@ static std::string getMacroNameAndPrintExpansion(TokenPrinter &Printer,
continue;
}
- // TODO: Handle tok::hash and tok::hashhash.
-
// If control reached here, then this token isn't a macro identifier, nor an
// unexpanded macro argument that we need to handle, print it.
Printer.printToken(T);
@@ -1094,14 +1092,25 @@ void MacroArgMap::expandFromPrevMacro(const MacroArgMap &Super) {
}
void TokenPrinter::printToken(const Token &Tok) {
- // If the tokens were already space separated, or if they must be to avoid
- // them being implicitly pasted, add a space between them.
// If this is the first token to be printed, don't print space.
- if (PrevTok.isNot(tok::unknown) && (Tok.hasLeadingSpace() ||
- ConcatInfo.AvoidConcat(PrevPrevTok, PrevTok, Tok)))
- OS << ' ';
+ if (PrevTok.isNot(tok::unknown)) {
+ // If the tokens were already space separated, or if they must be to avoid
+ // them being implicitly pasted, add a space between them.
+ if(Tok.hasLeadingSpace() || ConcatInfo.AvoidConcat(PrevPrevTok, PrevTok,
+ Tok)) {
+ // AvoidConcat doesn't check for ##, don't print a space around it.
+ if (PrevTok.isNot(tok::hashhash) && Tok.isNot(tok::hashhash)) {
+ OS << ' ';
+ }
+ }
+ }
- OS << PP.getSpelling(Tok);
+ if (!Tok.isOneOf(tok::hash, tok::hashhash)) {
+ if (PrevTok.is(tok::hash))
+ OS << '\"' << PP.getSpelling(Tok) << '\"';
+ else
+ OS << PP.getSpelling(Tok);
+ }
PrevPrevTok = PrevTok;
PrevTok = Tok;
OpenPOWER on IntegriCloud