9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_COLLECTMACROS_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_COLLECTMACROS_H
15#include "clang/Basic/SourceLocation.h"
16#include "clang/Lex/PPCallbacks.h"
17#include "clang/Lex/Preprocessor.h"
18#include "llvm/ADT/DenseMap.h"
39 llvm::DenseMap<SymbolID, std::vector<MacroOccurrence>>
MacroRefs;
55 : SM(PP.getSourceManager()), PP(PP),
Out(
Out) {}
58 SrcMgr::CharacteristicKind, FileID)
override;
63 SourceRange
Range,
const MacroArgs *
Args)
override;
66 const clang::MacroDefinition &MD,
67 const clang::MacroDirective *Undef)
override;
70 const MacroDefinition &MD)
override;
72 const MacroDefinition &MD)
override;
73 using PPCallbacks::Elifdef;
74 using PPCallbacks::Elifndef;
75 void Elifdef(SourceLocation
Loc,
const Token &MacroNameTok,
76 const MacroDefinition &MD)
override;
77 void Elifndef(SourceLocation
Loc,
const Token &MacroNameTok,
78 const MacroDefinition &MD)
override;
81 SourceRange
Range)
override;
86 void add(
const Token &MacroNameTok,
const MacroInfo *MI,
87 bool IsDefinition =
false,
bool InConditionalDirective =
false);
88 const SourceManager &SM;
89 const Preprocessor &PP;
90 bool InMainFile =
true;
103std::unique_ptr<PPCallbacks>
CompiledFragmentImpl & Out
Collects macro references (e.g.
void MacroDefined(const Token &MacroName, const MacroDirective *MD) override
void FileChanged(SourceLocation Loc, FileChangeReason, SrcMgr::CharacteristicKind, FileID) override
void MacroExpands(const Token &MacroName, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override
CollectMainFileMacros(const Preprocessor &PP, MainFileMacros &Out)
void Elifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
void Defined(const Token &MacroName, const MacroDefinition &MD, SourceRange Range) override
void MacroUndefined(const clang::Token &MacroName, const clang::MacroDefinition &MD, const clang::MacroDirective *Undef) override
void Ifndef(SourceLocation Loc, const Token &MacroName, const MacroDefinition &MD) override
void SourceRangeSkipped(SourceRange R, SourceLocation EndifLoc) override
void Ifdef(SourceLocation Loc, const Token &MacroName, const MacroDefinition &MD) override
void Elifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
std::unique_ptr< PPCallbacks > collectPragmaMarksCallback(const SourceManager &SM, std::vector< PragmaMark > &Out)
Collect all pragma marks from the main file.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Range toRange(const SourceManager &SM) const
bool InConditionalDirective
std::vector< MacroOccurrence > UnknownMacros
llvm::DenseMap< SymbolID, std::vector< MacroOccurrence > > MacroRefs
std::vector< Range > SkippedRanges
Represents a #pragma mark in the main file.