Skip to content

Commit ca20ebc

Browse files
committed
SwiftCompilerSources: add bridging to hasFeature
1 parent cc83a7d commit ca20ebc

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/Options.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ struct Options {
2929
}
3030

3131
var enableEmbeddedSwift: Bool {
32-
_bridged.enableEmbeddedSwift()
32+
_bridged.hasFeature(.Embedded)
33+
}
34+
35+
func hasFeature(_ feature: BridgedPassContext.Feature) -> Bool {
36+
_bridged.hasFeature(feature)
3337
}
3438

3539
enum AssertConfiguration {

include/swift/SILOptimizer/OptimizerBridging.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ struct BridgedPassContext {
169169
Lowered
170170
};
171171

172+
/// Enumeration describing all of the named features.
173+
enum class Feature {
174+
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option) FeatureName,
175+
#include "swift/Basic/Features.def"
176+
};
177+
172178
SWIFT_IMPORT_UNSAFE BridgedOwnedString getModuleDescription() const;
173179
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedChangeNotificationHandler asNotificationHandler() const;
174180
BRIDGED_INLINE SILStage getSILStage() const;
@@ -301,7 +307,7 @@ struct BridgedPassContext {
301307
};
302308

303309
BRIDGED_INLINE bool enableStackProtection() const;
304-
BRIDGED_INLINE bool enableEmbeddedSwift() const;
310+
BRIDGED_INLINE bool hasFeature(Feature feature) const;
305311
BRIDGED_INLINE bool enableMoveInoutStackProtection() const;
306312
BRIDGED_INLINE AssertConfiguration getAssertConfiguration() const;
307313
bool enableSimplificationFor(BridgedInstruction inst) const;

include/swift/SILOptimizer/OptimizerBridgingImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ bool BridgedPassContext::enableStackProtection() const {
414414
return mod->getOptions().EnableStackProtection;
415415
}
416416

417-
bool BridgedPassContext::enableEmbeddedSwift() const {
417+
bool BridgedPassContext::hasFeature(Feature feature) const {
418418
swift::SILModule *mod = invocation->getPassManager()->getModule();
419-
return mod->getASTContext().LangOpts.hasFeature(swift::Feature::Embedded);
419+
return mod->getASTContext().LangOpts.hasFeature((swift::Feature)feature);
420420
}
421421

422422
bool BridgedPassContext::enableMoveInoutStackProtection() const {

0 commit comments

Comments
 (0)