clang: clang::MacroExpansionContext Class Reference (original) (raw)
MacroExpansionContext tracks the macro expansions processed by the Preprocessor. More...
#include "[clang/Analysis/MacroExpansionContext.h](MacroExpansionContext%5F8h%5Fsource.html)"
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 |
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:
- regular macros
- macro functions
- variadic macros
- transitive macro expansions
- macro redefinition
- unbalanced parenthesis
void bar();
#define retArg(x) x
#define retArgUnclosed retArg(bar()
#define BB CC
#define applyInt BB(int)
#define CC(x) retArgUnclosed
void unbalancedMacros() {
applyInt );
}
#define expandArgUnclosedCommaExpr(x) (x, bar(), 1
#define f expandArgUnclosedCommaExpr
void unbalancedMacros2() {
int x = f(f(1)) ));
}
Definition at line 73 of file MacroExpansionContext.h.
MacroExpansionContext::MacroExpansionContext ( const LangOptions & LangOpts) | explicit |
---|
◆ dumpExpandedTexts()
void MacroExpansionContext::dumpExpandedTexts | ( | ) | const |
---|
◆ dumpExpandedTextsToStream()
void MacroExpansionContext::dumpExpandedTextsToStream | ( | raw_ostream & | OS | ) | const |
---|
◆ dumpExpansionRanges()
void MacroExpansionContext::dumpExpansionRanges | ( | ) | const |
---|
◆ dumpExpansionRangesToStream()
void MacroExpansionContext::dumpExpansionRangesToStream | ( | raw_ostream & | OS | ) | const |
---|
◆ getExpandedText()
std::optional< StringRef > MacroExpansionContext::getExpandedText | ( | SourceLocation | MacroExpansionLoc | ) | const |
---|
◆ getOriginalText()
std::optional< StringRef > MacroExpansionContext::getOriginalText | ( | SourceLocation | MacroExpansionLoc | ) | const |
---|
◆ registerForPreprocessor()
void MacroExpansionContext::registerForPreprocessor | ( | Preprocessor & | PP | ) |
---|
◆ detail::MacroExpansionRangeRecorder
The documentation for this class was generated from the following files:
- include/clang/Analysis/MacroExpansionContext.h
- lib/Analysis/MacroExpansionContext.cpp