diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -10362,14 +10362,14 @@ // Provide a white-list of attributes that are allowed to be combined with // multiversion functions. static bool AttrCompatibleWithMultiVersion(attr::Kind Kind, - MultiVersionKind MVType) { + MultiVersionKind MVKind) { // Note: this list/diagnosis must match the list in // checkMultiversionAttributesAllSame. switch (Kind) { default: return false; case attr::Used: - return MVType == MultiVersionKind::Target; + return MVKind == MultiVersionKind::Target; case attr::NonNull: case attr::NoThrow: return true; @@ -10379,10 +10379,10 @@ static bool checkNonMultiVersionCompatAttributes(Sema &S, const FunctionDecl *FD, const FunctionDecl *CausedFD, - MultiVersionKind MVType) { - const auto Diagnose = [FD, CausedFD, MVType](Sema &S, const Attr *A) { + MultiVersionKind MVKind) { + const auto Diagnose = [FD, CausedFD, MVKind](Sema &S, const Attr *A) { S.Diag(FD->getLocation(), diag::err_multiversion_disallowed_other_attr) - << static_cast(MVType) << A; + << static_cast(MVKind) << A; if (CausedFD) S.Diag(CausedFD->getLocation(), diag::note_multiversioning_caused_here); return true; @@ -10392,20 +10392,20 @@ switch (A->getKind()) { case attr::CPUDispatch: case attr::CPUSpecific: - if (MVType != MultiVersionKind::CPUDispatch && - MVType != MultiVersionKind::CPUSpecific) + if (MVKind != MultiVersionKind::CPUDispatch && + MVKind != MultiVersionKind::CPUSpecific) return Diagnose(S, A); break; case attr::Target: - if (MVType != MultiVersionKind::Target) + if (MVKind != MultiVersionKind::Target) return Diagnose(S, A); break; case attr::TargetClones: - if (MVType != MultiVersionKind::TargetClones) + if (MVKind != MultiVersionKind::TargetClones) return Diagnose(S, A); break; default: - if (!AttrCompatibleWithMultiVersion(A->getKind(), MVType)) + if (!AttrCompatibleWithMultiVersion(A->getKind(), MVKind)) return Diagnose(S, A); break; } @@ -10529,7 +10529,7 @@ static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD, const FunctionDecl *NewFD, bool CausesMV, - MultiVersionKind MVType) { + MultiVersionKind MVKind) { if (!S.getASTContext().getTargetInfo().supportsMultiVersioning()) { S.Diag(NewFD->getLocation(), diag::err_multiversion_not_supported); if (OldFD) @@ -10537,15 +10537,15 @@ return true; } - bool IsCPUSpecificCPUDispatchMVType = - MVType == MultiVersionKind::CPUDispatch || - MVType == MultiVersionKind::CPUSpecific; + bool IsCPUSpecificCPUDispatchMVKind = + MVKind == MultiVersionKind::CPUDispatch || + MVKind == MultiVersionKind::CPUSpecific; if (CausesMV && OldFD && - checkNonMultiVersionCompatAttributes(S, OldFD, NewFD, MVType)) + checkNonMultiVersionCompatAttributes(S, OldFD, NewFD, MVKind)) return true; - if (checkNonMultiVersionCompatAttributes(S, NewFD, nullptr, MVType)) + if (checkNonMultiVersionCompatAttributes(S, NewFD, nullptr, MVKind)) return true; // Only allow transition to MultiVersion if it hasn't been used. @@ -10558,11 +10558,11 @@ S.PDiag(diag::note_multiversioning_caused_here)), PartialDiagnosticAt(NewFD->getLocation(), S.PDiag(diag::err_multiversion_doesnt_support) - << static_cast(MVType)), + << static_cast(MVKind)), PartialDiagnosticAt(NewFD->getLocation(), S.PDiag(diag::err_multiversion_diff)), /*TemplatesSupported=*/false, - /*ConstexprSupported=*/!IsCPUSpecificCPUDispatchMVType, + /*ConstexprSupported=*/!IsCPUSpecificCPUDispatchMVKind, /*CLinkageMayDiffer=*/false); } @@ -10573,22 +10573,22 @@ /// /// Returns true if there was an error, false otherwise. static bool CheckMultiVersionFirstFunction(Sema &S, FunctionDecl *FD, - MultiVersionKind MVType, + MultiVersionKind MVKind, const TargetAttr *TA) { - assert(MVType != MultiVersionKind::None && + assert(MVKind != MultiVersionKind::None && "Function lacks multiversion attribute"); // Target only causes MV if it is default, otherwise this is a normal // function. - if (MVType == MultiVersionKind::Target && !TA->isDefaultVersion()) + if (MVKind == MultiVersionKind::Target && !TA->isDefaultVersion()) return false; - if (MVType == MultiVersionKind::Target && CheckMultiVersionValue(S, FD)) { + if (MVKind == MultiVersionKind::Target && CheckMultiVersionValue(S, FD)) { FD->setInvalidDecl(); return true; } - if (CheckMultiVersionAdditionalRules(S, nullptr, FD, true, MVType)) { + if (CheckMultiVersionAdditionalRules(S, nullptr, FD, true, MVKind)) { FD->setInvalidDecl(); return true; } @@ -10694,14 +10694,14 @@ /// multiversioned declaration collection. static bool CheckMultiVersionAdditionalDecl( Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, - MultiVersionKind NewMVType, const TargetAttr *NewTA, + MultiVersionKind NewMVKind, const TargetAttr *NewTA, const CPUDispatchAttr *NewCPUDisp, const CPUSpecificAttr *NewCPUSpec, const TargetClonesAttr *NewClones, bool &Redeclaration, NamedDecl *&OldDecl, LookupResult &Previous) { - MultiVersionKind OldMVType = OldFD->getMultiVersionKind(); + MultiVersionKind OldMVKind = OldFD->getMultiVersionKind(); // Disallow mixing of multiversioning types. - if (!MultiVersionTypesCompatible(OldMVType, NewMVType)) { + if (!MultiVersionTypesCompatible(OldMVKind, NewMVKind)) { S.Diag(NewFD->getLocation(), diag::err_multiversion_types_mixed); S.Diag(OldFD->getLocation(), diag::note_previous_declaration); NewFD->setInvalidDecl(); @@ -10730,9 +10730,9 @@ S.IsOverload(NewFD, CurFD, UseMemberUsingDeclRules)) continue; - switch (NewMVType) { + switch (NewMVKind) { case MultiVersionKind::None: - assert(OldMVType == MultiVersionKind::TargetClones && + assert(OldMVKind == MultiVersionKind::TargetClones && "Only target_clones can be omitted in subsequent declarations"); break; case MultiVersionKind::Target: { @@ -10779,7 +10779,7 @@ // Handle CPUDispatch/CPUSpecific versions. // Only 1 CPUDispatch function is allowed, this will make it go through // the redeclaration errors. - if (NewMVType == MultiVersionKind::CPUDispatch && + if (NewMVKind == MultiVersionKind::CPUDispatch && CurFD->hasAttr()) { if (CurCPUDisp->cpus_size() == NewCPUDisp->cpus_size() && std::equal( @@ -10800,8 +10800,7 @@ NewFD->setInvalidDecl(); return true; } - if (NewMVType == MultiVersionKind::CPUSpecific && CurCPUSpec) { - + if (NewMVKind == MultiVersionKind::CPUSpecific && CurCPUSpec) { if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() && std::equal( CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(), @@ -10836,14 +10835,14 @@ // Else, this is simply a non-redecl case. Checking the 'value' is only // necessary in the Target case, since The CPUSpecific/Dispatch cases are // handled in the attribute adding step. - if (NewMVType == MultiVersionKind::Target && + if (NewMVKind == MultiVersionKind::Target && CheckMultiVersionValue(S, NewFD)) { NewFD->setInvalidDecl(); return true; } if (CheckMultiVersionAdditionalRules(S, OldFD, NewFD, - !OldFD->isMultiVersion(), NewMVType)) { + !OldFD->isMultiVersion(), NewMVKind)) { NewFD->setInvalidDecl(); return true; } @@ -10877,13 +10876,13 @@ const auto *NewCPUDisp = NewFD->getAttr(); const auto *NewCPUSpec = NewFD->getAttr(); const auto *NewClones = NewFD->getAttr(); - MultiVersionKind MVType = NewFD->getMultiVersionKind(); + MultiVersionKind MVKind = NewFD->getMultiVersionKind(); // Main isn't allowed to become a multiversion function, however it IS // permitted to have 'main' be marked with the 'target' optimization hint. if (NewFD->isMain()) { - if (MVType != MultiVersionKind::None && - !(MVType == MultiVersionKind::Target && !NewTA->isDefaultVersion())) { + if (MVKind != MultiVersionKind::None && + !(MVKind == MultiVersionKind::Target && !NewTA->isDefaultVersion())) { S.Diag(NewFD->getLocation(), diag::err_multiversion_not_allowed_on_main); NewFD->setInvalidDecl(); return true; @@ -10896,19 +10895,19 @@ NewFD->getDeclContext()->getRedeclContext()) { // If there's no previous declaration, AND this isn't attempting to cause // multiversioning, this isn't an error condition. - if (MVType == MultiVersionKind::None) + if (MVKind == MultiVersionKind::None) return false; - return CheckMultiVersionFirstFunction(S, NewFD, MVType, NewTA); + return CheckMultiVersionFirstFunction(S, NewFD, MVKind, NewTA); } FunctionDecl *OldFD = OldDecl->getAsFunction(); - if (!OldFD->isMultiVersion() && MVType == MultiVersionKind::None) + if (!OldFD->isMultiVersion() && MVKind == MultiVersionKind::None) return false; // Multiversioned redeclarations aren't allowed to omit the attribute, except // for target_clones. - if (OldFD->isMultiVersion() && MVType == MultiVersionKind::None && + if (OldFD->isMultiVersion() && MVKind == MultiVersionKind::None && OldFD->getMultiVersionKind() != MultiVersionKind::TargetClones) { S.Diag(NewFD->getLocation(), diag::err_multiversion_required_in_redecl) << (OldFD->getMultiVersionKind() != MultiVersionKind::Target); @@ -10917,7 +10916,7 @@ } if (!OldFD->isMultiVersion()) { - switch (MVType) { + switch (MVKind) { case MultiVersionKind::Target: return CheckTargetCausesMultiVersioning(S, OldFD, NewFD, NewTA, Redeclaration, OldDecl, Previous); @@ -10938,7 +10937,7 @@ // At this point, we have a multiversion function decl (in OldFD) AND an // appropriate attribute in the current function decl. Resolve that these are // still compatible with previous declarations. - return CheckMultiVersionAdditionalDecl(S, OldFD, NewFD, MVType, NewTA, + return CheckMultiVersionAdditionalDecl(S, OldFD, NewFD, MVKind, NewTA, NewCPUDisp, NewCPUSpec, NewClones, Redeclaration, OldDecl, Previous); }