clang-tools  8.0.0
FindAllSymbolsAction.h
Go to the documentation of this file.
1 //===-- FindAllSymbolsAction.h - find all symbols action --------*- 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_FIND_ALL_SYMBOLS_ACTION_H
11 #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
12 
13 #include "FindAllSymbols.h"
14 #include "HeaderMapCollector.h"
15 #include "PragmaCommentHandler.h"
16 #include "clang/ASTMatchers/ASTMatchFinder.h"
17 #include "clang/Frontend/CompilerInstance.h"
18 #include "clang/Frontend/FrontendAction.h"
19 #include "clang/Tooling/Tooling.h"
20 #include "llvm/ADT/StringRef.h"
21 #include <memory>
22 
23 namespace clang {
24 namespace find_all_symbols {
25 
26 class FindAllSymbolsAction : public clang::ASTFrontendAction {
27 public:
28  explicit FindAllSymbolsAction(
29  SymbolReporter *Reporter,
30  const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr);
31 
32  std::unique_ptr<clang::ASTConsumer>
33  CreateASTConsumer(clang::CompilerInstance &Compiler,
34  StringRef InFile) override;
35 
36 private:
37  SymbolReporter *const Reporter;
38  clang::ast_matchers::MatchFinder MatchFinder;
39  HeaderMapCollector Collector;
40  PragmaCommentHandler Handler;
41  FindAllSymbols Matcher;
42 };
43 
44 class FindAllSymbolsActionFactory : public tooling::FrontendActionFactory {
45 public:
47  SymbolReporter *Reporter,
48  const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
49  : Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
50 
51  clang::FrontendAction *create() override {
52  return new FindAllSymbolsAction(Reporter, RegexHeaderMap);
53  }
54 
55 private:
56  SymbolReporter *const Reporter;
57  const HeaderMapCollector::RegexHeaderMap *const RegexHeaderMap;
58 };
59 
60 } // namespace find_all_symbols
61 } // namespace clang
62 
63 #endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef InFile) override
FindAllSymbolsActionFactory(SymbolReporter *Reporter, const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap=nullptr)
HeaderMappCollector collects all remapping header files.
FindAllSymbols collects all classes, free standing functions and global variables with some extra inf...
std::vector< std::pair< const char *, const char * > > RegexHeaderMap
An interface for classes that collect symbols.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
FindAllSymbolsAction(SymbolReporter *Reporter, const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap=nullptr)
PragmaCommentHandler parses pragma comment on include files to determine when we should include a dif...