File tree Expand file tree Collapse file tree 6 files changed +34
-0
lines changed
SwiftCompilerSources/Sources Expand file tree Collapse file tree 6 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -791,3 +791,9 @@ extension Function {
791791 return context. _bridged. appendBlock ( bridged) . block
792792 }
793793}
794+
795+ extension DeclRef {
796+ func calleesAreStaticallyKnowable( _ context: some Context ) -> Bool {
797+ context. _bridged. calleesAreStaticallyKnowable ( bridged)
798+ }
799+ }
Original file line number Diff line number Diff line change 1111//===----------------------------------------------------------------------===//
1212
1313import SILBridging
14+ import AST
1415
16+ /// A key for referencing an AST declaration in SIL.
17+ ///
18+ /// In addition to the AST reference, there are discriminators for referencing different
19+ /// implementation-level entities associated with a single language-level declaration,
20+ /// such as the allocating and initializing entry points of a constructor, etc.
1521public struct DeclRef : CustomStringConvertible , NoReflectionChildren {
1622 public let bridged : BridgedDeclRef
1723
1824 public var location : Location { Location ( bridged: bridged. getLocation ( ) ) }
1925
2026 public var description : String { String ( taking: bridged. getDebugDescription ( ) ) }
27+
28+ public var decl : Decl { bridged. getDecl ( ) . decl }
29+
30+ public static func == ( lhs: DeclRef , rhs: DeclRef ) -> Bool {
31+ lhs. bridged. isEqualTo ( rhs. bridged)
32+ }
2133}
Original file line number Diff line number Diff line change @@ -927,8 +927,10 @@ struct BridgedDeclRef {
927927 BRIDGED_INLINE BridgedDeclRef (swift::SILDeclRef declRef);
928928 BRIDGED_INLINE swift::SILDeclRef unbridged () const ;
929929
930+ BRIDGED_INLINE bool isEqualTo (BridgedDeclRef rhs) const ;
930931 BridgedOwnedString getDebugDescription () const ;
931932 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedLocation getLocation () const ;
933+ SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getDecl () const ;
932934 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDiagnosticArgument asDiagnosticArgument () const ;
933935};
934936
Original file line number Diff line number Diff line change @@ -1726,10 +1726,18 @@ swift::SILDeclRef BridgedDeclRef::unbridged() const {
17261726 return *reinterpret_cast <const swift::SILDeclRef *>(&storage);
17271727}
17281728
1729+ bool BridgedDeclRef::isEqualTo (BridgedDeclRef rhs) const {
1730+ return unbridged () == rhs.unbridged ();
1731+ }
1732+
17291733BridgedLocation BridgedDeclRef::getLocation () const {
17301734 return swift::SILDebugLocation (unbridged ().getDecl (), nullptr );
17311735}
17321736
1737+ BridgedDeclObj BridgedDeclRef::getDecl () const {
1738+ return {unbridged ().getDecl ()};
1739+ }
1740+
17331741BridgedDiagnosticArgument BridgedDeclRef::asDiagnosticArgument () const {
17341742 return swift::DiagnosticArgument (unbridged ().getDecl ()->getName ());
17351743}
Original file line number Diff line number Diff line change @@ -339,6 +339,7 @@ struct BridgedPassContext {
339339 SWIFT_IMPORT_UNSAFE OptionalBridgedFunction lookUpNominalDeinitFunction (BridgedDeclObj nominal) const ;
340340 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap (BridgedType type) const ;
341341 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getBuiltinIntegerType (SwiftInt bitWidth) const ;
342+ BRIDGED_INLINE bool calleesAreStaticallyKnowable (BridgedDeclRef method) const ;
342343 SWIFT_IMPORT_UNSAFE BridgedFunction createEmptyFunction (BridgedStringRef name,
343344 const BridgedParameterInfo * _Nullable bridgedParams,
344345 SwiftInt paramCount,
Original file line number Diff line number Diff line change @@ -488,6 +488,11 @@ BridgedType BridgedPassContext::getBuiltinIntegerType(SwiftInt bitWidth) const {
488488 return swift::SILType::getBuiltinIntegerType (bitWidth, ctxt);
489489}
490490
491+ bool BridgedPassContext::calleesAreStaticallyKnowable (BridgedDeclRef method) const {
492+ swift::SILModule *mod = invocation->getPassManager ()->getModule ();
493+ return swift::calleesAreStaticallyKnowable (*mod, method.unbridged ());
494+ }
495+
491496void BridgedPassContext::beginTransformFunction (BridgedFunction function) const {
492497 invocation->beginTransformFunction (function.getFunction ());
493498}
You can’t perform that action at this time.
0 commit comments