Go to the documentation of this file.
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_COLLECTEDMACROS_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COLLECTEDMACROS_H
16 #include "clang/Basic/IdentifierTable.h"
17 #include "clang/Lex/PPCallbacks.h"
18 #include "llvm/ADT/DenseMap.h"
28 llvm::DenseMap<SymbolID, std::vector<Range>>
MacroRefs;
47 SrcMgr::CharacteristicKind, FileID)
override {
51 void MacroDefined(
const Token &MacroName,
const MacroDirective *
MD)
override {
52 add(MacroName,
MD->getMacroInfo());
56 SourceRange
Range,
const MacroArgs *Args)
override {
57 add(MacroName,
MD.getMacroInfo());
61 const clang::MacroDefinition &
MD,
62 const clang::MacroDirective *Undef)
override {
63 add(MacroName,
MD.getMacroInfo());
66 void Ifdef(SourceLocation
Loc,
const Token &MacroName,
67 const MacroDefinition &
MD)
override {
68 add(MacroName,
MD.getMacroInfo());
71 void Ifndef(SourceLocation
Loc,
const Token &MacroName,
72 const MacroDefinition &
MD)
override {
73 add(MacroName,
MD.getMacroInfo());
76 void Defined(
const Token &MacroName,
const MacroDefinition &
MD,
77 SourceRange
Range)
override {
78 add(MacroName,
MD.getMacroInfo());
90 void add(
const Token &MacroNameTok,
const MacroInfo *MI);
91 const SourceManager &SM;
92 bool InMainFile =
true;
99 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_COLLECTEDMACROS_H
Collects macro references (e.g.
void Ifdef(SourceLocation Loc, const Token &MacroName, const MacroDefinition &MD) override
static GeneratorRegistry::Add< MDGenerator > MD(MDGenerator::Format, "Generator for MD output.")
void Defined(const Token &MacroName, const MacroDefinition &MD, SourceRange Range) override
llvm::DenseMap< SymbolID, std::vector< Range > > MacroRefs
Position sourceLocToPosition(const SourceManager &SM, SourceLocation Loc)
Turn a SourceLocation into a [line, column] pair.
void SourceRangeSkipped(SourceRange R, SourceLocation EndifLoc) override
void Ifndef(SourceLocation Loc, const Token &MacroName, const MacroDefinition &MD) override
CollectMainFileMacros(const SourceManager &SM, MainFileMacros &Out)
void MacroDefined(const Token &MacroName, const MacroDirective *MD) override
std::vector< Range > SkippedRanges
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void FileChanged(SourceLocation Loc, FileChangeReason, SrcMgr::CharacteristicKind, FileID) override
bool isInsideMainFile(SourceLocation Loc, const SourceManager &SM)
Returns true iff Loc is inside the main file.
void MacroUndefined(const clang::Token &MacroName, const clang::MacroDefinition &MD, const clang::MacroDirective *Undef) override
SourceLocation Loc
'#' location in the include directive
CompiledFragmentImpl & Out
void MacroExpands(const Token &MacroName, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override
std::vector< Range > UnknownMacros