From: George Burgess IV Date: Thu, 6 Apr 2017 00:08:35 +0000 (+0000) Subject: Simplify. NFC. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3934d96fb96e1bdd74be98297550b9d1fe7213d2;p=clang Simplify. NFC. 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 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index c0a1015840..02cbca8b2b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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)); } }