diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 21:24:38 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 21:24:38 +0000 |
commit | 2500961f4fdfc570c0b51f027547a734d03c6bd3 (patch) | |
tree | 79d20b9521489087e44545b30c399dfe5df5b728 | |
parent | ec5f43302420c25042beb2b7b1d2ee2f67470885 (diff) | |
download | chromium_src-2500961f4fdfc570c0b51f027547a734d03c6bd3.zip chromium_src-2500961f4fdfc570c0b51f027547a734d03c6bd3.tar.gz chromium_src-2500961f4fdfc570c0b51f027547a734d03c6bd3.tar.bz2 |
clang plugin: Put inner classes bugfix behind a flag.
A follow-up to https://chromiumcodereview.appspot.com/10808078
This way, cleaning up existing style issues in inner classes doesn't
have to block a clang roll.
BUG=139346
Review URL: https://chromiumcodereview.appspot.com/10828057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148814 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | tools/clang/plugins/ChromeClassTester.cpp | 16 | ||||
-rw-r--r-- | tools/clang/plugins/ChromeClassTester.h | 6 | ||||
-rw-r--r-- | tools/clang/plugins/FindBadConstructs.cpp | 14 | ||||
-rwxr-xr-x | tools/clang/plugins/tests/test.sh | 2 |
4 files changed, 28 insertions, 10 deletions
diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp index 8280799..c61271b 100644 --- a/tools/clang/plugins/ChromeClassTester.cpp +++ b/tools/clang/plugins/ChromeClassTester.cpp @@ -36,18 +36,24 @@ bool ends_with(const std::string& one, const std::string& two) { } // namespace -ChromeClassTester::ChromeClassTester(CompilerInstance& instance) +ChromeClassTester::ChromeClassTester(CompilerInstance& instance, + bool check_inner_classes) : instance_(instance), - diagnostic_(instance.getDiagnostics()) { + diagnostic_(instance.getDiagnostics()), + check_inner_classes_(check_inner_classes) { BuildBannedLists(); } ChromeClassTester::~ChromeClassTester() {} void ChromeClassTester::HandleTagDeclDefinition(TagDecl* tag) { - // Defer processing of this tag until its containing top-level - // declaration has been fully parsed. See crbug.com/136863. - pending_class_decls_.push_back(tag); + if (check_inner_classes_) { + // Defer processing of this tag until its containing top-level + // declaration has been fully parsed. See crbug.com/136863. + pending_class_decls_.push_back(tag); + } else { + CheckTag(tag); + } } bool ChromeClassTester::HandleTopLevelDecl(DeclGroupRef group_ref) { diff --git a/tools/clang/plugins/ChromeClassTester.h b/tools/clang/plugins/ChromeClassTester.h index 588ae9c..fe11fcd 100644 --- a/tools/clang/plugins/ChromeClassTester.h +++ b/tools/clang/plugins/ChromeClassTester.h @@ -16,7 +16,8 @@ // headers to subclasses which implement CheckChromeClass(). class ChromeClassTester : public clang::ASTConsumer { public: - explicit ChromeClassTester(clang::CompilerInstance& instance); + explicit ChromeClassTester(clang::CompilerInstance& instance, + bool check_inner_classes); virtual ~ChromeClassTester(); // clang::ASTConsumer: @@ -79,6 +80,9 @@ class ChromeClassTester : public clang::ASTConsumer { // List of decls to check once the current top-level decl is parsed. std::vector<clang::TagDecl*> pending_class_decls_; + + // TODO: Remove once all inner classes are cleaned up. + bool check_inner_classes_; }; #endif // TOOLS_CLANG_PLUGINS_CHROMECLASSTESTER_H_ diff --git a/tools/clang/plugins/FindBadConstructs.cpp b/tools/clang/plugins/FindBadConstructs.cpp index b79a64d..b9e1f5b 100644 --- a/tools/clang/plugins/FindBadConstructs.cpp +++ b/tools/clang/plugins/FindBadConstructs.cpp @@ -50,8 +50,9 @@ class FindBadConstructsConsumer : public ChromeClassTester { public: FindBadConstructsConsumer(CompilerInstance& instance, bool check_refcounted_dtors, - bool check_virtuals_in_implementations) - : ChromeClassTester(instance), + bool check_virtuals_in_implementations, + bool check_inner_classes) + : ChromeClassTester(instance, check_inner_classes), check_refcounted_dtors_(check_refcounted_dtors), check_virtuals_in_implementations_(check_virtuals_in_implementations) { } @@ -395,7 +396,8 @@ class FindBadConstructsAction : public PluginASTAction { public: FindBadConstructsAction() : check_refcounted_dtors_(true), - check_virtuals_in_implementations_(true) { + check_virtuals_in_implementations_(true), + check_inner_classes_(false) { } protected: @@ -403,7 +405,8 @@ class FindBadConstructsAction : public PluginASTAction { virtual ASTConsumer* CreateASTConsumer(CompilerInstance& instance, llvm::StringRef ref) { return new FindBadConstructsConsumer( - instance, check_refcounted_dtors_, check_virtuals_in_implementations_); + instance, check_refcounted_dtors_, check_virtuals_in_implementations_, + check_inner_classes_); } virtual bool ParseArgs(const CompilerInstance& instance, @@ -415,6 +418,8 @@ class FindBadConstructsAction : public PluginASTAction { check_refcounted_dtors_ = false; } else if (args[i] == "skip-virtuals-in-implementations") { check_virtuals_in_implementations_ = false; + } else if (args[i] == "check-inner-classes") { + check_inner_classes_ = true; } else { parsed = false; llvm::errs() << "Unknown argument: " << args[i] << "\n"; @@ -427,6 +432,7 @@ class FindBadConstructsAction : public PluginASTAction { private: bool check_refcounted_dtors_; bool check_virtuals_in_implementations_; + bool check_inner_classes_; }; } // namespace diff --git a/tools/clang/plugins/tests/test.sh b/tools/clang/plugins/tests/test.sh index 262ebbb..eec23dd 100755 --- a/tools/clang/plugins/tests/test.sh +++ b/tools/clang/plugins/tests/test.sh @@ -25,6 +25,8 @@ usage() { do_testcase() { local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \ -Xclang -load -Xclang "${CLANG_DIR}"/lib/libFindBadConstructs.${LIB} \ + -Xclang -plugin-arg-find-bad-constructs \ + -Xclang check-inner-classes \ -Xclang -plugin -Xclang find-bad-constructs ${1} 2>&1)" local diffout="$(echo "${output}" | diff - "${2}")" if [ "${diffout}" = "" ]; then |