37 #include "clang/ASTMatchers/ASTMatchFinder.h"
38 #include "clang/ASTMatchers/ASTMatchers.h"
39 #include "clang/Basic/SourceManager.h"
40 #include "clang/Frontend/FrontendActions.h"
41 #include "clang/Lex/Lexer.h"
42 #include "clang/Tooling/CommonOptionsParser.h"
43 #include "clang/Tooling/Refactoring.h"
44 #include "clang/Tooling/Tooling.h"
45 #include "llvm/Support/CommandLine.h"
46 #include "llvm/Support/MemoryBuffer.h"
47 #include "llvm/Support/Signals.h"
49 using namespace clang;
50 using namespace clang::ast_matchers;
51 using namespace clang::tooling;
55 class ToolTemplateCallback :
public MatchFinder::MatchCallback {
57 ToolTemplateCallback(std::map<std::string, Replacements> *Replace)
60 void run(
const MatchFinder::MatchResult &Result)
override {
69 std::map<std::string, Replacements> *Replace;
74 static cl::extrahelp
CommonHelp(CommonOptionsParser::HelpMessage);
77 int main(
int argc,
const char **argv) {
78 llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
80 RefactoringTool Tool(OptionsParser.getCompilations(),
81 OptionsParser.getSourcePathList());
82 ast_matchers::MatchFinder
Finder;
83 ToolTemplateCallback Callback(&Tool.getReplacements());
89 return Tool.run(newFrontendActionFactory(&Finder).
get());
std::unique_ptr< ast_matchers::MatchFinder > Finder