clang-tools 8.0.0

FindAllSymbols.h
Go to the documentation of this file.
1 //===-- FindAllSymbols.h - find all symbols----------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_SYMBOL_MATCHER_H
11 #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_SYMBOL_MATCHER_H
12
13 #include "SymbolInfo.h"
14 #include "SymbolReporter.h"
15 #include "clang/ASTMatchers/ASTMatchFinder.h"
16 #include <string>
17
18 namespace clang {
19 namespace find_all_symbols {
20
21 class HeaderMapCollector;
22
23 /// \brief FindAllSymbols collects all classes, free standing functions and
24 /// global variables with some extra information such as the path of the header
25 /// file, the namespaces they are contained in, the type of variables and the
26 /// parameter types of functions.
27 ///
28 /// NOTE:
29 /// - Symbols declared in main files are not collected since they can not be
30 /// included.
31 /// - Member functions are not collected because accessing them must go
32 /// through the class. #include fixer only needs the class name to find
33 /// headers.
34 ///
35 class FindAllSymbols : public ast_matchers::MatchFinder::MatchCallback {
36 public:
37 explicit FindAllSymbols(SymbolReporter *Reporter,
38 HeaderMapCollector *Collector = nullptr)
39 : Reporter(Reporter), Collector(Collector) {}
40
41 void registerMatchers(ast_matchers::MatchFinder *MatchFinder);
42
43 void run(const ast_matchers::MatchFinder::MatchResult &result) override;
44
45 protected:
46 void onEndOfTranslationUnit() override;
47
48 private:
49 // Current source file being processed, filled by first symbol found.
50 std::string Filename;
51 // Findings for the current source file, flushed on onEndOfTranslationUnit.
52 SymbolInfo::SignalMap FileSymbols;
53 // Reporter for SymbolInfo.
54 SymbolReporter *const Reporter;
55 // A remapping header file collector allowing clients include a different
56 // header.
57 HeaderMapCollector *const Collector;
58 };
59
60 } // namespace find_all_symbols
61 } // namespace clang
62
63 #endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_SYMBOL_MATCHER_H
clang::find_all_symbols::HeaderMapCollector
HeaderMappCollector collects all remapping header files.
Definition: HeaderMapCollector.h:23
SymbolReporter.h
clang::find_all_symbols::FindAllSymbols::run
void run(const ast_matchers::MatchFinder::MatchResult &result) override
Definition: FindAllSymbols.cpp:238
SymbolInfo.h
clang::find_all_symbols::FindAllSymbols
FindAllSymbols collects all classes, free standing functions and global variables with some extra inf...
Definition: FindAllSymbols.h:35
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::SymbolInfo::SignalMap
std::map< SymbolInfo, Signals > SignalMap
Definition: SymbolInfo.h:69
clang::find_all_symbols::FindAllSymbols::onEndOfTranslationUnit
void onEndOfTranslationUnit() override
Definition: FindAllSymbols.cpp:260
clang::find_all_symbols::FindAllSymbols::FindAllSymbols
FindAllSymbols(SymbolReporter *Reporter, HeaderMapCollector *Collector=nullptr)
Definition: FindAllSymbols.h:37
clang::find_all_symbols::FindAllSymbols::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *MatchFinder)
Definition: FindAllSymbols.cpp:117