|
clang 22.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 |
| std::optional< StringRef > | getFormattedExpandedText (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 87 of file MacroExpansionContext.cpp.
| void MacroExpansionContext::dumpExpandedTexts | ( | ) | const |
Definition at line 168 of file MacroExpansionContext.cpp.
References dumpExpandedTextsToStream().
| void MacroExpansionContext::dumpExpandedTextsToStream | ( | raw_ostream & | OS | ) | const |
Definition at line 190 of file MacroExpansionContext.cpp.
Referenced by dumpExpandedTexts().
| void MacroExpansionContext::dumpExpansionRanges | ( | ) | const |
Definition at line 165 of file MacroExpansionContext.cpp.
References dumpExpansionRangesToStream().
| void MacroExpansionContext::dumpExpansionRangesToStream | ( | raw_ostream & | OS | ) | const |
Definition at line 172 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 102 of file MacroExpansionContext.cpp.
References clang::SourceLocation::isMacroID().
Referenced by getFormattedExpandedText().
| std::optional< StringRef > MacroExpansionContext::getFormattedExpandedText | ( | SourceLocation | MacroExpansionLoc | ) | const |
| MacroExpansionLoc | Must be the expansion location of a macro. |
Definition at line 136 of file MacroExpansionContext.cpp.
References clang::tooling::applyAllReplacements(), getExpandedText(), clang::format::getLLVMStyle(), clang::format::reformat(), and clang::Result.
Referenced by getExpandedMacro().
| std::optional< StringRef > MacroExpansionContext::getOriginalText | ( | SourceLocation | MacroExpansionLoc | ) | const |
| MacroExpansionLoc | Must be the expansion location of a macro. |
Definition at line 120 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 90 of file MacroExpansionContext.cpp.
References clang::Preprocessor::getSourceManager(), and Tok.
|
friend |
Definition at line 112 of file MacroExpansionContext.h.
References Tok.