Skip to content

Commit 43da3fd

Browse files
committed
Add support for -enable-experimental-feature to sil-opt
1 parent f1607c9 commit 43da3fd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tools/sil-opt/SILOpt.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/Basic/FileTypes.h"
2222
#include "swift/Basic/LLVMInitialize.h"
2323
#include "swift/Basic/InitializeSwiftModules.h"
24+
#include "swift/Basic/QuotedString.h"
2425
#include "swift/Frontend/DiagnosticVerifier.h"
2526
#include "swift/Frontend/Frontend.h"
2627
#include "swift/Frontend/PrintingDiagnosticConsumer.h"
@@ -113,6 +114,10 @@ static llvm::cl::opt<bool>
113114
DisableObjCInterop("disable-objc-interop",
114115
llvm::cl::desc("Disable Objective-C interoperability."));
115116

117+
static llvm::cl::list<std::string>
118+
ExperimentalFeatures("enable-experimental-feature",
119+
llvm::cl::desc("Enable the given experimental feature."));
120+
116121
static llvm::cl::opt<bool>
117122
EnableExperimentalConcurrency("enable-experimental-concurrency",
118123
llvm::cl::desc("Enable experimental concurrency model."));
@@ -572,6 +577,15 @@ int main(int argc, char **argv) {
572577
toOptionalBool(EnableExperimentalMoveOnly);
573578
if (enableExperimentalMoveOnly && *enableExperimentalMoveOnly)
574579
Invocation.getLangOptions().Features.insert(Feature::MoveOnly);
580+
for (auto &featureName : ExperimentalFeatures) {
581+
if (auto feature = getExperimentalFeature(featureName)) {
582+
Invocation.getLangOptions().Features.insert(*feature);
583+
} else {
584+
llvm::errs() << "error: unknown feature "
585+
<< QuotedString(featureName) << "\n";
586+
exit(-1);
587+
}
588+
}
575589

576590
Invocation.getLangOptions().EnableObjCInterop =
577591
EnableObjCInterop ? true :

0 commit comments

Comments
 (0)