Skip to content

Commit

Permalink
[Sema] CheckObjCBridgeNSCast - fix dead code warning. NFCI.
Browse files Browse the repository at this point in the history
Target is only ever non-null when we find an existing type, so move its declaration inside that case, and remove the dead code where Target was always null.
  • Loading branch information
RKSimon committed Aug 18, 2021
1 parent 26da53f commit f22e586
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions clang/lib/Sema/SemaExprObjC.cpp
Expand Up @@ -4015,12 +4015,11 @@ static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr,
if (Parm->isStr("id"))
return true;

NamedDecl *Target = nullptr;
// Check for an existing type with this name.
LookupResult R(S, DeclarationName(Parm), SourceLocation(),
Sema::LookupOrdinaryName);
if (S.LookupName(R, S.TUScope)) {
Target = R.getFoundDecl();
NamedDecl *Target = R.getFoundDecl();
if (Target && isa<ObjCInterfaceDecl>(Target)) {
ObjCInterfaceDecl *ExprClass = cast<ObjCInterfaceDecl>(Target);
if (const ObjCObjectPointerType *InterfacePointerType =
Expand Down Expand Up @@ -4056,8 +4055,6 @@ static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr,
diag::err_objc_cf_bridged_not_interface)
<< castExpr->getType() << Parm;
S.Diag(TDNDecl->getBeginLoc(), diag::note_declared_at);
if (Target)
S.Diag(Target->getBeginLoc(), diag::note_declared_at);
}
return true;
}
Expand Down

0 comments on commit f22e586

Please sign in to comment.