File tree Expand file tree Collapse file tree 3 files changed +22
-11
lines changed Expand file tree Collapse file tree 3 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 5050
5151#include " swift/Basic/SourceLoc.h"
5252#include " llvm/ADT/StringRef.h"
53+ #include " llvm/ADT/APInt.h"
5354#include < string>
5455#include < vector>
5556#endif
@@ -273,6 +274,24 @@ BRIDGED_INLINE SwiftInt BridgedOwnedString_count(BridgedOwnedString str);
273274SWIFT_NAME (" getter:BridgedOwnedString.isEmpty(self:)" )
274275BRIDGED_INLINE bool BridgedOwnedString_empty(BridgedOwnedString str);
275276
277+ // ===----------------------------------------------------------------------===//
278+ // MARK: BridgedOptionalInt
279+ // ===----------------------------------------------------------------------===//
280+
281+ struct BridgedOptionalInt {
282+ SwiftInt value;
283+ bool hasValue;
284+
285+ #ifdef USED_IN_CPP_SOURCE
286+ static BridgedOptionalInt getFromAPInt (llvm::APInt i) {
287+ if (i.getSignificantBits () <= std::min (std::numeric_limits<SwiftInt>::digits, 64 )) {
288+ return {(SwiftInt)i.getSExtValue (), true };
289+ }
290+ return {0 , false };
291+ }
292+ #endif
293+ };
294+
276295// ===----------------------------------------------------------------------===//
277296// MARK: OStream
278297// ===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change @@ -699,11 +699,6 @@ struct BridgedInstruction {
699699 unknown
700700 };
701701
702- struct OptionalInt {
703- SwiftInt value;
704- bool hasValue;
705- };
706-
707702 enum class MarkDependenceKind {
708703 Unresolved, Escaping, NonEscaping
709704 };
@@ -744,7 +739,7 @@ struct BridgedInstruction {
744739 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedGlobalVar GlobalAccessInst_getGlobal () const ;
745740 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedGlobalVar AllocGlobalInst_getGlobal () const ;
746741 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedFunction FunctionRefBaseInst_getReferencedFunction () const ;
747- BRIDGED_INLINE OptionalInt IntegerLiteralInst_getValue () const ;
742+ BRIDGED_INLINE BridgedOptionalInt IntegerLiteralInst_getValue () const ;
748743 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef StringLiteralInst_getValue () const ;
749744 BRIDGED_INLINE int StringLiteralInst_getEncoding () const ;
750745 BRIDGED_INLINE SwiftInt TupleExtractInst_fieldIndex () const ;
Original file line number Diff line number Diff line change @@ -1170,12 +1170,9 @@ BridgedFunction BridgedInstruction::FunctionRefBaseInst_getReferencedFunction()
11701170 return {getAs<swift::FunctionRefBaseInst>()->getInitiallyReferencedFunction ()};
11711171}
11721172
1173- BridgedInstruction::OptionalInt BridgedInstruction::IntegerLiteralInst_getValue () const {
1173+ BridgedOptionalInt BridgedInstruction::IntegerLiteralInst_getValue () const {
11741174 llvm::APInt result = getAs<swift::IntegerLiteralInst>()->getValue ();
1175- if (result.getSignificantBits () <= std::min (std::numeric_limits<SwiftInt>::digits, 64 )) {
1176- return {(SwiftInt)result.getSExtValue (), true };
1177- }
1178- return {0 , false };
1175+ return BridgedOptionalInt::getFromAPInt (result);
11791176}
11801177
11811178BridgedStringRef BridgedInstruction::StringLiteralInst_getValue () const {
You can’t perform that action at this time.
0 commit comments