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"
40 llvm::DenseMap<SymbolID, std::vector<MacroOccurrence>>
MacroRefs;
56 : SM(PP.getSourceManager()), PP(PP), Out(Out) {}
58 void FileChanged(SourceLocation Loc, FileChangeReason,
59 SrcMgr::CharacteristicKind, FileID)
override;
64 SourceRange
Range,
const MacroArgs *Args)
override;
67 const clang::MacroDefinition &MD,
68 const clang::MacroDirective *Undef)
override;
70 void Ifdef(SourceLocation Loc,
const Token &MacroName,
71 const MacroDefinition &MD)
override;
72 void Ifndef(SourceLocation Loc,
const Token &MacroName,
73 const MacroDefinition &MD)
override;
74 using PPCallbacks::Elifdef;
75 using PPCallbacks::Elifndef;
76 void Elifdef(SourceLocation Loc,
const Token &MacroNameTok,
77 const MacroDefinition &MD)
override;
79 const MacroDefinition &MD)
override;
81 void Defined(
const Token &MacroName,
const MacroDefinition &MD,
82 SourceRange
Range)
override;
95 void add(
const Token &MacroNameTok,
const MacroInfo *MI,
96 bool IsDefinition =
false,
bool InConditionalDirective =
false);
97 const SourceManager &SM;
98 const Preprocessor &PP;
99 bool InMainFile =
true;
112std::unique_ptr<PPCallbacks>
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
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
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
CharSourceRange toSourceRange(const SourceManager &SM) const
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.