clang 20.0.0git
|
MacroExpansionContext tracks the macro expansions processed by the Preprocessor. More...
#include "clang/Analysis/MacroExpansionContext.h"
Public Member Functions | |
MacroExpansionContext (const LangOptions &LangOpts) | |
Creates a MacroExpansionContext. | |
void | registerForPreprocessor (Preprocessor &PP) |
Register the necessary callbacks to the Preprocessor to record the expansion events and the generated tokens. | |
std::optional< StringRef > | getExpandedText (SourceLocation MacroExpansionLoc) const |
std::optional< StringRef > | getOriginalText (SourceLocation MacroExpansionLoc) const |
LLVM_DUMP_METHOD void | dumpExpansionRangesToStream (raw_ostream &OS) const |
LLVM_DUMP_METHOD void | dumpExpandedTextsToStream (raw_ostream &OS) const |
LLVM_DUMP_METHOD void | dumpExpansionRanges () const |
LLVM_DUMP_METHOD void | dumpExpandedTexts () const |
Friends | |
class | detail::MacroExpansionRangeRecorder |
MacroExpansionContext tracks the macro expansions processed by the Preprocessor.
It means that it can track source locations from a single translation unit. For every macro expansion it can tell you what text will be substituted.
It was designed to deal with:
Definition at line 73 of file MacroExpansionContext.h.
|
explicit |
Creates a MacroExpansionContext.
Definition at line 86 of file MacroExpansionContext.cpp.
void MacroExpansionContext::dumpExpandedTexts | ( | ) | const |
Definition at line 138 of file MacroExpansionContext.cpp.
References dumpExpandedTextsToStream().
void MacroExpansionContext::dumpExpandedTextsToStream | ( | raw_ostream & | OS | ) | const |
Definition at line 160 of file MacroExpansionContext.cpp.
Referenced by dumpExpandedTexts().
void MacroExpansionContext::dumpExpansionRanges | ( | ) | const |
Definition at line 135 of file MacroExpansionContext.cpp.
References dumpExpansionRangesToStream().
void MacroExpansionContext::dumpExpansionRangesToStream | ( | raw_ostream & | OS | ) | const |
Definition at line 142 of file MacroExpansionContext.cpp.
Referenced by dumpExpansionRanges().
std::optional< StringRef > MacroExpansionContext::getExpandedText | ( | SourceLocation | MacroExpansionLoc | ) | const |
MacroExpansionLoc | Must be the expansion location of a macro. |
Definition at line 101 of file MacroExpansionContext.cpp.
References clang::SourceLocation::isMacroID().
Referenced by getExpandedMacro().
std::optional< StringRef > MacroExpansionContext::getOriginalText | ( | SourceLocation | MacroExpansionLoc | ) | const |
MacroExpansionLoc | Must be the expansion location of a macro. |
Definition at line 119 of file MacroExpansionContext.cpp.
References clang::CharSourceRange::getCharRange(), clang::Lexer::getSourceText(), and clang::SourceLocation::isMacroID().
void MacroExpansionContext::registerForPreprocessor | ( | Preprocessor & | PP | ) |
Register the necessary callbacks to the Preprocessor to record the expansion events and the generated tokens.
Must ensure that this object outlives the given Preprocessor.
Definition at line 89 of file MacroExpansionContext.cpp.
References clang::Preprocessor::addPPCallbacks(), clang::Preprocessor::getSourceManager(), and clang::Preprocessor::setTokenWatcher().
|
friend |
Definition at line 105 of file MacroExpansionContext.h.