mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/main' into rebranch
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "swift/Config.h"
|
||||
#include "llvm/ADT/Hashing.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <limits.h>
|
||||
|
||||
@@ -228,10 +229,20 @@ bool LangOptions::hasFeature(Feature feature) const {
|
||||
if (Features.contains(feature))
|
||||
return true;
|
||||
|
||||
if (feature == Feature::BareSlashRegexLiterals &&
|
||||
EnableBareSlashRegexLiterals)
|
||||
return true;
|
||||
|
||||
if (auto version = getFeatureLanguageVersion(feature))
|
||||
return isSwiftVersionAtLeast(*version);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LangOptions::hasFeature(llvm::StringRef featureName) const {
|
||||
if (auto feature = getFutureFeature(featureName))
|
||||
return hasFeature(*feature);
|
||||
|
||||
if (auto feature = getExperimentalFeature(featureName))
|
||||
return hasFeature(*feature);
|
||||
|
||||
@@ -424,6 +435,15 @@ bool swift::isSuppressibleFeature(Feature feature) {
|
||||
llvm_unreachable("covered switch");
|
||||
}
|
||||
|
||||
llvm::Optional<Feature> swift::getFutureFeature(llvm::StringRef name) {
|
||||
return llvm::StringSwitch<Optional<Feature>>(name)
|
||||
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option)
|
||||
#define FUTURE_FEATURE(FeatureName, SENumber, Version) \
|
||||
.Case(#FeatureName, Feature::FeatureName)
|
||||
#include "swift/Basic/Features.def"
|
||||
.Default(None);
|
||||
}
|
||||
|
||||
llvm::Optional<Feature> swift::getExperimentalFeature(llvm::StringRef name) {
|
||||
return llvm::StringSwitch<Optional<Feature>>(name)
|
||||
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option)
|
||||
@@ -433,6 +453,16 @@ llvm::Optional<Feature> swift::getExperimentalFeature(llvm::StringRef name) {
|
||||
.Default(None);
|
||||
}
|
||||
|
||||
llvm::Optional<unsigned> swift::getFeatureLanguageVersion(Feature feature) {
|
||||
switch (feature) {
|
||||
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option)
|
||||
#define FUTURE_FEATURE(FeatureName, SENumber, Version) \
|
||||
case Feature::FeatureName: return Version;
|
||||
#include "swift/Basic/Features.def"
|
||||
default: return None;
|
||||
}
|
||||
}
|
||||
|
||||
DiagnosticBehavior LangOptions::getAccessNoteFailureLimit() const {
|
||||
switch (AccessNoteBehavior) {
|
||||
case AccessNoteDiagnosticBehavior::Ignore:
|
||||
|
||||
Reference in New Issue
Block a user