Go to the documentation of this file.
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_COLLECTMACROS_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COLLECTMACROS_H
15 #include "clang/Lex/PPCallbacks.h"
16 #include "llvm/ADT/DenseMap.h"
31 llvm::DenseMap<SymbolID, std::vector<MacroOccurrence>>
MacroRefs;
50 SrcMgr::CharacteristicKind, FileID)
override {
54 void MacroDefined(
const Token &MacroName,
const MacroDirective *
MD)
override {
55 add(MacroName,
MD->getMacroInfo(),
true);
59 SourceRange
Range,
const MacroArgs *
Args)
override {
60 add(MacroName,
MD.getMacroInfo());
64 const clang::MacroDefinition &
MD,
65 const clang::MacroDirective *Undef)
override {
66 add(MacroName,
MD.getMacroInfo());
69 void Ifdef(SourceLocation
Loc,
const Token &MacroName,
70 const MacroDefinition &
MD)
override {
71 add(MacroName,
MD.getMacroInfo());
74 void Ifndef(SourceLocation
Loc,
const Token &MacroName,
75 const MacroDefinition &
MD)
override {
76 add(MacroName,
MD.getMacroInfo());
79 void Defined(
const Token &MacroName,
const MacroDefinition &
MD,
80 SourceRange
Range)
override {
81 add(MacroName,
MD.getMacroInfo());
93 void add(
const Token &MacroNameTok,
const MacroInfo *MI,
94 bool IsDefinition =
false);
95 const SourceManager &SM;
96 bool InMainFile =
true;
109 std::unique_ptr<PPCallbacks>
115 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_COLLECTMACROS_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.")
Represents a #pragma mark in the main file.
void Defined(const Token &MacroName, const MacroDefinition &MD, SourceRange Range) override
llvm::DenseMap< SymbolID, std::vector< MacroOccurrence > > 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
std::unique_ptr< PPCallbacks > collectPragmaMarksCallback(const SourceManager &SM, std::vector< PragmaMark > &Out)
Collect all pragma marks from the main file.
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
std::vector< MacroOccurrence > UnknownMacros
CompiledFragmentImpl & Out
void MacroExpands(const Token &MacroName, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override