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;
76 const MacroDefinition &MD)
override;
78 const MacroDefinition &MD)
override;
81 SourceRange
Range)
override;
94 void add(
const Token &MacroNameTok,
const MacroInfo *MI,
95 bool IsDefinition =
false,
bool InConditionalDirective =
false);
96 const SourceManager &SM;
97 const Preprocessor &PP;
98 bool InMainFile =
true;
111std::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.
A single C++ or preprocessor token.