Commit 2500961f authored by thakis@chromium.org's avatar thakis@chromium.org

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
parent ec5f4330
......@@ -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) {
......
......@@ -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_
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment