summaryrefslogtreecommitdiffstats
path: root/pp-trace/PPCallbacksTracker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pp-trace/PPCallbacksTracker.cpp')
-rw-r--r--pp-trace/PPCallbacksTracker.cpp221
1 files changed, 115 insertions, 106 deletions
diff --git a/pp-trace/PPCallbacksTracker.cpp b/pp-trace/PPCallbacksTracker.cpp
index 2530dc2d..ae4d5847 100644
--- a/pp-trace/PPCallbacksTracker.cpp
+++ b/pp-trace/PPCallbacksTracker.cpp
@@ -1,9 +1,8 @@
//===--- PPCallbacksTracker.cpp - Preprocessor tracker -*--*---------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
@@ -18,16 +17,17 @@
#include "clang/Lex/MacroArgs.h"
#include "llvm/Support/raw_ostream.h"
-// Utility functions.
+namespace clang {
+namespace pp_trace {
// Get a "file:line:column" source location string.
-static std::string getSourceLocationString(clang::Preprocessor &PP,
- clang::SourceLocation Loc) {
+static std::string getSourceLocationString(Preprocessor &PP,
+ SourceLocation Loc) {
if (Loc.isInvalid())
return std::string("(none)");
if (Loc.isFileID()) {
- clang::PresumedLoc PLoc = PP.getSourceManager().getPresumedLoc(Loc);
+ PresumedLoc PLoc = PP.getSourceManager().getPresumedLoc(Loc);
if (PLoc.isInvalid()) {
return std::string("(invalid)");
@@ -89,19 +89,20 @@ static const char *const MappingStrings[] = { "0", "MAP_IGNORE",
// PPCallbacksTracker functions.
-PPCallbacksTracker::PPCallbacksTracker(llvm::SmallSet<std::string, 4> &Ignore,
+PPCallbacksTracker::PPCallbacksTracker(const FilterType &Filters,
std::vector<CallbackCall> &CallbackCalls,
- clang::Preprocessor &PP)
- : CallbackCalls(CallbackCalls), Ignore(Ignore), PP(PP) {}
+ Preprocessor &PP)
+ : CallbackCalls(CallbackCalls), Filters(Filters), PP(PP) {}
PPCallbacksTracker::~PPCallbacksTracker() {}
// Callback functions.
// Callback invoked whenever a source file is entered or exited.
-void PPCallbacksTracker::FileChanged(
- clang::SourceLocation Loc, clang::PPCallbacks::FileChangeReason Reason,
- clang::SrcMgr::CharacteristicKind FileType, clang::FileID PrevFID) {
+void PPCallbacksTracker::FileChanged(SourceLocation Loc,
+ PPCallbacks::FileChangeReason Reason,
+ SrcMgr::CharacteristicKind FileType,
+ FileID PrevFID) {
beginCallback("FileChanged");
appendArgument("Loc", Loc);
appendArgument("Reason", Reason, FileChangeReasonStrings);
@@ -111,10 +112,9 @@ void PPCallbacksTracker::FileChanged(
// Callback invoked whenever a source file is skipped as the result
// of header guard optimization.
-void
-PPCallbacksTracker::FileSkipped(const clang::FileEntry &SkippedFile,
- const clang::Token &FilenameTok,
- clang::SrcMgr::CharacteristicKind FileType) {
+void PPCallbacksTracker::FileSkipped(const FileEntry &SkippedFile,
+ const Token &FilenameTok,
+ SrcMgr::CharacteristicKind FileType) {
beginCallback("FileSkipped");
appendArgument("ParentFile", &SkippedFile);
appendArgument("FilenameTok", FilenameTok);
@@ -135,11 +135,10 @@ PPCallbacksTracker::FileNotFound(llvm::StringRef FileName,
// any kind (#include, #import, etc.) has been processed, regardless
// of whether the inclusion will actually result in an inclusion.
void PPCallbacksTracker::InclusionDirective(
- clang::SourceLocation HashLoc, const clang::Token &IncludeTok,
- llvm::StringRef FileName, bool IsAngled,
- clang::CharSourceRange FilenameRange, const clang::FileEntry *File,
+ SourceLocation HashLoc, const Token &IncludeTok, llvm::StringRef FileName,
+ bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
llvm::StringRef SearchPath, llvm::StringRef RelativePath,
- const clang::Module *Imported, clang::SrcMgr::CharacteristicKind FileType) {
+ const Module *Imported, SrcMgr::CharacteristicKind FileType) {
beginCallback("InclusionDirective");
appendArgument("IncludeTok", IncludeTok);
appendFilePathArgument("FileName", FileName);
@@ -153,9 +152,9 @@ void PPCallbacksTracker::InclusionDirective(
// Callback invoked whenever there was an explicit module-import
// syntax.
-void PPCallbacksTracker::moduleImport(clang::SourceLocation ImportLoc,
- clang::ModuleIdPath Path,
- const clang::Module *Imported) {
+void PPCallbacksTracker::moduleImport(SourceLocation ImportLoc,
+ ModuleIdPath Path,
+ const Module *Imported) {
beginCallback("moduleImport");
appendArgument("ImportLoc", ImportLoc);
appendArgument("Path", Path);
@@ -167,24 +166,23 @@ void PPCallbacksTracker::moduleImport(clang::SourceLocation ImportLoc,
void PPCallbacksTracker::EndOfMainFile() { beginCallback("EndOfMainFile"); }
// Callback invoked when a #ident or #sccs directive is read.
-void PPCallbacksTracker::Ident(clang::SourceLocation Loc, llvm::StringRef Str) {
+void PPCallbacksTracker::Ident(SourceLocation Loc, llvm::StringRef Str) {
beginCallback("Ident");
appendArgument("Loc", Loc);
appendArgument("Str", Str);
}
// Callback invoked when start reading any pragma directive.
-void
-PPCallbacksTracker::PragmaDirective(clang::SourceLocation Loc,
- clang::PragmaIntroducerKind Introducer) {
+void PPCallbacksTracker::PragmaDirective(SourceLocation Loc,
+ PragmaIntroducerKind Introducer) {
beginCallback("PragmaDirective");
appendArgument("Loc", Loc);
appendArgument("Introducer", Introducer, PragmaIntroducerKindStrings);
}
// Callback invoked when a #pragma comment directive is read.
-void PPCallbacksTracker::PragmaComment(clang::SourceLocation Loc,
- const clang::IdentifierInfo *Kind,
+void PPCallbacksTracker::PragmaComment(SourceLocation Loc,
+ const IdentifierInfo *Kind,
llvm::StringRef Str) {
beginCallback("PragmaComment");
appendArgument("Loc", Loc);
@@ -194,7 +192,7 @@ void PPCallbacksTracker::PragmaComment(clang::SourceLocation Loc,
// Callback invoked when a #pragma detect_mismatch directive is
// read.
-void PPCallbacksTracker::PragmaDetectMismatch(clang::SourceLocation Loc,
+void PPCallbacksTracker::PragmaDetectMismatch(SourceLocation Loc,
llvm::StringRef Name,
llvm::StringRef Value) {
beginCallback("PragmaDetectMismatch");
@@ -204,7 +202,7 @@ void PPCallbacksTracker::PragmaDetectMismatch(clang::SourceLocation Loc,
}
// Callback invoked when a #pragma clang __debug directive is read.
-void PPCallbacksTracker::PragmaDebug(clang::SourceLocation Loc,
+void PPCallbacksTracker::PragmaDebug(SourceLocation Loc,
llvm::StringRef DebugType) {
beginCallback("PragmaDebug");
appendArgument("Loc", Loc);
@@ -212,9 +210,10 @@ void PPCallbacksTracker::PragmaDebug(clang::SourceLocation Loc,
}
// Callback invoked when a #pragma message directive is read.
-void PPCallbacksTracker::PragmaMessage(
- clang::SourceLocation Loc, llvm::StringRef Namespace,
- clang::PPCallbacks::PragmaMessageKind Kind, llvm::StringRef Str) {
+void PPCallbacksTracker::PragmaMessage(SourceLocation Loc,
+ llvm::StringRef Namespace,
+ PPCallbacks::PragmaMessageKind Kind,
+ llvm::StringRef Str) {
beginCallback("PragmaMessage");
appendArgument("Loc", Loc);
appendArgument("Namespace", Namespace);
@@ -224,7 +223,7 @@ void PPCallbacksTracker::PragmaMessage(
// Callback invoked when a #pragma gcc dianostic push directive
// is read.
-void PPCallbacksTracker::PragmaDiagnosticPush(clang::SourceLocation Loc,
+void PPCallbacksTracker::PragmaDiagnosticPush(SourceLocation Loc,
llvm::StringRef Namespace) {
beginCallback("PragmaDiagnosticPush");
appendArgument("Loc", Loc);
@@ -233,7 +232,7 @@ void PPCallbacksTracker::PragmaDiagnosticPush(clang::SourceLocation Loc,
// Callback invoked when a #pragma gcc dianostic pop directive
// is read.
-void PPCallbacksTracker::PragmaDiagnosticPop(clang::SourceLocation Loc,
+void PPCallbacksTracker::PragmaDiagnosticPop(SourceLocation Loc,
llvm::StringRef Namespace) {
beginCallback("PragmaDiagnosticPop");
appendArgument("Loc", Loc);
@@ -241,9 +240,9 @@ void PPCallbacksTracker::PragmaDiagnosticPop(clang::SourceLocation Loc,
}
// Callback invoked when a #pragma gcc dianostic directive is read.
-void PPCallbacksTracker::PragmaDiagnostic(clang::SourceLocation Loc,
+void PPCallbacksTracker::PragmaDiagnostic(SourceLocation Loc,
llvm::StringRef Namespace,
- clang::diag::Severity Mapping,
+ diag::Severity Mapping,
llvm::StringRef Str) {
beginCallback("PragmaDiagnostic");
appendArgument("Loc", Loc);
@@ -254,9 +253,10 @@ void PPCallbacksTracker::PragmaDiagnostic(clang::SourceLocation Loc,
// Called when an OpenCL extension is either disabled or
// enabled with a pragma.
-void PPCallbacksTracker::PragmaOpenCLExtension(
- clang::SourceLocation NameLoc, const clang::IdentifierInfo *Name,
- clang::SourceLocation StateLoc, unsigned State) {
+void PPCallbacksTracker::PragmaOpenCLExtension(SourceLocation NameLoc,
+ const IdentifierInfo *Name,
+ SourceLocation StateLoc,
+ unsigned State) {
beginCallback("PragmaOpenCLExtension");
appendArgument("NameLoc", NameLoc);
appendArgument("Name", Name);
@@ -265,7 +265,7 @@ void PPCallbacksTracker::PragmaOpenCLExtension(
}
// Callback invoked when a #pragma warning directive is read.
-void PPCallbacksTracker::PragmaWarning(clang::SourceLocation Loc,
+void PPCallbacksTracker::PragmaWarning(SourceLocation Loc,
llvm::StringRef WarningSpec,
llvm::ArrayRef<int> Ids) {
beginCallback("PragmaWarning");
@@ -285,26 +285,40 @@ void PPCallbacksTracker::PragmaWarning(clang::SourceLocation Loc,
}
// Callback invoked when a #pragma warning(push) directive is read.
-void PPCallbacksTracker::PragmaWarningPush(clang::SourceLocation Loc,
- int Level) {
+void PPCallbacksTracker::PragmaWarningPush(SourceLocation Loc, int Level) {
beginCallback("PragmaWarningPush");
appendArgument("Loc", Loc);
appendArgument("Level", Level);
}
// Callback invoked when a #pragma warning(pop) directive is read.
-void PPCallbacksTracker::PragmaWarningPop(clang::SourceLocation Loc) {
+void PPCallbacksTracker::PragmaWarningPop(SourceLocation Loc) {
beginCallback("PragmaWarningPop");
appendArgument("Loc", Loc);
}
+// Callback invoked when a #pragma execution_character_set(push) directive
+// is read.
+void PPCallbacksTracker::PragmaExecCharsetPush(SourceLocation Loc,
+ StringRef Str) {
+ beginCallback("PragmaExecCharsetPush");
+ appendArgument("Loc", Loc);
+ appendArgument("Charset", Str);
+}
+
+// Callback invoked when a #pragma execution_character_set(pop) directive
+// is read.
+void PPCallbacksTracker::PragmaExecCharsetPop(SourceLocation Loc) {
+ beginCallback("PragmaExecCharsetPop");
+ appendArgument("Loc", Loc);
+}
+
// Called by Preprocessor::HandleMacroExpandedIdentifier when a
// macro invocation is found.
-void
-PPCallbacksTracker::MacroExpands(const clang::Token &MacroNameTok,
- const clang::MacroDefinition &MacroDefinition,
- clang::SourceRange Range,
- const clang::MacroArgs *Args) {
+void PPCallbacksTracker::MacroExpands(const Token &MacroNameTok,
+ const MacroDefinition &MacroDefinition,
+ SourceRange Range,
+ const MacroArgs *Args) {
beginCallback("MacroExpands");
appendArgument("MacroNameTok", MacroNameTok);
appendArgument("MacroDefinition", MacroDefinition);
@@ -313,28 +327,26 @@ PPCallbacksTracker::MacroExpands(const clang::Token &MacroNameTok,
}
// Hook called whenever a macro definition is seen.
-void
-PPCallbacksTracker::MacroDefined(const clang::Token &MacroNameTok,
- const clang::MacroDirective *MacroDirective) {
+void PPCallbacksTracker::MacroDefined(const Token &MacroNameTok,
+ const MacroDirective *MacroDirective) {
beginCallback("MacroDefined");
appendArgument("MacroNameTok", MacroNameTok);
appendArgument("MacroDirective", MacroDirective);
}
// Hook called whenever a macro #undef is seen.
-void PPCallbacksTracker::MacroUndefined(
- const clang::Token &MacroNameTok,
- const clang::MacroDefinition &MacroDefinition,
- const clang::MacroDirective *Undef) {
+void PPCallbacksTracker::MacroUndefined(const Token &MacroNameTok,
+ const MacroDefinition &MacroDefinition,
+ const MacroDirective *Undef) {
beginCallback("MacroUndefined");
appendArgument("MacroNameTok", MacroNameTok);
appendArgument("MacroDefinition", MacroDefinition);
}
// Hook called whenever the 'defined' operator is seen.
-void PPCallbacksTracker::Defined(const clang::Token &MacroNameTok,
- const clang::MacroDefinition &MacroDefinition,
- clang::SourceRange Range) {
+void PPCallbacksTracker::Defined(const Token &MacroNameTok,
+ const MacroDefinition &MacroDefinition,
+ SourceRange Range) {
beginCallback("Defined");
appendArgument("MacroNameTok", MacroNameTok);
appendArgument("MacroDefinition", MacroDefinition);
@@ -342,15 +354,14 @@ void PPCallbacksTracker::Defined(const clang::Token &MacroNameTok,
}
// Hook called when a source range is skipped.
-void PPCallbacksTracker::SourceRangeSkipped(clang::SourceRange Range,
- clang::SourceLocation EndifLoc) {
+void PPCallbacksTracker::SourceRangeSkipped(SourceRange Range,
+ SourceLocation EndifLoc) {
beginCallback("SourceRangeSkipped");
- appendArgument("Range", clang::SourceRange(Range.getBegin(), EndifLoc));
+ appendArgument("Range", SourceRange(Range.getBegin(), EndifLoc));
}
// Hook called whenever an #if is seen.
-void PPCallbacksTracker::If(clang::SourceLocation Loc,
- clang::SourceRange ConditionRange,
+void PPCallbacksTracker::If(SourceLocation Loc, SourceRange ConditionRange,
ConditionValueKind ConditionValue) {
beginCallback("If");
appendArgument("Loc", Loc);
@@ -359,10 +370,9 @@ void PPCallbacksTracker::If(clang::SourceLocation Loc,
}
// Hook called whenever an #elif is seen.
-void PPCallbacksTracker::Elif(clang::SourceLocation Loc,
- clang::SourceRange ConditionRange,
+void PPCallbacksTracker::Elif(SourceLocation Loc, SourceRange ConditionRange,
ConditionValueKind ConditionValue,
- clang::SourceLocation IfLoc) {
+ SourceLocation IfLoc) {
beginCallback("Elif");
appendArgument("Loc", Loc);
appendArgument("ConditionRange", ConditionRange);
@@ -371,9 +381,8 @@ void PPCallbacksTracker::Elif(clang::SourceLocation Loc,
}
// Hook called whenever an #ifdef is seen.
-void PPCallbacksTracker::Ifdef(clang::SourceLocation Loc,
- const clang::Token &MacroNameTok,
- const clang::MacroDefinition &MacroDefinition) {
+void PPCallbacksTracker::Ifdef(SourceLocation Loc, const Token &MacroNameTok,
+ const MacroDefinition &MacroDefinition) {
beginCallback("Ifdef");
appendArgument("Loc", Loc);
appendArgument("MacroNameTok", MacroNameTok);
@@ -381,9 +390,8 @@ void PPCallbacksTracker::Ifdef(clang::SourceLocation Loc,
}
// Hook called whenever an #ifndef is seen.
-void PPCallbacksTracker::Ifndef(clang::SourceLocation Loc,
- const clang::Token &MacroNameTok,
- const clang::MacroDefinition &MacroDefinition) {
+void PPCallbacksTracker::Ifndef(SourceLocation Loc, const Token &MacroNameTok,
+ const MacroDefinition &MacroDefinition) {
beginCallback("Ifndef");
appendArgument("Loc", Loc);
appendArgument("MacroNameTok", MacroNameTok);
@@ -391,16 +399,14 @@ void PPCallbacksTracker::Ifndef(clang::SourceLocation Loc,
}
// Hook called whenever an #else is seen.
-void PPCallbacksTracker::Else(clang::SourceLocation Loc,
- clang::SourceLocation IfLoc) {
+void PPCallbacksTracker::Else(SourceLocation Loc, SourceLocation IfLoc) {
beginCallback("Else");
appendArgument("Loc", Loc);
appendArgument("IfLoc", IfLoc);
}
// Hook called whenever an #endif is seen.
-void PPCallbacksTracker::Endif(clang::SourceLocation Loc,
- clang::SourceLocation IfLoc) {
+void PPCallbacksTracker::Endif(SourceLocation Loc, SourceLocation IfLoc) {
beginCallback("Endif");
appendArgument("Loc", Loc);
appendArgument("IfLoc", IfLoc);
@@ -410,7 +416,14 @@ void PPCallbacksTracker::Endif(clang::SourceLocation Loc,
// Start a new callback.
void PPCallbacksTracker::beginCallback(const char *Name) {
- DisableTrace = Ignore.count(std::string(Name));
+ auto R = CallbackIsEnabled.try_emplace(Name, false);
+ if (R.second) {
+ llvm::StringRef N(Name);
+ for (const std::pair<llvm::GlobPattern, bool> &Filter : Filters)
+ if (Filter.first.match(N))
+ R.first->second = Filter.second;
+ }
+ DisableTrace = !R.first->second;
if (DisableTrace)
return;
CallbackCalls.push_back(CallbackCall(Name));
@@ -433,7 +446,7 @@ void PPCallbacksTracker::appendArgument(const char *Name, int Value) {
void PPCallbacksTracker::appendArgument(const char *Name, const char *Value) {
if (DisableTrace)
return;
- CallbackCalls.back().Arguments.push_back(Argument(Name, Value));
+ CallbackCalls.back().Arguments.push_back(Argument{Name, Value});
}
// Append a string object argument to the top trace item.
@@ -449,8 +462,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
}
// Append a token argument to the top trace item.
-void PPCallbacksTracker::appendArgument(const char *Name,
- const clang::Token &Value) {
+void PPCallbacksTracker::appendArgument(const char *Name, const Token &Value) {
appendArgument(Name, PP.getSpelling(Value));
}
@@ -461,13 +473,12 @@ void PPCallbacksTracker::appendArgument(const char *Name, int Value,
}
// Append a FileID argument to the top trace item.
-void PPCallbacksTracker::appendArgument(const char *Name, clang::FileID Value) {
+void PPCallbacksTracker::appendArgument(const char *Name, FileID Value) {
if (Value.isInvalid()) {
appendArgument(Name, "(invalid)");
return;
}
- const clang::FileEntry *FileEntry =
- PP.getSourceManager().getFileEntryForID(Value);
+ const FileEntry *FileEntry = PP.getSourceManager().getFileEntryForID(Value);
if (!FileEntry) {
appendArgument(Name, "(getFileEntryForID failed)");
return;
@@ -477,7 +488,7 @@ void PPCallbacksTracker::appendArgument(const char *Name, clang::FileID Value) {
// Append a FileEntry argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
- const clang::FileEntry *Value) {
+ const FileEntry *Value) {
if (!Value) {
appendArgument(Name, "(null)");
return;
@@ -487,7 +498,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
// Append a SourceLocation argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
- clang::SourceLocation Value) {
+ SourceLocation Value) {
if (Value.isInvalid()) {
appendArgument(Name, "(invalid)");
return;
@@ -496,8 +507,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
}
// Append a SourceRange argument to the top trace item.
-void PPCallbacksTracker::appendArgument(const char *Name,
- clang::SourceRange Value) {
+void PPCallbacksTracker::appendArgument(const char *Name, SourceRange Value) {
if (DisableTrace)
return;
if (Value.isInvalid()) {
@@ -513,7 +523,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
// Append a CharSourceRange argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
- clang::CharSourceRange Value) {
+ CharSourceRange Value) {
if (Value.isInvalid()) {
appendArgument(Name, "(invalid)");
return;
@@ -522,8 +532,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
}
// Append a SourceLocation argument to the top trace item.
-void PPCallbacksTracker::appendArgument(const char *Name,
- clang::ModuleIdPath Value) {
+void PPCallbacksTracker::appendArgument(const char *Name, ModuleIdPath Value) {
if (DisableTrace)
return;
std::string Str;
@@ -542,7 +551,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
// Append an IdentifierInfo argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
- const clang::IdentifierInfo *Value) {
+ const IdentifierInfo *Value) {
if (!Value) {
appendArgument(Name, "(null)");
return;
@@ -552,7 +561,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
// Append a MacroDirective argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
- const clang::MacroDirective *Value) {
+ const MacroDirective *Value) {
if (!Value) {
appendArgument(Name, "(null)");
return;
@@ -562,7 +571,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
// Append a MacroDefinition argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
- const clang::MacroDefinition &Value) {
+ const MacroDefinition &Value) {
std::string Str;
llvm::raw_string_ostream SS(Str);
SS << "[";
@@ -581,7 +590,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
// Append a MacroArgs argument to the top trace item.
void PPCallbacksTracker::appendArgument(const char *Name,
- const clang::MacroArgs *Value) {
+ const MacroArgs *Value) {
if (!Value) {
appendArgument(Name, "(null)");
return;
@@ -593,18 +602,17 @@ void PPCallbacksTracker::appendArgument(const char *Name,
// 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);
+ const Token *Current = Value->getUnexpArgument(I);
if (I)
SS << ", ";
bool First = true;
- while (Current->isNot(clang::tok::eof)) {
+ while (Current->isNot(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
// numeric literals.
- if (Current->isAnyIdentifier() ||
- Current->is(clang::tok::numeric_constant)) {
+ if (Current->isAnyIdentifier() || Current->is(tok::numeric_constant)) {
SS << PP.getSpelling(*Current);
} else {
SS << "<" << Current->getName() << ">";
@@ -618,8 +626,7 @@ void PPCallbacksTracker::appendArgument(const char *Name,
}
// Append a Module argument to the top trace item.
-void PPCallbacksTracker::appendArgument(const char *Name,
- const clang::Module *Value) {
+void PPCallbacksTracker::appendArgument(const char *Name, const Module *Value) {
if (!Value) {
appendArgument(Name, "(null)");
return;
@@ -646,9 +653,11 @@ void PPCallbacksTracker::appendFilePathArgument(const char *Name,
}
// Get the raw source string of the range.
-llvm::StringRef
-PPCallbacksTracker::getSourceString(clang::CharSourceRange Range) {
+llvm::StringRef PPCallbacksTracker::getSourceString(CharSourceRange Range) {
const char *B = PP.getSourceManager().getCharacterData(Range.getBegin());
const char *E = PP.getSourceManager().getCharacterData(Range.getEnd());
return llvm::StringRef(B, E - B);
}
+
+} // namespace pp_trace
+} // namespace clang