clang-tools  14.0.0git
FindAllSymbolsAction.h
Go to the documentation of this file.
1 //===-- FindAllSymbolsAction.h - find all symbols action --------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
10 #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
11 
12 #include "FindAllSymbols.h"
13 #include "HeaderMapCollector.h"
14 #include "PragmaCommentHandler.h"
15 #include "clang/ASTMatchers/ASTMatchFinder.h"
16 #include "clang/Frontend/CompilerInstance.h"
17 #include "clang/Frontend/FrontendAction.h"
18 #include "clang/Tooling/Tooling.h"
19 #include "llvm/ADT/StringRef.h"
20 #include <memory>
21 
22 namespace clang {
23 namespace find_all_symbols {
24 
25 class FindAllSymbolsAction : public clang::ASTFrontendAction {
26 public:
27  explicit FindAllSymbolsAction(
28  SymbolReporter *Reporter,
29  const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr);
30 
31  std::unique_ptr<clang::ASTConsumer>
32  CreateASTConsumer(clang::CompilerInstance &Compiler,
33  StringRef InFile) override;
34 
35 private:
36  SymbolReporter *const Reporter;
37  clang::ast_matchers::MatchFinder MatchFinder;
38  HeaderMapCollector Collector;
39  PragmaCommentHandler Handler;
40  FindAllSymbols Matcher;
41 };
42 
43 class FindAllSymbolsActionFactory : public tooling::FrontendActionFactory {
44 public:
46  SymbolReporter *Reporter,
47  const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
48  : Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
49 
50  std::unique_ptr<FrontendAction> create() override {
51  return std::make_unique<FindAllSymbolsAction>(Reporter, RegexHeaderMap);
52  }
53 
54 private:
55  SymbolReporter *const Reporter;
56  const HeaderMapCollector::RegexHeaderMap *const RegexHeaderMap;
57 };
58 
59 } // namespace find_all_symbols
60 } // namespace clang
61 
62 #endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
clang::find_all_symbols::FindAllSymbolsActionFactory::FindAllSymbolsActionFactory
FindAllSymbolsActionFactory(SymbolReporter *Reporter, const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap=nullptr)
Definition: FindAllSymbolsAction.h:45
clang::find_all_symbols::FindAllSymbolsActionFactory::create
std::unique_ptr< FrontendAction > create() override
Definition: FindAllSymbolsAction.h:50
clang::find_all_symbols::FindAllSymbolsAction
Definition: FindAllSymbolsAction.h:25
clang::find_all_symbols::HeaderMapCollector::RegexHeaderMap
std::vector< std::pair< const char *, const char * > > RegexHeaderMap
Definition: HeaderMapCollector.h:25
clang::find_all_symbols::FindAllSymbolsAction::FindAllSymbolsAction
FindAllSymbolsAction(SymbolReporter *Reporter, const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap=nullptr)
Definition: FindAllSymbolsAction.cpp:18
clang::find_all_symbols::FindAllSymbolsAction::CreateASTConsumer
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef InFile) override
Definition: FindAllSymbolsAction.cpp:27
HeaderMapCollector.h
clang::find_all_symbols::HeaderMapCollector
HeaderMappCollector collects all remapping header files.
Definition: HeaderMapCollector.h:22
clang::find_all_symbols::FindAllSymbols
FindAllSymbols collects all classes, free standing functions and global variables with some extra inf...
Definition: FindAllSymbols.h:34
PragmaCommentHandler.h
FindAllSymbols.h
clang::find_all_symbols::FindAllSymbolsActionFactory
Definition: FindAllSymbolsAction.h:43
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::PragmaCommentHandler
PragmaCommentHandler parses pragma comment on include files to determine when we should include a dif...
Definition: PragmaCommentHandler.h:27