Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/swift/Basic/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef SWIFT_BASIC_FEATURES_H
#define SWIFT_BASIC_FEATURES_H

#include "swift/Basic/FixedBitSet.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"

Expand All @@ -37,6 +38,9 @@ FeatureName,
return NumFeatures;
}

// A handy set datatype for all your feature-tracking needs!
using BasicFeatureSet = FixedBitSet<numFeatures(), Feature>;

/// Determine whether the given feature is suppressible.
bool isSuppressibleFeature(Feature feature);

Expand Down
5 changes: 2 additions & 3 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/Regex.h"
Expand Down Expand Up @@ -377,8 +375,9 @@ namespace swift {
/// behavior. This is a staging flag, and will be removed in the future.
bool EnableNewOperatorLookup = false;


/// The set of features that have been enabled.
llvm::SmallSet<Feature, 2> Features;
BasicFeatureSet Features;

/// Temporary flag to support LLDB's transition to using \c Features.
bool EnableBareSlashRegexLiterals = false;
Expand Down
1 change: 0 additions & 1 deletion lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3293,7 +3293,6 @@ static void suppressingFeature(PrintOptions &options, Feature feature,
llvm_unreachable("exhaustive switch");
}

using BasicFeatureSet = FixedBitSet<numFeatures(), Feature>;

class FeatureSet {
BasicFeatureSet required;
Expand Down
23 changes: 22 additions & 1 deletion lib/Basic/LangOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,29 @@

using namespace swift;

static void
insertDefaultEnabledFeatures(decltype(LangOptions::Features) &Features) {
// Default-on any full-fledged language features
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option) \
if (Option) \
Features.insert(Feature::FeatureName);

// Don't default-on any other features.
#define UPCOMING_FEATURE(FeatureName, SENumber, Version)
#define SUPPRESSIBLE_LANGUAGE_FEATURE(FeatureName, SENumber, Description, \
Option)
#define EXPERIMENTAL_FEATURE(FeatureName, AvailableInProd)
#include "swift/Basic/Features.def"
#undef LANGUAGE_FEATURE
#undef UPCOMING_FEATURE
#undef SUPPRESSIBLE_LANGUAGE_FEATURE
#undef EXPERIMENTAL_LANGUAGE_FEATURE
}

LangOptions::LangOptions() {
// Note: Introduce default-on language options here.
insertDefaultEnabledFeatures(Features);

// Features default-on only in asserts builds.
#ifndef NDEBUG
Features.insert(Feature::ParserRoundTrip);
Features.insert(Feature::ParserValidation);
Expand Down