diff options
author | Kristof Umann <dkszelethus@gmail.com> | 2018-11-30 19:21:35 +0000 |
---|---|---|
committer | Kristof Umann <dkszelethus@gmail.com> | 2018-11-30 19:21:35 +0000 |
commit | 5f9981f8a5a7acf044b347438d16fe46af97c1c0 (patch) | |
tree | a86304b584ce06c8c944bd2c2c777aa004b6fdcd /clang/lib | |
parent | 27b1e3bd4f7a064a2672e30cc6be31433ebd300b (diff) | |
download | bcm5719-llvm-5f9981f8a5a7acf044b347438d16fe46af97c1c0.tar.gz bcm5719-llvm-5f9981f8a5a7acf044b347438d16fe46af97c1c0.zip |
[analyzer][PlistMacroExpansion] Part 5.: Support for # and ##
From what I can see, this should be the last patch needed to replicate macro
argument expansions.
Differential Revision: https://reviews.llvm.org/D52988
llvm-svn: 348025
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp | 25 |
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; |