Skip to content

Commit 07aa074

Browse files
authored
Merge pull request swiftlang#10189 from swiftlang/revert-10180-feature-availability-20240723
Revert "Extend availability attribute to support feature-based availability"
2 parents e8d6d9e + 48b143c commit 07aa074

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+28
-1352
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "clang/AST/RawCommentList.h"
2626
#include "clang/AST/TemplateName.h"
2727
#include "clang/Basic/LLVM.h"
28-
#include "clang/Basic/LangOptions.h"
2928
#include "clang/Basic/PartialDiagnostic.h"
3029
#include "clang/Basic/SourceLocation.h"
3130
#include "llvm/ADT/DenseMap.h"
@@ -802,35 +801,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
802801
return DiagAllocator;
803802
}
804803

805-
struct AvailabilityDomainInfo {
806-
FeatureAvailKind Kind = FeatureAvailKind::None;
807-
ImplicitCastExpr *Call = nullptr;
808-
bool isInvalid() const { return Kind == FeatureAvailKind::None; }
809-
};
810-
811-
std::map<StringRef, AvailabilityDomainInfo> AvailabilityDomainMap;
812-
813-
void addAvailabilityDomainMap(StringRef Name, AvailabilityDomainInfo Info) {
814-
AvailabilityDomainMap[Name] = Info;
815-
}
816-
817-
std::pair<DomainAvailabilityAttr *, bool>
818-
checkNewFeatureAvailability(Decl *D, StringRef DomainName, bool Unavailable);
819-
820-
bool hasFeatureAvailabilityAttr(const Decl *D) const;
821-
822-
// Retrieve availability domain information for a feature.
823-
AvailabilityDomainInfo getFeatureAvailInfo(StringRef FeatureName) const;
824-
825-
// Retrieve feature name and availability domain information on a decl. If the
826-
// decl doesn't have attribute availability_domain on it, the name will be
827-
// empty and AvailabilityDomainInfo::Kind will be set to
828-
// FeatureAvailKind::None.
829-
std::pair<StringRef, AvailabilityDomainInfo>
830-
getFeatureAvailInfo(Decl *D) const;
831-
832-
bool hasUnavailableFeature(const Decl *D) const;
833-
834804
const TargetInfo &getTargetInfo() const { return *Target; }
835805
const TargetInfo *getAuxTargetInfo() const { return AuxTarget; }
836806

clang/include/clang/AST/Availability.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class AvailabilitySpec {
3737
/// Name of the platform that Version corresponds to.
3838
StringRef Platform;
3939

40-
StringRef DomainName;
41-
4240
SourceLocation BeginLoc, EndLoc;
4341

4442
public:
@@ -47,9 +45,6 @@ class AvailabilitySpec {
4745
: Version(Version), Platform(Platform), BeginLoc(BeginLoc),
4846
EndLoc(EndLoc) {}
4947

50-
AvailabilitySpec(StringRef DomainName, SourceLocation Loc)
51-
: DomainName(DomainName), BeginLoc(Loc), EndLoc(Loc) {}
52-
5348
/// This constructor is used when representing the '*' case.
5449
AvailabilitySpec(SourceLocation StarLoc)
5550
: BeginLoc(StarLoc), EndLoc(StarLoc) {}
@@ -60,12 +55,7 @@ class AvailabilitySpec {
6055
SourceLocation getEndLoc() const { return EndLoc; }
6156

6257
/// Returns true when this represents the '*' case.
63-
bool isOtherPlatformSpec() const {
64-
return Version.empty() && DomainName.empty();
65-
}
66-
67-
bool isDomainName() const { return !DomainName.empty(); }
68-
StringRef getDomainName() const { return DomainName; }
58+
bool isOtherPlatformSpec() const { return Version.empty(); }
6959
};
7060

7161
class Decl;

clang/include/clang/AST/ExprObjC.h

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,9 +1693,7 @@ class ObjCBridgedCastExpr final
16931693
/// be used in the condition of an \c if, but it is also usable as top level
16941694
/// expressions.
16951695
///
1696-
class ObjCAvailabilityCheckExpr final
1697-
: public Expr,
1698-
private llvm::TrailingObjects<ObjCAvailabilityCheckExpr, char> {
1696+
class ObjCAvailabilityCheckExpr : public Expr {
16991697
public:
17001698
struct VersionAsWritten {
17011699
/// Platform version canonicalized for use with availability checks.
@@ -1706,46 +1704,21 @@ class ObjCAvailabilityCheckExpr final
17061704

17071705
private:
17081706
friend class ASTStmtReader;
1709-
friend llvm::TrailingObjects<ObjCAvailabilityCheckExpr, char>;
17101707

17111708
VersionAsWritten VersionToCheck;
17121709
SourceLocation AtLoc, RParen;
17131710

1714-
void setHasDomainName(bool V) {
1715-
ObjCAvailabilityCheckExprBits.HasDomainName = V;
1716-
}
1717-
1718-
ObjCAvailabilityCheckExpr(SourceLocation AtLoc, SourceLocation RParen,
1719-
QualType Ty, StringRef DomainName)
1720-
: Expr(ObjCAvailabilityCheckExprClass, Ty, VK_PRValue, OK_Ordinary),
1721-
VersionToCheck(), AtLoc(AtLoc), RParen(RParen) {
1722-
setDependence(ExprDependence::None);
1723-
setHasDomainName(true);
1724-
strcpy(getTrailingObjects<char>(), DomainName.data());
1725-
}
1726-
17271711
public:
17281712
ObjCAvailabilityCheckExpr(VersionAsWritten VersionToCheck,
17291713
SourceLocation AtLoc,
17301714
SourceLocation RParen, QualType Ty)
17311715
: Expr(ObjCAvailabilityCheckExprClass, Ty, VK_PRValue, OK_Ordinary),
17321716
VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) {
17331717
setDependence(ExprDependence::None);
1734-
setHasDomainName(false);
17351718
}
17361719

1737-
static ObjCAvailabilityCheckExpr *
1738-
CreateAvailabilityFeatureCheck(SourceLocation AtLoc, SourceLocation RParen,
1739-
QualType Ty, StringRef DomainName,
1740-
const ASTContext &C);
1741-
17421720
explicit ObjCAvailabilityCheckExpr(EmptyShell Shell)
1743-
: Expr(ObjCAvailabilityCheckExprClass, Shell) {
1744-
setHasDomainName(false);
1745-
}
1746-
1747-
static ObjCAvailabilityCheckExpr *
1748-
CreateEmpty(const ASTContext &C, Stmt::EmptyShell Empty, size_t FeaturesLen);
1721+
: Expr(ObjCAvailabilityCheckExprClass, Shell) {}
17491722

17501723
SourceLocation getBeginLoc() const { return AtLoc; }
17511724
SourceLocation getEndLoc() const { return RParen; }
@@ -1758,14 +1731,6 @@ class ObjCAvailabilityCheckExpr final
17581731
return VersionToCheck.SourceVersion;
17591732
}
17601733

1761-
bool hasDomainName() const {
1762-
return ObjCAvailabilityCheckExprBits.HasDomainName;
1763-
}
1764-
StringRef getDomainName() const {
1765-
assert(hasDomainName());
1766-
return getTrailingObjects<char>();
1767-
}
1768-
17691734
child_range children() {
17701735
return child_range(child_iterator(), child_iterator());
17711736
}

clang/include/clang/AST/Stmt.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,15 +1226,6 @@ class alignas(void *) Stmt {
12261226
unsigned ShouldCopy : 1;
12271227
};
12281228

1229-
class ObjCAvailabilityCheckExprBitfields {
1230-
friend class ObjCAvailabilityCheckExpr;
1231-
LLVM_PREFERRED_TYPE(ExprBitfields)
1232-
unsigned : NumExprBits;
1233-
1234-
LLVM_PREFERRED_TYPE(bool)
1235-
unsigned HasDomainName : 1;
1236-
};
1237-
12381229
//===--- Clang Extensions bitfields classes ---===//
12391230

12401231
class OpaqueValueExprBitfields {
@@ -1333,7 +1324,6 @@ class alignas(void *) Stmt {
13331324

13341325
// Obj-C Expressions
13351326
ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits;
1336-
ObjCAvailabilityCheckExprBitfields ObjCAvailabilityCheckExprBits;
13371327

13381328
// Clang Extensions
13391329
OpaqueValueExprBitfields OpaqueValueExprBits;

clang/include/clang/Basic/Attr.td

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,25 +1124,6 @@ static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef Environm
11241124
let Documentation = [AvailabilityDocs];
11251125
}
11261126

1127-
def DomainAvailability : InheritableAttr {
1128-
// This attribute has no spellings as it is created implicitly when
1129-
// __attribute__((availability(domain:...))) is seen.
1130-
let Spellings = [];
1131-
let Args = [StringArgument<"domain">, BoolArgument<"unavailable">];
1132-
let AdditionalMembers = [{
1133-
std::string getFeatureAttributeStr() const;
1134-
}];
1135-
let Documentation = [InternalOnly];
1136-
}
1137-
1138-
// This attribute is used to annotate structs of type `_AvailabilityDomain`.
1139-
def AvailabilityDomain : InheritableAttr {
1140-
let Spellings = [Clang<"availability_domain">];
1141-
let Args = [IdentifierArgument<"name">];
1142-
let Subjects = SubjectList<[Var]>;
1143-
let Documentation = [Undocumented];
1144-
}
1145-
11461127
def ExternalSourceSymbol : InheritableAttr {
11471128
let Spellings = [Clang<"external_source_symbol", /*allowInC=*/1,
11481129
/*version=*/20230206>];

clang/include/clang/Basic/DiagnosticFrontendKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ def err_fe_invalid_exception_model
144144
def err_fe_invalid_source_date_epoch : Error<
145145
"environment variable 'SOURCE_DATE_EPOCH' ('%0') must be a non-negative decimal integer <= %1">;
146146

147-
def err_feature_availability_flag_invalid_value : Error<
148-
"invalid value '%0' passed to '-ffeature-availability='; expected <feature>:<on|off>">;
149-
150147
def err_fe_incompatible_option_with_remote_cache : Error<
151148
"'%0' is incompatible with remote caching backend">;
152149
def err_fe_unable_to_load_include_tree : Error<

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,11 +1122,6 @@ def err_availability_expected_platform : Error<
11221122
def err_availability_expected_environment : Error<
11231123
"expected an environment name, e.g., 'compute'">;
11241124

1125-
def err_features_domain_name : Error<
1126-
"expected a domain name">;
1127-
def err_feature_invalid_availability_check : Error<
1128-
"cannot pass a domain argument along with other arguments">;
1129-
11301125
// objc_bridge_related attribute
11311126
def err_objcbridge_related_expected_related_class : Error<
11321127
"expected a related Objective-C class name, e.g., 'NSColor'">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3960,28 +3960,6 @@ def err_availability_unexpected_parameter: Error<
39603960
def warn_unguarded_availability :
39613961
Warning<"%0 is only available %select{|in %4 environment }3on %1 %2 or newer">,
39623962
InGroup<UnguardedAvailability>, DefaultIgnore;
3963-
def err_unguarded_feature : Error<
3964-
"use of %0 requires feature '%1' to be %select{available|unavailable}2">;
3965-
def err_label_in_conditionally_guarded_feature : Error<
3966-
"labels cannot appear in regions conditionally guarded by features">;
3967-
def err_features_invalid_for_decl : Error<
3968-
"feature attributes cannot be applied to %0">;
3969-
def err_features_invalid_name : Error<
3970-
"cannot find definition of feature attribute '%0'">;
3971-
def err_features_invalid__arg : Error<
3972-
"invalid argument %0: must evaluate to 0 or 1">;
3973-
def err_feature_invalid_for_decl : Error<
3974-
"feature attribute '%0(%1)' cannot be applied to this decl">;
3975-
def err_feature_merge_incompatible : Error<
3976-
"cannot merge incompatible feature attribute to this decl">;
3977-
def err_new_feature_redeclaration : Error<
3978-
"new feature attributes cannot be added to redeclarations">;
3979-
def err_feature_invalid_added : Error<
3980-
"cannot add feature availability to this decl">;
3981-
def note_feature_incompatible0 : Note<
3982-
"feature attribute %0">;
3983-
def note_feature_incompatible1 : Note<
3984-
"is incompatible with %0">;
39853963
def warn_unguarded_availability_unavailable :
39863964
Warning<"%0 is unavailable">,
39873965
InGroup<UnguardedAvailability>, DefaultIgnore;

clang/include/clang/Basic/LangOptions.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ enum class PointerAuthenticationMode : unsigned {
6464
SignAndAuth
6565
};
6666

67-
enum class FeatureAvailKind { None, Available, Unavailable, Dynamic };
68-
6967
/// Bitfields of LangOptions, split out from LangOptions in order to ensure that
7068
/// this large collection of bitfields is a trivial class type.
7169
class LangOptionsBase {
@@ -546,8 +544,6 @@ class LangOptions : public LangOptionsBase {
546544
/// This list is sorted.
547545
std::vector<std::string> ModuleFeatures;
548546

549-
std::vector<std::string> FeatureAvailability;
550-
551547
/// Options for parsing comments.
552548
CommentOptions CommentOpts;
553549

@@ -565,16 +561,6 @@ class LangOptions : public LangOptionsBase {
565561
/// host code generation.
566562
std::string OMPHostIRFile;
567563

568-
llvm::StringMap<FeatureAvailKind> FeatureAvailabilityMap;
569-
570-
void setFeatureAvailability(StringRef Feature, FeatureAvailKind Kind) {
571-
FeatureAvailabilityMap[Feature] = Kind;
572-
}
573-
574-
FeatureAvailKind getFeatureAvailability(StringRef Feature) const {
575-
return FeatureAvailabilityMap.lookup(Feature);
576-
}
577-
578564
/// The user provided compilation unit ID, if non-empty. This is used to
579565
/// externalize static variables which is needed to support accessing static
580566
/// device variables in host code for single source offloading languages

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3433,10 +3433,6 @@ def fno_builtin : Flag<["-"], "fno-builtin">, Group<f_Group>,
34333433
def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group<f_Group>,
34343434
Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
34353435
HelpText<"Disable implicit builtin knowledge of a specific function">;
3436-
def ffeature_availability_EQ : Joined<["-"], "ffeature-availability=">, Group<f_Group>,
3437-
Visibility<[CC1Option]>,
3438-
HelpText<"feature availability">,
3439-
MarshallingInfoStringVector<LangOpts<"FeatureAvailability">>;
34403436
def fno_common : Flag<["-"], "fno-common">, Group<f_Group>,
34413437
Visibility<[ClangOption, CC1Option]>,
34423438
HelpText<"Compile common globals like normal definitions">;

clang/include/clang/Parse/Parser.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3127,12 +3127,6 @@ class Parser : public CodeCompletionHandler {
31273127
void ParseHLSLQualifiers(ParsedAttributes &Attrs);
31283128

31293129
VersionTuple ParseVersionTuple(SourceRange &Range);
3130-
void ParseFeatureAvailabilityAttribute(
3131-
IdentifierInfo &Availability, SourceLocation AvailabilityLoc,
3132-
ParsedAttributes &attrs, SourceLocation *endLoc,
3133-
IdentifierInfo *ScopeName, SourceLocation ScopeLoc, ParsedAttr::Form Form,
3134-
BalancedDelimiterTracker &T);
3135-
31363130
void ParseAvailabilityAttribute(IdentifierInfo &Availability,
31373131
SourceLocation AvailabilityLoc,
31383132
ParsedAttributes &attrs,

clang/include/clang/Sema/DelayedDiagnostic.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,7 @@ class AccessedEntity {
125125
/// the complete parsing of the current declaration.
126126
class DelayedDiagnostic {
127127
public:
128-
enum DDKind : unsigned char {
129-
Availability,
130-
FeatureAvailability,
131-
Access,
132-
ForbiddenType
133-
};
128+
enum DDKind : unsigned char { Availability, Access, ForbiddenType };
134129

135130
DDKind Kind;
136131
bool Triggered;
@@ -148,9 +143,6 @@ class DelayedDiagnostic {
148143
StringRef Msg,
149144
bool ObjCPropertyAccess);
150145

151-
static DelayedDiagnostic
152-
makeFeatureAvailability(NamedDecl *D, ArrayRef<SourceLocation> Locs);
153-
154146
static DelayedDiagnostic makeAccess(SourceLocation Loc,
155147
const AccessedEntity &Entity) {
156148
DelayedDiagnostic DD;
@@ -209,12 +201,6 @@ class DelayedDiagnostic {
209201
return AvailabilityData.AR;
210202
}
211203

212-
const NamedDecl *getFeatureAvailabilityDecl() const {
213-
assert(Kind == FeatureAvailability &&
214-
"Not a feature availability diagnostic.");
215-
return FeatureAvailabilityData.Decl;
216-
}
217-
218204
/// The diagnostic ID to emit. Used like so:
219205
/// Diag(diag.Loc, diag.getForbiddenTypeDiagnostic())
220206
/// << diag.getForbiddenTypeOperand()
@@ -260,10 +246,6 @@ class DelayedDiagnostic {
260246
bool ObjCPropertyAccess;
261247
};
262248

263-
struct FAD {
264-
const NamedDecl *Decl;
265-
};
266-
267249
struct FTD {
268250
unsigned Diagnostic;
269251
unsigned Argument;
@@ -272,7 +254,6 @@ class DelayedDiagnostic {
272254

273255
union {
274256
struct AD AvailabilityData;
275-
struct FAD FeatureAvailabilityData;
276257
struct FTD ForbiddenTypeData;
277258

278259
/// Access control.

clang/include/clang/Sema/ParsedAttr.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,6 @@ class ParsedAttr final
363363
return IsProperty;
364364
}
365365

366-
bool isAvailabilityAttribute() const { return IsAvailability; }
367-
368366
bool isInvalid() const { return Invalid; }
369367
void setInvalid(bool b = true) const { Invalid = b; }
370368

clang/include/clang/Sema/ScopeInfo.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ class FunctionScopeInfo {
144144
/// unavailable.
145145
bool HasPotentialAvailabilityViolations : 1;
146146

147-
bool HasPotentialFeatureAvailabilityViolations : 1;
148-
149147
/// A flag that is set when parsing a method that must call super's
150148
/// implementation, such as \c -dealloc, \c -finalize, or any method marked
151149
/// with \c __attribute__((objc_requires_super)).
@@ -396,8 +394,7 @@ class FunctionScopeInfo {
396394
HasBranchIntoScope(false), HasIndirectGoto(false), HasMustTail(false),
397395
HasDroppedStmt(false), HasOMPDeclareReductionCombiner(false),
398396
HasFallthroughStmt(false), UsesFPIntrin(false),
399-
HasPotentialAvailabilityViolations(false),
400-
HasPotentialFeatureAvailabilityViolations(false), ObjCShouldCallSuper(false),
397+
HasPotentialAvailabilityViolations(false), ObjCShouldCallSuper(false),
401398
ObjCIsDesignatedInit(false), ObjCWarnForNoDesignatedInitChain(false),
402399
ObjCIsSecondaryInit(false), ObjCWarnForNoInitDelegation(false),
403400
NeedsCoroutineSuspends(true), FoundImmediateEscalatingExpression(false),

0 commit comments

Comments
 (0)