diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index a155bb2fd3ba2a..0c1e054f7c30a4 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -6567,29 +6567,22 @@ static void collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType, UnresolvedSetImpl &ViableConversions, OverloadCandidateSet &CandidateSet) { - for (unsigned I = 0, N = ViableConversions.size(); I != N; ++I) { - DeclAccessPair FoundDecl = ViableConversions[I]; + for (const DeclAccessPair &FoundDecl : ViableConversions.pairs()) { NamedDecl *D = FoundDecl.getDecl(); CXXRecordDecl *ActingContext = cast(D->getDeclContext()); if (isa(D)) D = cast(D)->getTargetDecl(); - CXXConversionDecl *Conv; - FunctionTemplateDecl *ConvTemplate; - if ((ConvTemplate = dyn_cast(D))) - Conv = cast(ConvTemplate->getTemplatedDecl()); - else - Conv = cast(D); - - if (ConvTemplate) + if (auto *ConvTemplate = dyn_cast(D)) { SemaRef.AddTemplateConversionCandidate( ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet, - /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit*/ true); - else - SemaRef.AddConversionCandidate(Conv, FoundDecl, ActingContext, From, - ToType, CandidateSet, - /*AllowObjCConversionOnExplicit=*/false, - /*AllowExplicit*/ true); + /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit=*/true); + continue; + } + CXXConversionDecl *Conv = cast(D); + SemaRef.AddConversionCandidate( + Conv, FoundDecl, ActingContext, From, ToType, CandidateSet, + /*AllowObjCConversionOnExplicit=*/false, /*AllowExplicit=*/true); } }