clang-tools 18.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"
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
22namespace clang {
23namespace find_all_symbols {
24
25class FindAllSymbolsAction : public clang::ASTFrontendAction {
26public:
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
35private:
36 SymbolReporter *const Reporter;
37 clang::ast_matchers::MatchFinder MatchFinder;
38 HeaderMapCollector Collector;
40 FindAllSymbols Matcher;
41};
42
43class FindAllSymbolsActionFactory : public tooling::FrontendActionFactory {
44public:
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
54private:
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
std::unique_ptr< FrontendAction > create() override
FindAllSymbolsActionFactory(SymbolReporter *Reporter, const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap=nullptr)
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef InFile) override
FindAllSymbols collects all classes, free standing functions and global variables with some extra inf...
HeaderMappCollector collects all remapping header files.
std::vector< std::pair< const char *, const char * > > RegexHeaderMap
PragmaCommentHandler parses pragma comment on include files to determine when we should include a dif...
An interface for classes that collect symbols.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//