21 #ifndef PPTRACE_PPCALLBACKSTRACKER_H 22 #define PPTRACE_PPCALLBACKSTRACKER_H 24 #include "clang/Lex/PPCallbacks.h" 25 #include "clang/Lex/Preprocessor.h" 26 #include "clang/Basic/SourceManager.h" 27 #include "llvm/ADT/ArrayRef.h" 28 #include "llvm/ADT/SmallSet.h" 29 #include "llvm/ADT/StringMap.h" 30 #include "llvm/ADT/StringRef.h" 31 #include "llvm/Support/GlobPattern.h" 55 using FilterType = std::vector<std::pair<llvm::GlobPattern, bool>>;
82 std::vector<CallbackCall> &CallbackCalls,
89 void FileChanged(SourceLocation
Loc, PPCallbacks::FileChangeReason Reason,
90 SrcMgr::CharacteristicKind FileType,
91 FileID PrevFID = FileID())
override;
92 void FileSkipped(
const FileEntry &SkippedFile,
const Token &FilenameTok,
93 SrcMgr::CharacteristicKind FileType)
override;
94 bool FileNotFound(llvm::StringRef
FileName,
95 llvm::SmallVectorImpl<char> &RecoveryPath)
override;
96 void InclusionDirective(SourceLocation HashLoc,
const Token &IncludeTok,
97 llvm::StringRef FileName,
bool IsAngled,
98 CharSourceRange FilenameRange,
const FileEntry *File,
99 llvm::StringRef SearchPath,
100 llvm::StringRef RelativePath,
const Module *Imported,
101 SrcMgr::CharacteristicKind FileType)
override;
102 void moduleImport(SourceLocation ImportLoc, ModuleIdPath
Path,
103 const Module *Imported)
override;
104 void EndOfMainFile()
override;
105 void Ident(SourceLocation Loc, llvm::StringRef str)
override;
106 void PragmaDirective(SourceLocation Loc,
107 PragmaIntroducerKind Introducer)
override;
108 void PragmaComment(SourceLocation Loc,
const IdentifierInfo *
Kind,
109 llvm::StringRef Str)
override;
110 void PragmaDetectMismatch(SourceLocation Loc, llvm::StringRef
Name,
111 llvm::StringRef
Value)
override;
112 void PragmaDebug(SourceLocation Loc, llvm::StringRef DebugType)
override;
113 void PragmaMessage(SourceLocation Loc, llvm::StringRef Namespace,
114 PPCallbacks::PragmaMessageKind Kind,
115 llvm::StringRef Str)
override;
116 void PragmaDiagnosticPush(SourceLocation Loc,
117 llvm::StringRef Namespace)
override;
118 void PragmaDiagnosticPop(SourceLocation Loc,
119 llvm::StringRef Namespace)
override;
120 void PragmaDiagnostic(SourceLocation Loc, llvm::StringRef Namespace,
121 diag::Severity mapping, llvm::StringRef Str)
override;
122 void PragmaOpenCLExtension(SourceLocation NameLoc,
const IdentifierInfo *Name,
123 SourceLocation StateLoc,
unsigned State)
override;
124 void PragmaWarning(SourceLocation Loc, llvm::StringRef WarningSpec,
125 llvm::ArrayRef<int> Ids)
override;
126 void PragmaWarningPush(SourceLocation Loc,
int Level)
override;
127 void PragmaWarningPop(SourceLocation Loc)
override;
128 void PragmaExecCharsetPush(SourceLocation Loc, StringRef Str)
override;
129 void PragmaExecCharsetPop(SourceLocation Loc)
override;
130 void MacroExpands(
const Token &MacroNameTok,
const MacroDefinition &
MD,
131 SourceRange
Range,
const MacroArgs *Args)
override;
132 void MacroDefined(
const Token &MacroNameTok,
133 const MacroDirective *MD)
override;
134 void MacroUndefined(
const Token &MacroNameTok,
const MacroDefinition &MD,
135 const MacroDirective *Undef)
override;
136 void Defined(
const Token &MacroNameTok,
const MacroDefinition &MD,
137 SourceRange Range)
override;
138 void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc)
override;
139 void If(SourceLocation Loc, SourceRange ConditionRange,
141 void Elif(SourceLocation Loc, SourceRange ConditionRange,
142 ConditionValueKind ConditionValue, SourceLocation IfLoc)
override;
143 void Ifdef(SourceLocation Loc,
const Token &MacroNameTok,
144 const MacroDefinition &MD)
override;
145 void Ifndef(SourceLocation Loc,
const Token &MacroNameTok,
146 const MacroDefinition &MD)
override;
147 void Else(SourceLocation Loc, SourceLocation IfLoc)
override;
148 void Endif(SourceLocation Loc, SourceLocation IfLoc)
override;
153 void beginCallback(
const char *Name);
156 void append(
const char *Str);
159 void appendArgument(
const char *Name,
bool Value);
162 void appendArgument(
const char *Name,
int Value);
165 void appendArgument(
const char *Name,
const char *Value);
168 void appendArgument(
const char *Name, llvm::StringRef Value);
171 void appendArgument(
const char *Name,
const std::string &Value);
174 void appendArgument(
const char *Name,
const Token &Value);
177 void appendArgument(
const char *Name,
int Value,
const char *
const Strings[]);
180 void appendArgument(
const char *Name, FileID Value);
183 void appendArgument(
const char *Name,
const FileEntry *Value);
186 void appendArgument(
const char *Name, SourceLocation Value);
189 void appendArgument(
const char *Name, SourceRange Value);
192 void appendArgument(
const char *Name, CharSourceRange Value);
195 void appendArgument(
const char *Name, ModuleIdPath Value);
198 void appendArgument(
const char *Name,
const IdentifierInfo *Value);
201 void appendArgument(
const char *Name,
const MacroDirective *Value);
204 void appendArgument(
const char *Name,
const MacroDefinition &Value);
207 void appendArgument(
const char *Name,
const MacroArgs *Value);
210 void appendArgument(
const char *Name,
const Module *Value);
213 void appendQuotedArgument(
const char *Name,
const std::string &Value);
216 void appendFilePathArgument(
const char *Name, llvm::StringRef Value);
241 #endif // PPTRACE_PPCALLBACKSTRACKER_H SourceLocation Loc
'#' location in the include directive
std::vector< CallbackCall > & CallbackCalls
Callback trace information.
CallbackCall(llvm::StringRef Name)
static std::string getSourceString(clang::Preprocessor &PP, clang::SourceRange Range)
const FilterType & Filters
std::vector< HeaderHandle > Path
This class overrides the PPCallbacks class for tracking preprocessor activity by means of its callbac...
bool DisableTrace
Inhibit trace while this is set.
This class represents one callback call by name and an array of arguments.
bool IsAngled
true if this was an include with angle brackets
clang::PPCallbacks::ConditionValueKind ConditionValue
std::vector< llvm::StringRef > Strings
llvm::StringMap< bool > CallbackIsEnabled
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
static GeneratorRegistry::Add< MDGenerator > MD(MDGenerator::Format, "Generator for MD output.")
CharSourceRange Range
SourceRange for the file name.
std::vector< std::pair< llvm::GlobPattern, bool > > FilterType
std::vector< Argument > Arguments