1 //===-- FindAllSymbolsAction.h - find all symbols action --------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
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
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"
23 namespace find_all_symbols
{
25 class FindAllSymbolsAction
: public clang::ASTFrontendAction
{
27 explicit FindAllSymbolsAction(
28 SymbolReporter
*Reporter
,
29 const HeaderMapCollector::RegexHeaderMap
*RegexHeaderMap
= nullptr);
31 std::unique_ptr
<clang::ASTConsumer
>
32 CreateASTConsumer(clang::CompilerInstance
&Compiler
,
33 StringRef InFile
) override
;
36 SymbolReporter
*const Reporter
;
37 clang::ast_matchers::MatchFinder MatchFinder
;
38 HeaderMapCollector Collector
;
39 PragmaCommentHandler Handler
;
40 FindAllSymbols Matcher
;
43 class FindAllSymbolsActionFactory
: public tooling::FrontendActionFactory
{
45 FindAllSymbolsActionFactory(
46 SymbolReporter
*Reporter
,
47 const HeaderMapCollector::RegexHeaderMap
*RegexHeaderMap
= nullptr)
48 : Reporter(Reporter
), RegexHeaderMap(RegexHeaderMap
) {}
50 std::unique_ptr
<FrontendAction
> create() override
{
51 return std::make_unique
<FindAllSymbolsAction
>(Reporter
, RegexHeaderMap
);
55 SymbolReporter
*const Reporter
;
56 const HeaderMapCollector::RegexHeaderMap
*const RegexHeaderMap
;
59 } // namespace find_all_symbols
62 #endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H