|
|
@@ -20,17 +20,11 @@
|
|
|
// THE SOFTWARE.
|
|
|
//
|
|
|
|
|
|
-#include "clang/AST/ASTConsumer.h"
|
|
|
-#include "clang/Driver/Options.h"
|
|
|
-#include "clang/Frontend/ASTConsumers.h"
|
|
|
-#include "clang/Frontend/CompilerInstance.h"
|
|
|
-#include "clang/Rewrite/Frontend/FixItRewriter.h"
|
|
|
-#include "clang/Rewrite/Frontend/FrontendActions.h"
|
|
|
-#include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
|
|
|
-#include "clang/Tooling/CommonOptionsParser.h"
|
|
|
-#include "clang/Tooling/Tooling.h"
|
|
|
-#include "llvm/Support/Signals.h"
|
|
|
+#include <clang/Driver/Options.h>
|
|
|
+#include <clang/Tooling/CommonOptionsParser.h>
|
|
|
+#include <clang/Tooling/Tooling.h>
|
|
|
|
|
|
+using namespace clang;
|
|
|
using namespace clang::driver;
|
|
|
using namespace clang::tooling;
|
|
|
using namespace llvm;
|
|
|
@@ -38,37 +32,32 @@ using namespace llvm;
|
|
|
static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
|
|
|
static cl::extrahelp MoreHelp(
|
|
|
"\tFor example, to run Annotator on all files in a subtree of the\n"
|
|
|
- "\tsource tree, use:\n"
|
|
|
- "\n"
|
|
|
- "\t find path/in/substree -name '*.cpp'|xargs Annotator -p build/path\n"
|
|
|
- "\n"
|
|
|
- "\tNote, that path/in/subtree and current directory should follow the\n"
|
|
|
- "\trules described above.\n"
|
|
|
- "\n"
|
|
|
+ "\tsource tree, use:\n"
|
|
|
+ "\n"
|
|
|
+ "\t find path/in/substree -name '*.cpp'|xargs Annotator -p build/path\n"
|
|
|
+ "\n"
|
|
|
+ "\tNote, that path/in/subtree and current directory should follow the\n"
|
|
|
+ "\trules described above.\n"
|
|
|
+ "\n"
|
|
|
);
|
|
|
|
|
|
static cl::OptionCategory AnnotatorCategory("Annotator options");
|
|
|
static std::unique_ptr<opt::OptTable> Options(createDriverOptTable());
|
|
|
-static cl::opt<bool> ASTDump("ast-dump", cl::desc(Options->getOptionHelpText(options::OPT_ast_dump)), cl::cat(AnnotatorCategory));
|
|
|
-static cl::opt<std::string> ASTDumpFilter
|
|
|
- ("ast-dump-filter", cl::desc(Options->getOptionHelpText(options::OPT_ast_dump_filter)), cl::cat(AnnotatorCategory));
|
|
|
+static cl::opt<std::string> BindingsFile
|
|
|
+ ("b", cl::desc("Bindings file in JSON format (output of ScriptBindingExtractor tool)"), cl::cat(AnnotatorCategory));
|
|
|
|
|
|
-class AnnotatorActionFactory
|
|
|
+class AnnotateFrontendAction : public ASTFrontendAction
|
|
|
{
|
|
|
-public:
|
|
|
- std::unique_ptr<clang::ASTConsumer> newASTConsumer()
|
|
|
+protected:
|
|
|
+ virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance& CI, StringRef InFile)
|
|
|
{
|
|
|
- if (ASTDump)
|
|
|
- return clang::CreateASTDumper(ASTDumpFilter, /*DumpDecls=*/true, /*DumpLookups=*/false);
|
|
|
- return llvm::make_unique<clang::ASTConsumer>();
|
|
|
+ return make_unique<ASTConsumer>();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
int main(int argc, const char** argv)
|
|
|
{
|
|
|
- llvm::sys::PrintStackTraceOnErrorSignal();
|
|
|
CommonOptionsParser OptionsParser(argc, argv, AnnotatorCategory);
|
|
|
ClangTool Tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList());
|
|
|
- AnnotatorActionFactory annotatorFactory;
|
|
|
- return Tool.run(newFrontendActionFactory(&annotatorFactory).get());
|
|
|
+ return Tool.run(newFrontendActionFactory<AnnotateFrontendAction>().get());
|
|
|
}
|