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

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

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months 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/FindBadConstructsAction.cpp ('k') | tools/clang/plugins/Options.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/plugins/FindBadConstructsConsumer.cpp
diff --git a/tools/clang/plugins/FindBadConstructsConsumer.cpp b/tools/clang/plugins/FindBadConstructsConsumer.cpp
index fe868c01de6cab10389a46321e50f0f328bd0e0a..46e1df851b5358c2b31e1da669c8eaf0fec60314 100644
--- a/tools/clang/plugins/FindBadConstructsConsumer.cpp
+++ b/tools/clang/plugins/FindBadConstructsConsumer.cpp
@@ -283,9 +283,6 @@ void FindBadConstructsConsumer::CheckCtorDtorWeight(
for (CXXRecordDecl::ctor_iterator it = record->ctor_begin();
it != record->ctor_end();
++it) {
- // The current check is buggy. An implicit copy constructor does not
- // have an inline body, so this check never fires for classes with a
- // user-declared out-of-line constructor.
if (it->hasInlineBody()) {
if (it->isCopyConstructor() &&
!record->hasUserDeclaredCopyConstructor()) {
@@ -296,15 +293,6 @@ void FindBadConstructsConsumer::CheckCtorDtorWeight(
emitWarning(it->getInnerLocStart(),
"Complex constructor has an inlined body.");
}
- } else if (it->isInlined() && (!it->isCopyOrMoveConstructor() ||
- it->isExplicitlyDefaulted())) {
- // isInlined() is a more reliable check than hasInlineBody(), but
- // unfortunately, it results in warnings for implicit copy/move
- // constructors in the previously mentioned situation. To preserve
- // compatibility with existing Chromium code, only warn if it's an
- // explicitly defaulted copy or move constructor.
- emitWarning(it->getInnerLocStart(),
- "Complex constructor has an inlined body.");
}
}
}
@@ -318,7 +306,7 @@ void FindBadConstructsConsumer::CheckCtorDtorWeight(
"Complex class/struct needs an explicit out-of-line "
"destructor.");
} else if (CXXDestructorDecl* dtor = record->getDestructor()) {
- if (dtor->isInlined()) {
+ if (dtor->hasInlineBody()) {
emitWarning(dtor->getInnerLocStart(),
"Complex destructor has an inline body.");
}
@@ -343,7 +331,8 @@ bool FindBadConstructsConsumer::IsMethodInBannedOrTestingNamespace(
// magic to try to make sure SetUp()/TearDown() aren't capitalized
// incorrectly, but having the plugin enforce override is also nice.
(InTestingNamespace(overridden) &&
- !IsGtestTestFixture(overridden->getParent()))) {
+ (!options_.strict_virtual_specifiers ||
+ !IsGtestTestFixture(overridden->getParent())))) {
return true;
}
}
@@ -404,13 +393,20 @@ void FindBadConstructsConsumer::CheckVirtualSpecifiers(
OverrideAttr* override_attr = method->getAttr<OverrideAttr>();
FinalAttr* final_attr = method->getAttr<FinalAttr>();
+ if (method->isPure() && !options_.strict_virtual_specifiers)
+ return;
+
if (IsMethodInBannedOrTestingNamespace(method))
return;
+ if (isa<CXXDestructorDecl>(method) && !options_.strict_virtual_specifiers)
+ return;
+
SourceManager& manager = instance().getSourceManager();
// Complain if a method is annotated virtual && (override || final).
- if (has_virtual && (override_attr || final_attr)) {
+ if (has_virtual && (override_attr || final_attr) &&
+ options_.strict_virtual_specifiers) {
diagnostic().Report(method->getLocStart(),
diag_redundant_virtual_specifier_)
<< "'virtual'"
@@ -440,14 +436,14 @@ void FindBadConstructsConsumer::CheckVirtualSpecifiers(
}
}
- if (final_attr && override_attr) {
+ if (final_attr && override_attr && options_.strict_virtual_specifiers) {
diagnostic().Report(override_attr->getLocation(),
diag_redundant_virtual_specifier_)
<< override_attr << final_attr
<< FixItHint::CreateRemoval(override_attr->getRange());
}
- if (final_attr && !is_override) {
+ if (final_attr && !is_override && options_.strict_virtual_specifiers) {
diagnostic().Report(method->getLocStart(),
diag_base_method_virtual_and_final_)
<< FixItRemovalForVirtual(manager, method)
« no previous file with comments | « tools/clang/plugins/FindBadConstructsAction.cpp ('k') | tools/clang/plugins/Options.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698