Go to the documentation of this file.
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>>;
89 void FileChanged(SourceLocation
Loc, PPCallbacks::FileChangeReason Reason,
90 SrcMgr::CharacteristicKind FileType,
91 FileID PrevFID = FileID())
override;
92 void FileSkipped(
const FileEntryRef &SkippedFile,
const Token &FilenameTok,
93 SrcMgr::CharacteristicKind FileType)
override;
95 llvm::SmallVectorImpl<char> &RecoveryPath)
override;
98 CharSourceRange FilenameRange,
const FileEntry *File,
99 llvm::StringRef SearchPath,
100 llvm::StringRef RelativePath,
const Module *Imported,
101 SrcMgr::CharacteristicKind FileType)
override;
103 const Module *Imported)
override;
105 void Ident(SourceLocation
Loc, llvm::StringRef str)
override;
107 PragmaIntroducerKind Introducer)
override;
109 llvm::StringRef Str)
override;
111 llvm::StringRef Value)
override;
112 void PragmaDebug(SourceLocation
Loc, llvm::StringRef DebugType)
override;
114 PPCallbacks::PragmaMessageKind
Kind,
115 llvm::StringRef Str)
override;
117 llvm::StringRef Namespace)
override;
119 llvm::StringRef Namespace)
override;
121 diag::Severity mapping, llvm::StringRef Str)
override;
123 SourceLocation StateLoc,
unsigned State)
override;
125 llvm::ArrayRef<int> Ids)
override;
130 void MacroExpands(
const Token &MacroNameTok,
const MacroDefinition &
MD,
131 SourceRange
Range,
const MacroArgs *Args)
override;
133 const MacroDirective *
MD)
override;
135 const MacroDirective *Undef)
override;
136 void Defined(
const Token &MacroNameTok,
const MacroDefinition &
MD,
137 SourceRange
Range)
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;
156 void append(
const char *Str);
241 #endif // PPTRACE_PPCALLBACKSTRACKER_H
CharSourceRange Range
SourceRange for the file name.
void PragmaExecCharsetPop(SourceLocation Loc) override
void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, llvm::StringRef Str) override
void append(const char *Str)
Append a string to the top trace item.
void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State) override
static GeneratorRegistry::Add< MDGenerator > MD(MDGenerator::Format, "Generator for MD output.")
PPCallbacksTracker(const FilterType &Filters, std::vector< CallbackCall > &CallbackCalls, Preprocessor &PP)
Note that all of the arguments are references, and owned by the caller.
void If(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue) override
std::vector< std::pair< llvm::GlobPattern, bool > > FilterType
void Endif(SourceLocation Loc, SourceLocation IfLoc) override
bool DisableTrace
Inhibit trace while this is set.
clang::PPCallbacks::ConditionValueKind ConditionValue
void PragmaWarningPop(SourceLocation Loc) override
void Defined(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range) override
~PPCallbacksTracker() override
void FileChanged(SourceLocation Loc, PPCallbacks::FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID=FileID()) override
void beginCallback(const char *Name)
Start a new callback.
std::vector< Argument > Arguments
void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, const Module *Imported) override
void PragmaDirective(SourceLocation Loc, PragmaIntroducerKind Introducer) override
void PragmaWarningPush(SourceLocation Loc, int Level) override
This class overrides the PPCallbacks class for tracking preprocessor activity by means of its callbac...
llvm::StringMap< bool > CallbackIsEnabled
void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
std::vector< CallbackCall > & CallbackCalls
Callback trace information.
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, llvm::StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, llvm::StringRef SearchPath, llvm::StringRef RelativePath, const Module *Imported, SrcMgr::CharacteristicKind FileType) override
void appendArgument(const char *Name, bool Value)
Append a bool argument to the top trace item.
bool FileNotFound(llvm::StringRef FileName, llvm::SmallVectorImpl< char > &RecoveryPath) override
void Ident(SourceLocation Loc, llvm::StringRef str) override
CallbackCall(llvm::StringRef Name)
void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok, SrcMgr::CharacteristicKind FileType) override
This class represents one callback call by name and an array of arguments.
static constexpr llvm::StringLiteral Name
void EndOfMainFile() override
void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override
void appendFilePathArgument(const char *Name, llvm::StringRef Value)
Append a double-quoted file path argument to the top trace item.
void PragmaDetectMismatch(SourceLocation Loc, llvm::StringRef Name, llvm::StringRef Value) override
void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
llvm::StringRef getSourceString(CharSourceRange Range)
Get the raw source string of the range.
void PragmaDiagnosticPush(SourceLocation Loc, llvm::StringRef Namespace) override
bool IsAngled
true if this was an include with angle brackets
const FilterType & Filters
void PragmaDiagnosticPop(SourceLocation Loc, llvm::StringRef Namespace) override
std::vector< llvm::StringRef > Strings
void PragmaMessage(SourceLocation Loc, llvm::StringRef Namespace, PPCallbacks::PragmaMessageKind Kind, llvm::StringRef Str) override
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override
void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override
void Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc) override
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void Else(SourceLocation Loc, SourceLocation IfLoc) override
void appendQuotedArgument(const char *Name, const std::string &Value)
Append a double-quoted argument to the top trace item.
SourceLocation Loc
'#' location in the include directive
void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef) override
void PragmaWarning(SourceLocation Loc, llvm::StringRef WarningSpec, llvm::ArrayRef< int > Ids) override
void PragmaExecCharsetPush(SourceLocation Loc, StringRef Str) override
void PragmaDebug(SourceLocation Loc, llvm::StringRef DebugType) override
void PragmaDiagnostic(SourceLocation Loc, llvm::StringRef Namespace, diag::Severity mapping, llvm::StringRef Str) override
std::vector< HeaderHandle > Path