clang-tools 10.0.0

FindAllMacros.h
Go to the documentation of this file.
1 //===-- FindAllMacros.h - find all macros -----------------------*- C++ -*-===//
2 //
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_MACROS_H
11 #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_MACROS_H
12
13 #include "SymbolInfo.h"
14 #include "SymbolReporter.h"
15 #include "clang/Lex/PPCallbacks.h"
16
17 namespace clang {
18 class MacroInfo;
19 namespace find_all_symbols {
20
21 class HeaderMapCollector;
22
23 /// A preprocessor that collects all macro symbols.
24 /// The contexts of a macro will be ignored since they are not available during
25 /// preprocessing period.
26 class FindAllMacros : public clang::PPCallbacks {
27 public:
28 explicit FindAllMacros(SymbolReporter *Reporter, SourceManager *SM,
29 HeaderMapCollector *Collector = nullptr)
30 : Reporter(Reporter), SM(SM), Collector(Collector) {}
31
32 void MacroDefined(const Token &MacroNameTok,
33 const MacroDirective *MD) override;
34
35 void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
36 SourceRange Range, const MacroArgs *Args) override;
37
38 void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
39 const MacroDefinition &MD) override;
40
41 void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
42 const MacroDefinition &MD) override;
43
44 void EndOfMainFile() override;
45
46 private:
47 llvm::Optional<SymbolInfo> CreateMacroSymbol(const Token &MacroNameTok,
48 const MacroInfo *MD);
49 // Not a callback, just a common path for all usage types.
50 void MacroUsed(const Token &Name, const MacroDefinition &MD);
51
52 SymbolInfo::SignalMap FileSymbols;
53 // Reporter for SymbolInfo.
54 SymbolReporter *const Reporter;
55 SourceManager *const SM;
56 // A remapping header file collector allowing clients to include a different
57 // header.
58 HeaderMapCollector *const Collector;
59 };
60
61 } // namespace find_all_symbols
62 } // namespace clang
63
64 #endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_MACROS_H
Loc
SourceLocation Loc
&#39;#&#39; location in the include directive
Definition: IncludeOrderCheck.cpp:37
clang::find_all_symbols::FindAllMacros::Ifdef
void Ifdef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
Definition: FindAllMacros.cpp:52
clang::find_all_symbols::HeaderMapCollector
HeaderMappCollector collects all remapping header files.
Definition: HeaderMapCollector.h:22
SymbolReporter.h
clang::find_all_symbols::FindAllMacros::FindAllMacros
FindAllMacros(SymbolReporter *Reporter, SourceManager *SM, HeaderMapCollector *Collector=nullptr)
Definition: FindAllMacros.h:28
clang::find_all_symbols::FindAllMacros::MacroExpands
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override
Definition: FindAllMacros.cpp:46
clang::find_all_symbols::FindAllMacros::EndOfMainFile
void EndOfMainFile() override
Definition: FindAllMacros.cpp:62
SymbolInfo.h
clang::find_all_symbols::FindAllMacros::Ifndef
void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
Definition: FindAllMacros.cpp:57
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:27
clang::find_all_symbols::FindAllMacros::MacroDefined
void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override
Definition: FindAllMacros.cpp:33
clang::find_all_symbols::SymbolReporter
An interface for classes that collect symbols.
Definition: SymbolReporter.h:18
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::find_all_symbols::FindAllMacros
A preprocessor that collects all macro symbols.
Definition: FindAllMacros.h:26
clang::doc::MD
static GeneratorRegistry::Add< MDGenerator > MD(MDGenerator::Format, "Generator for MD output.")
Range
CharSourceRange Range
SourceRange for the file name.
Definition: IncludeOrderCheck.cpp:38
clang::find_all_symbols::SymbolInfo::SignalMap
std::map< SymbolInfo, Signals > SignalMap
Definition: SymbolInfo.h:68