37 #include "clang/ASTMatchers/ASTMatchers.h"
38 #include "clang/ASTMatchers/ASTMatchFinder.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(Replacements *Replace) : Replace(Replace) {}
59 void run(
const MatchFinder::MatchResult &
Result)
override {
67 Replacements *Replace;
72 static cl::extrahelp
CommonHelp(CommonOptionsParser::HelpMessage);
75 int main(
int argc,
const char **argv) {
76 llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
78 RefactoringTool Tool(OptionsParser.getCompilations(),
79 OptionsParser.getSourcePathList());
80 ast_matchers::MatchFinder
Finder;
81 ToolTemplateCallback Callback(&Tool.getReplacements());
87 return Tool.run(newFrontendActionFactory(&Finder).
get());
std::unique_ptr< ast_matchers::MatchFinder > Finder