1 //===-- FindAllSymbols.h - find all symbols----------------------*- 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_SYMBOL_MATCHER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_SYMBOL_MATCHER_H
12 #include "SymbolInfo.h"
13 #include "SymbolReporter.h"
14 #include "clang/ASTMatchers/ASTMatchFinder.h"
18 namespace find_all_symbols
{
20 class HeaderMapCollector
;
22 /// FindAllSymbols collects all classes, free standing functions and
23 /// global variables with some extra information such as the path of the header
24 /// file, the namespaces they are contained in, the type of variables and the
25 /// parameter types of functions.
28 /// - Symbols declared in main files are not collected since they can not be
30 /// - Member functions are not collected because accessing them must go
31 /// through the class. #include fixer only needs the class name to find
34 class FindAllSymbols
: public ast_matchers::MatchFinder::MatchCallback
{
36 explicit FindAllSymbols(SymbolReporter
*Reporter
,
37 HeaderMapCollector
*Collector
= nullptr)
38 : Reporter(Reporter
), Collector(Collector
) {}
40 void registerMatchers(ast_matchers::MatchFinder
*MatchFinder
);
42 void run(const ast_matchers::MatchFinder::MatchResult
&result
) override
;
45 void onEndOfTranslationUnit() override
;
48 // Current source file being processed, filled by first symbol found.
50 // Findings for the current source file, flushed on onEndOfTranslationUnit.
51 SymbolInfo::SignalMap FileSymbols
;
52 // Reporter for SymbolInfo.
53 SymbolReporter
*const Reporter
;
54 // A remapping header file collector allowing clients include a different
56 HeaderMapCollector
*const Collector
;
59 } // namespace find_all_symbols
62 #endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_SYMBOL_MATCHER_H