Go to the documentation of this file.
19 using namespace clang;
21 void MacroPPCallbacks::writeMacroDefinition(
const IdentifierInfo &II,
31 for (; AI + 1 != E; ++AI) {
32 Name << (*AI)->getName();
37 if ((*AI)->getName() ==
"__VA_ARGS__")
40 Name << (*AI)->getName();
52 for (
const auto &T : MI.
tokens()) {
53 if (!First && T.hasLeadingSpace())
62 : Gen(Gen), PP(PP), Status(NoScope) {}
76 llvm::DIMacroFile *MacroPPCallbacks::getCurrentScope() {
77 if (Status == MainFileScope || Status == CommandLineIncludeScope)
83 if (Status == MainFileScope || EnteredCommandLineIncludeFiles)
91 void MacroPPCallbacks::updateStatusToNextScope() {
94 Status = InitializedScope;
96 case InitializedScope:
97 Status = BuiltinScope;
100 Status = CommandLineIncludeScope;
102 case CommandLineIncludeScope:
103 Status = MainFileScope;
106 llvm_unreachable(
"There is no next scope, already in the final scope");
114 updateStatusToNextScope();
116 case InitializedScope:
117 updateStatusToNextScope();
122 updateStatusToNextScope();
124 case CommandLineIncludeScope:
125 EnteredCommandLineIncludeFiles++;
138 llvm_unreachable(
"Do not expect to exit a file from current scope");
142 Status = MainFileScope;
144 case CommandLineIncludeScope:
145 if (!EnteredCommandLineIncludeFiles) {
146 updateStatusToNextScope();
149 EnteredCommandLineIncludeFiles--;
171 StringRef SearchPath, StringRef RelativePath,
const Module *Imported,
175 LastHashLoc = HashLoc;
183 llvm::raw_string_ostream Name(NameBuffer);
184 llvm::raw_string_ostream
Value(ValueBuffer);
187 llvm::dwarf::DW_MACINFO_define, location,
188 Name.str(),
Value.str());
197 llvm::dwarf::DW_MACINFO_undef, location,
param_iterator param_begin() const
The primary public interface to the Clang code generator.
CodeGen::CGDebugInfo * getCGDebugInfo()
Return debug info code generator.
llvm::DIMacroFile * CreateTempMacroFile(llvm::DIMacroFile *Parent, SourceLocation LineLoc, SourceLocation FileLoc)
Create debug info for a file referenced by an include directive.
A description of the current definition of a macro.
Encodes a location in the source.
IdentifierInfo * getIdentifierInfo() const
ArrayRef< Token > tokens() const
bool isWrittenInBuiltinFile(SourceLocation Loc) const
Returns whether Loc is located in a <built-in> file.
Encapsulates the data about a macro definition (e.g.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Token - This structure provides full information about a lexed token.
Describes a module or submodule.
void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override
Hook called whenever a macro definition is seen.
IdentifierInfo *const * param_iterator
Parameters - The list of parameters for a function-like macro.
bool isWrittenInCommandLineFile(SourceLocation Loc) const
Returns whether Loc is located in a <command line> file.
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, StringRef SearchPath, StringRef RelativePath, const Module *Imported, SrcMgr::CharacteristicKind FileType) override
Callback invoked whenever a directive (#xxx) is processed.
llvm::DIMacro * CreateMacro(llvm::DIMacroFile *Parent, unsigned MType, SourceLocation LineLoc, StringRef Name, StringRef Value)
Create debug info for a macro defined by a #define directive or a macro undefined by a #undef directi...
Cached information about one file (either on disk or in the virtual file system).
SourceManager & getSourceManager() const
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
Represents a character-granular source range.
void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD, const MacroDirective *Undef) override
Hook called whenever a macro #undef is seen.
MacroPPCallbacks(CodeGenerator *Gen, Preprocessor &PP)
One of these records is kept for each identifier that is lexed.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
StringRef getName() const
Return the actual identifier string.
Dataflow Directional Tag Classes.
Encapsulates changes to the "macros namespace" (the location where the macro name became active,...
const MacroInfo * getMacroInfo() const
void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID=FileID()) override
Callback invoked whenever a source file is entered or exited.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool isFunctionLike() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isGNUVarargs() const
param_iterator param_end() const