Line data Source code
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:
46 : FindAllSymbolsActionFactory(
47 : SymbolReporter *Reporter,
48 : const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
49 14 : : Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
50 :
51 14 : clang::FrontendAction *create() override {
52 14 : 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
|