@@ -103,6 +103,9 @@ def NonParmVar : SubsetSubject<Var,
103103def NonLocalVar : SubsetSubject<Var,
104104 [{!S->hasLocalStorage()}],
105105 "variables with non-local storage">;
106+ def VarTmpl : SubsetSubject<Var, [{S->getDescribedVarTemplate()}],
107+ "variable templates">;
108+
106109def NonBitField : SubsetSubject<Field,
107110 [{!S->isBitField()}],
108111 "non-bit-field non-static data members">;
@@ -3260,33 +3263,28 @@ def Target : InheritableAttr {
32603263 let Subjects = SubjectList<[Function], ErrorDiag>;
32613264 let Documentation = [TargetDocs];
32623265 let AdditionalMembers = [{
3263- StringRef getArchitecture () const {
3266+ std::optional< StringRef> getX86Architecture () const {
32643267 StringRef Features = getFeaturesStr();
3265- if (Features == "default") return {};
3266-
3267- SmallVector<StringRef, 1> AttrFeatures;
3268- Features.split(AttrFeatures, ",");
3269-
3270- for (auto &Feature : AttrFeatures) {
3268+ SmallVector<StringRef, 4> AttrFeatures;
3269+ Features.split(AttrFeatures, ',');
3270+ for (StringRef Feature : AttrFeatures) {
32713271 Feature = Feature.trim();
32723272 if (Feature.starts_with("arch="))
32733273 return Feature.drop_front(sizeof("arch=") - 1);
32743274 }
3275- return "" ;
3275+ return std::nullopt ;
32763276 }
32773277
32783278 // Gets the list of features as simple string-refs with no +/- or 'no-'.
32793279 // Only adds the items to 'Out' that are additions.
3280- void getAddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
3280+ void getX86AddedFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
3281+ if (isDefaultVersion())
3282+ return;
32813283 StringRef Features = getFeaturesStr();
3282- if (Features == "default") return;
3283-
3284- SmallVector<StringRef, 1> AttrFeatures;
3285- Features.split(AttrFeatures, ",");
3286-
3284+ SmallVector<StringRef, 4> AttrFeatures;
3285+ Features.split(AttrFeatures, ',');
32873286 for (auto &Feature : AttrFeatures) {
32883287 Feature = Feature.trim();
3289-
32903288 if (!Feature.starts_with("no-") && !Feature.starts_with("arch=") &&
32913289 !Feature.starts_with("fpmath=") && !Feature.starts_with("tune="))
32923290 Out.push_back(Feature);
@@ -3304,17 +3302,17 @@ def TargetVersion : InheritableAttr, TargetSpecificAttr<TargetArch<!listconcat(T
33043302 let Documentation = [TargetVersionDocs];
33053303 let AdditionalMembers = [{
33063304 StringRef getName() const { return getNamesStr().trim(); }
3307- bool isDefaultVersion() const {
3308- return getName() == "default";
3309- }
3310- void getFeatures(llvm::SmallVectorImpl<StringRef> &Out) const {
3311- if (isDefaultVersion()) return;
3312- StringRef Features = getName();
33133305
3314- SmallVector<StringRef, 8> AttrFeatures;
3315- Features.split(AttrFeatures, "+");
3306+ bool isDefaultVersion() const { return getName() == "default"; }
33163307
3317- for (auto &Feature : AttrFeatures) {
3308+ void getFeatures(llvm::SmallVectorImpl<StringRef> &Out,
3309+ char Delim = '+') const {
3310+ if (isDefaultVersion())
3311+ return;
3312+ StringRef Features = getName();
3313+ SmallVector<StringRef, 4> AttrFeatures;
3314+ Features.split(AttrFeatures, Delim);
3315+ for (StringRef Feature : AttrFeatures) {
33183316 Feature = Feature.trim();
33193317 Out.push_back(Feature);
33203318 }
@@ -3331,20 +3329,40 @@ def TargetClones : InheritableAttr {
33313329 StringRef getFeatureStr(unsigned Index) const {
33323330 return *(featuresStrs_begin() + Index);
33333331 }
3332+
33343333 bool isDefaultVersion(unsigned Index) const {
33353334 return getFeatureStr(Index) == "default";
33363335 }
3336+
33373337 void getFeatures(llvm::SmallVectorImpl<StringRef> &Out,
3338- unsigned Index) const {
3339- if (isDefaultVersion(Index)) return;
3338+ unsigned Index, char Delim = '+') const {
3339+ if (isDefaultVersion(Index))
3340+ return;
33403341 StringRef Features = getFeatureStr(Index);
3341- SmallVector<StringRef, 8 > AttrFeatures;
3342- Features.split(AttrFeatures, "+" );
3343- for (auto & Feature : AttrFeatures) {
3342+ SmallVector<StringRef, 4 > AttrFeatures;
3343+ Features.split(AttrFeatures, Delim );
3344+ for (StringRef Feature : AttrFeatures) {
33443345 Feature = Feature.trim();
33453346 Out.push_back(Feature);
33463347 }
33473348 }
3349+
3350+ std::optional<StringRef> getX86Architecture(unsigned Index) const {
3351+ StringRef Feature = getFeatureStr(Index);
3352+ if (Feature.starts_with("arch="))
3353+ return Feature.drop_front(sizeof("arch=") - 1);
3354+ return std::nullopt;
3355+ }
3356+
3357+ void getX86Feature(llvm::SmallVectorImpl<StringRef> &Out,
3358+ unsigned Index) const {
3359+ if (isDefaultVersion(Index))
3360+ return;
3361+ if (getX86Architecture(Index))
3362+ return;
3363+ Out.push_back(getFeatureStr(Index));
3364+ }
3365+
33483366 // Given an index into the 'featuresStrs' sequence, compute a unique
33493367 // ID to be used with function name mangling for the associated variant.
33503368 // This mapping is necessary due to a requirement that the mangling ID
@@ -3428,6 +3446,15 @@ def DiagnoseIf : InheritableAttr {
34283446 let Documentation = [DiagnoseIfDocs];
34293447}
34303448
3449+ def NoSpecializations : InheritableAttr {
3450+ let Spellings = [Clang<"no_specializations", /*AllowInC*/0>];
3451+ let Args = [StringArgument<"Message", 1>];
3452+ let Subjects = SubjectList<[ClassTmpl, FunctionTmpl, VarTmpl]>;
3453+ let Documentation = [NoSpecializationsDocs];
3454+ let MeaningfulToClassTemplateDefinition = 1;
3455+ let TemplateDependent = 1;
3456+ }
3457+
34313458def ArcWeakrefUnavailable : InheritableAttr {
34323459 let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
34333460 let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
0 commit comments