Skip to content

Commit a882ac6

Browse files
committed
AST: Make some ASTContext parameters const-correct.
1 parent ddf8f25 commit a882ac6

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

include/swift/AST/Attr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3222,7 +3222,7 @@ class SemanticAvailableAttr final {
32223222

32233223
/// Returns the effective range in which the declaration with this attribute
32243224
/// was introduced.
3225-
AvailabilityRange getIntroducedRange(ASTContext &Ctx) const;
3225+
AvailabilityRange getIntroducedRange(const ASTContext &Ctx) const;
32263226

32273227
/// The version tuple written in source for the `deprecated:` component.
32283228
std::optional<llvm::VersionTuple> getDeprecated() const {

include/swift/AST/AvailabilityDomain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class AvailabilityDomain final {
8888

8989
/// Returns true if this domain is considered active in the current
9090
/// compilation context.
91-
bool isActive(ASTContext &ctx) const;
91+
bool isActive(const ASTContext &ctx) const;
9292

9393
/// Returns the string to use in diagnostics to identify the domain. May
9494
/// return an empty string.

lib/AST/Availability.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,10 +828,13 @@ bool AvailabilityInference::isAvailableAsSPI(const Decl *D) {
828828
}
829829

830830
AvailabilityRange
831-
SemanticAvailableAttr::getIntroducedRange(ASTContext &Ctx) const {
832-
auto *attr = getParsedAttr();
831+
SemanticAvailableAttr::getIntroducedRange(const ASTContext &Ctx) const {
833832
assert(domain.isActive(Ctx));
834833

834+
auto *attr = getParsedAttr();
835+
if (!attr->Introduced.has_value())
836+
return AvailabilityRange::alwaysAvailable();
837+
835838
llvm::VersionTuple IntroducedVersion = attr->Introduced.value();
836839
StringRef Platform;
837840
llvm::VersionTuple RemappedIntroducedVersion;

lib/AST/AvailabilityDomain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
using namespace swift;
1818

19-
bool AvailabilityDomain::isActive(ASTContext &ctx) const {
19+
bool AvailabilityDomain::isActive(const ASTContext &ctx) const {
2020
switch (kind) {
2121
case Kind::Universal:
2222
case Kind::SwiftLanguage:

0 commit comments

Comments
 (0)