[clang-tidy] Replace redundant checks with an assert().
authorArtem Belevich <tra@google.com>
Tue, 18 Sep 2018 21:51:02 +0000 (21:51 +0000)
committerArtem Belevich <tra@google.com>
Tue, 18 Sep 2018 21:51:02 +0000 (21:51 +0000)
findStyleKind is only called if D is an explicit identifier with a name,
so the checks for operators will never return true. The explicit assert()
enforces this invariant.

Differential Revision: https://reviews.llvm.org/D52179

llvm-svn: 342514

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

index 90c34b3..e34fcbb 100644 (file)
@@ -385,6 +385,9 @@ static StyleKind findStyleKind(
     const NamedDecl *D,
     const std::vector<llvm::Optional<IdentifierNamingCheck::NamingStyle>>
         &NamingStyles) {
+  assert(D && D->getIdentifier() && !D->getName().empty() && !D->isImplicit() &&
+         "Decl must be an explicit identifier with a name.");
+
   if (isa<ObjCIvarDecl>(D) && NamingStyles[SK_ObjcIvar])
     return SK_ObjcIvar;
   
@@ -548,8 +551,6 @@ static StyleKind findStyleKind(
 
   if (const auto *Decl = dyn_cast<CXXMethodDecl>(D)) {
     if (Decl->isMain() || !Decl->isUserProvided() ||
-        Decl->isUsualDeallocationFunction() ||
-        Decl->isCopyAssignmentOperator() || Decl->isMoveAssignmentOperator() ||
         Decl->size_overridden_methods() > 0)
       return SK_Invalid;