Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: tools/clang/plugins/FindBadConstructsAction.cpp

Issue 751233002: Switch the Clang plugin to use RecursiveASTVisitor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/clang/plugins/ChromeClassTester.h ('k') | tools/clang/plugins/FindBadConstructsConsumer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/plugins/FindBadConstructsAction.cpp
diff --git a/tools/clang/plugins/FindBadConstructsAction.cpp b/tools/clang/plugins/FindBadConstructsAction.cpp
index ddaf41914455bd2e3ca38edff555c22449275d4e..7563c21078525c0772aeee523e451c7d3d7bdb38 100644
--- a/tools/clang/plugins/FindBadConstructsAction.cpp
+++ b/tools/clang/plugins/FindBadConstructsAction.cpp
@@ -4,6 +4,7 @@
#include "FindBadConstructsAction.h"
+#include "clang/AST/ASTConsumer.h"
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "FindBadConstructsConsumer.h"
@@ -12,12 +13,31 @@ using namespace clang;
namespace chrome_checker {
+namespace {
+
+class PluginConsumer : public ASTConsumer {
+ public:
+ PluginConsumer(CompilerInstance* instance, const Options& options)
+ : visitor_(*instance, options) {}
+
+ void HandleTranslationUnit(clang::ASTContext& context) override {
+ visitor_.TraverseDecl(context.getTranslationUnitDecl());
+ }
+
+ private:
+ FindBadConstructsConsumer visitor_;
+};
+
+} // namespace
+
FindBadConstructsAction::FindBadConstructsAction() {
}
std::unique_ptr<ASTConsumer> FindBadConstructsAction::CreateASTConsumer(
CompilerInstance& instance,
llvm::StringRef ref) {
+ if (options_.with_ast_visitor)
+ return llvm::make_unique<PluginConsumer>(&instance, options_);
return llvm::make_unique<FindBadConstructsConsumer>(instance, options_);
}
@@ -38,6 +58,8 @@ bool FindBadConstructsAction::ParseArgs(const CompilerInstance& instance,
options_.check_enum_last_value = true;
} else if (args[i] == "strict-virtual-specifiers") {
options_.strict_virtual_specifiers = true;
+ } else if (args[i] == "with-ast-visitor") {
+ options_.with_ast_visitor = true;
} else {
parsed = false;
llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n";
« no previous file with comments | « tools/clang/plugins/ChromeClassTester.h ('k') | tools/clang/plugins/FindBadConstructsConsumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698