diff options
| -rw-r--r-- | clang-tools-extra/pp-trace/PPCallbacksTracker.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp index d09cb998831..ca634d2d3dd 100644 --- a/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp +++ b/clang-tools-extra/pp-trace/PPCallbacksTracker.cpp @@ -588,19 +588,16 @@ void PPCallbacksTracker::appendArgument(const char *Name, std::string Str; llvm::raw_string_ostream SS(Str); SS << "["; - // The argument tokens might include end tokens, so we reflect how - // how getUnexpArgument provides the arguments. - for (int I = 0, E = Value->getNumMacroArguments(); I < E; ++I) { + + // Each argument is is a series of contiguous Tokens, terminated by a eof. + // Go through each argument printing tokens until we reach eof. + for (unsigned I = 0; I < Value->getNumMacroArguments(); ++I) { const clang::Token *Current = Value->getUnexpArgument(I); - int TokenCount = Value->getArgLength(Current) + 1; // include EOF - E -= TokenCount; if (I) SS << ", "; - // We're assuming tokens are contiguous, as otherwise we have no - // other way to get at them. - --TokenCount; - for (int TokenIndex = 0; TokenIndex < TokenCount; ++TokenIndex, ++Current) { - if (TokenIndex) + bool First = true; + while (Current->isNot(clang::tok::eof)) { + if (!First) SS << " "; // We need to be careful here because the arguments might not be legal in // YAML, so we use the token name for anything but identifiers and @@ -611,6 +608,8 @@ void PPCallbacksTracker::appendArgument(const char *Name, } else { SS << "<" << Current->getName() << ">"; } + ++Current; + First = false; } } SS << "]"; |

