| 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: |
| 45 |
FindAllSymbolsActionFactory( |
| 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 |