clang-tools  7.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
HeaderMappCollector collects all remapping header files.
void run(const ast_matchers::MatchFinder::MatchResult &result) override
FindAllSymbols collects all classes, free standing functions and global variables with some extra inf...
An interface for classes that collect symbols.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::map< SymbolInfo, Signals > SignalMap
Definition: SymbolInfo.h:69
FindAllSymbols(SymbolReporter *Reporter, HeaderMapCollector *Collector=nullptr)
void registerMatchers(ast_matchers::MatchFinder *MatchFinder)