2016-05-24 23:10:58 +08:00
|
|
|
//===-- FindAllSymbolsAction.h - find all symbols action --------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
|
|
|
|
|
|
|
|
#include "FindAllSymbols.h"
|
|
|
|
#include "HeaderMapCollector.h"
|
|
|
|
#include "PragmaCommentHandler.h"
|
2016-09-07 03:53:26 +08:00
|
|
|
#include "clang/ASTMatchers/ASTMatchFinder.h"
|
2016-05-24 23:10:58 +08:00
|
|
|
#include "clang/Frontend/CompilerInstance.h"
|
2016-09-07 03:53:26 +08:00
|
|
|
#include "clang/Frontend/FrontendAction.h"
|
2016-05-24 23:10:58 +08:00
|
|
|
#include "clang/Tooling/Tooling.h"
|
2016-09-07 03:53:26 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include <memory>
|
2016-05-24 23:10:58 +08:00
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace find_all_symbols {
|
|
|
|
|
|
|
|
class FindAllSymbolsAction : public clang::ASTFrontendAction {
|
|
|
|
public:
|
|
|
|
explicit FindAllSymbolsAction(
|
|
|
|
SymbolReporter *Reporter,
|
2016-07-04 19:22:35 +08:00
|
|
|
const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr);
|
2016-05-24 23:10:58 +08:00
|
|
|
|
|
|
|
std::unique_ptr<clang::ASTConsumer>
|
|
|
|
CreateASTConsumer(clang::CompilerInstance &Compiler,
|
|
|
|
StringRef InFile) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
SymbolReporter *const Reporter;
|
|
|
|
clang::ast_matchers::MatchFinder MatchFinder;
|
|
|
|
HeaderMapCollector Collector;
|
|
|
|
PragmaCommentHandler Handler;
|
|
|
|
FindAllSymbols Matcher;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FindAllSymbolsActionFactory : public tooling::FrontendActionFactory {
|
|
|
|
public:
|
|
|
|
FindAllSymbolsActionFactory(
|
|
|
|
SymbolReporter *Reporter,
|
2016-07-04 19:22:35 +08:00
|
|
|
const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
|
|
|
|
: Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
|
2016-05-24 23:10:58 +08:00
|
|
|
|
2016-09-07 03:53:26 +08:00
|
|
|
clang::FrontendAction *create() override {
|
2016-07-04 19:22:35 +08:00
|
|
|
return new FindAllSymbolsAction(Reporter, RegexHeaderMap);
|
2016-05-24 23:10:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SymbolReporter *const Reporter;
|
2016-07-04 19:22:35 +08:00
|
|
|
const HeaderMapCollector::RegexHeaderMap *const RegexHeaderMap;
|
2016-05-24 23:10:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace find_all_symbols
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
|