================ @@ -1056,4 +1056,62 @@ void SemaX86::handleForceAlignArgPointerAttr(Decl *D, const ParsedAttr &AL) { X86ForceAlignArgPointerAttr(getASTContext(), AL)); } +enum FirstParam { Unsupported, Duplicate, Unknown }; +enum SecondParam { None, CPU, Tune }; +enum ThirdParam { Target, TargetClones, TargetVersion }; + +bool SemaX86::checkTargetClonesAttr(SmallVectorImpl<StringRef> &Strs, + SmallVectorImpl<SourceLocation> &Locs, + SmallVectorImpl<SmallString<64>> &Buffer) { + assert(Strs.size() == Locs.size() && + "Mismatch between number of strings and locations"); + + bool HasDefault = false; + bool HasComma = false; + for (unsigned I = 0; I < Strs.size(); ++I) { + StringRef Str = Strs[I].trim(); + SourceLocation Loc = Locs[I]; + + if (Str.empty() || Str.ends_with(',')) + return Diag(Loc, diag::warn_unsupported_target_attribute) + << Unsupported << None << "" << TargetClones; + + if (Str.contains(',')) + HasComma = true; + + StringRef LHS; + StringRef RHS = Str; + do { + std::tie(LHS, RHS) = RHS.split(','); + LHS = LHS.trim(); + SourceLocation CurLoc = Loc.getLocWithOffset(LHS.data() - Str.data()); + + if (LHS.starts_with("arch=")) { + if (!getASTContext().getTargetInfo().isValidCPUName( + LHS.drop_front(sizeof("arch=") - 1))) + return Diag(CurLoc, diag::warn_unsupported_target_attribute) + << Unsupported << CPU << LHS.drop_front(sizeof("arch=") - 1) + << TargetClones; + } else if (LHS == "default") + HasDefault = true; + else if (!getASTContext().getTargetInfo().isValidFeatureName(LHS) || + getASTContext().getTargetInfo().getFMVPriority(LHS) == 0) + return Diag(CurLoc, diag::warn_unsupported_target_attribute) + << Unsupported << None << LHS << TargetClones; + + if (llvm::is_contained(Buffer, LHS)) ---------------- labrinea wrote:
because `llvm::is_contained(Buffer, LHS)` accounts for that https://github.com/llvm/llvm-project/pull/149067 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits