52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
// Declares clang::SyntaxOnlyAction.
|
|
#include "clang/Frontend/FrontendActions.h"
|
|
#include "clang/Tooling/CommonOptionsParser.h"
|
|
#include "clang/Tooling/Tooling.h"
|
|
// Declares llvm::cl::extrahelp.
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "OperationFinder.hpp"
|
|
#include "TestASTConsumer.hpp"
|
|
#include "OperationFinderConsumer.hpp"
|
|
|
|
using namespace clang::tooling;
|
|
using namespace clang::ast_matchers;
|
|
using namespace llvm;
|
|
|
|
// Apply a custom category to all command-line options so that they are the
|
|
// only ones displayed.
|
|
static llvm::cl::OptionCategory MyToolCategory("opcounter options");
|
|
|
|
// CommonOptionsParser declares HelpMessage with a description of the common
|
|
// command-line options related to the compilation database and input files.
|
|
// It's nice to have this help message in all tools.
|
|
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
|
|
|
|
// A help message for this specific tool can be added afterwards.
|
|
static cl::extrahelp MoreHelp("\nMore help text...\n");
|
|
|
|
int main(int argc, const char** argv)
|
|
{
|
|
auto ExpectedParser = CommonOptionsParser::create(argc, argv, MyToolCategory);
|
|
if (!ExpectedParser)
|
|
{
|
|
// Fail gracefully for unsupported options.
|
|
llvm::errs() << ExpectedParser.takeError();
|
|
return 1;
|
|
}
|
|
|
|
CommonOptionsParser& OptionsParser = ExpectedParser.get();
|
|
ClangTool Tool(OptionsParser.getCompilations(),
|
|
OptionsParser.getSourcePathList());
|
|
|
|
OperationFinder op_finder;
|
|
MatchFinder finder;
|
|
|
|
op_finder.addMatcher(finder);
|
|
|
|
// Tool.run(newFrontendActionFactory<clang::ASTPrintAction>().get());
|
|
Tool.run(newFrontendActionFactory<DebuggeringASTAction>().get());
|
|
Tool.run(newFrontendActionFactory<OperationFinderAction>().get());
|
|
|
|
// return Tool.run(newFrontendActionFactory(&finder).get());
|
|
} |