]> granicus.if.org Git - clang/commitdiff
Simplify. NFC.
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 6 Apr 2017 00:08:35 +0000 (00:08 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 6 Apr 2017 00:08:35 +0000 (00:08 +0000)
Two simplifications:
- We check `!Previous.empty()` above and only use `Previous` in const
  contexts after that check, so the `!Previous.empty()` check seems
  redundant.
- The null check looks pointless, as well: AFAICT, `LookupResults`
  should never contain null entries, and `OldDecl` should always be
  non-null if `Redeclaration` is true.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299601 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp

index c0a1015840531ff846df6e9fc9efb4affa29bc72..02cbca8b2bbbac0b329398eae40e773237791e5e 100644 (file)
@@ -9038,14 +9038,10 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
         // with that name must be marked "overloadable".
         Diag(NewFD->getLocation(), diag::err_attribute_overloadable_missing)
           << Redeclaration << NewFD;
-        NamedDecl *OverloadedDecl = nullptr;
-        if (Redeclaration)
-          OverloadedDecl = OldDecl;
-        else if (!Previous.empty())
-          OverloadedDecl = Previous.getRepresentativeDecl();
-        if (OverloadedDecl)
-          Diag(OverloadedDecl->getLocation(),
-               diag::note_attribute_overloadable_prev_overload);
+        NamedDecl *OverloadedDecl =
+            Redeclaration ? OldDecl : Previous.getRepresentativeDecl();
+        Diag(OverloadedDecl->getLocation(),
+             diag::note_attribute_overloadable_prev_overload);
         NewFD->addAttr(OverloadableAttr::CreateImplicit(Context));
       }
     }