clang-tools 8.0.0

FindAllMacros.h
Go to the documentation of this file.
1 //===-- FindAllMacros.h - find all macros -----------------------*- C++ -*-===//
2 //
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_MACROS_H
12 #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_MACROS_H
13
14 #include "SymbolInfo.h"
15 #include "SymbolReporter.h"
16 #include "clang/Lex/PPCallbacks.h"
17
18 namespace clang {
19 class MacroInfo;
20 namespace find_all_symbols {
21
22 class HeaderMapCollector;
23
24 /// \brief A preprocessor that collects all macro symbols.
25 /// The contexts of a macro will be ignored since they are not available during
26 /// preprocessing period.
27 class FindAllMacros : public clang::PPCallbacks {
28 public:
29 explicit FindAllMacros(SymbolReporter *Reporter, SourceManager *SM,
30 HeaderMapCollector *Collector = nullptr)
31 : Reporter(Reporter), SM(SM), Collector(Collector) {}
32
33 void MacroDefined(const Token &MacroNameTok,
34 const MacroDirective *MD) override;
35
36 void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
37 SourceRange Range, const MacroArgs *Args) override;
38
39 void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
40 const MacroDefinition &MD) override;
41
42 void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
43 const MacroDefinition &MD) override;
44
45 void EndOfMainFile() override;
46
47 private:
48 llvm::Optional<SymbolInfo> CreateMacroSymbol(const Token &MacroNameTok,
49 const MacroInfo *MD);
50 // Not a callback, just a common path for all usage types.
51 void MacroUsed(const Token &Name, const MacroDefinition &MD);
52
53 SymbolInfo::SignalMap FileSymbols;
54 // Reporter for SymbolInfo.
55 SymbolReporter *const Reporter;
56 SourceManager *const SM;
57 // A remapping header file collector allowing clients to include a different
58 // header.
59 HeaderMapCollector *const Collector;
60 };
61
62 } // namespace find_all_symbols
63 } // namespace clang
64
65 #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:53
clang::find_all_symbols::HeaderMapCollector
HeaderMappCollector collects all remapping header files.
Definition: HeaderMapCollector.h:23
SymbolReporter.h
clang::find_all_symbols::FindAllMacros::FindAllMacros
FindAllMacros(SymbolReporter *Reporter, SourceManager *SM, HeaderMapCollector *Collector=nullptr)
Definition: FindAllMacros.h:29
clang::find_all_symbols::FindAllMacros::MacroExpands
void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override
Definition: FindAllMacros.cpp:47
clang::find_all_symbols::FindAllMacros::EndOfMainFile
void EndOfMainFile() override
Definition: FindAllMacros.cpp:63
SymbolInfo.h
clang::find_all_symbols::FindAllMacros::Ifndef
void Ifndef(SourceLocation Loc, const Token &MacroNameTok, const MacroDefinition &MD) override
Definition: FindAllMacros.cpp:58
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
clang::find_all_symbols::FindAllMacros::MacroDefined
void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override
Definition: FindAllMacros.cpp:34
clang::find_all_symbols::SymbolReporter
An interface for classes that collect symbols.
Definition: SymbolReporter.h:19
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
clang::find_all_symbols::FindAllMacros
A preprocessor that collects all macro symbols.
Definition: FindAllMacros.h:27
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:69