@@ -37,9 +37,6 @@ SwiftMetatype SILNode::getSILNodeMetatype(SILNodeKind kind) {
37
37
return metatype;
38
38
}
39
39
40
- static_assert (sizeof (BridgedLocation) == sizeof(SILDebugLocation),
41
- "BridgedLocation has wrong size");
42
-
43
40
// / Fills \p storage with all Values from the bridged \p values array.
44
41
ArrayRef<SILValue> swift::getSILValues (BridgedValueArray values,
45
42
SmallVectorImpl<SILValue> &storage) {
@@ -565,10 +562,10 @@ BridgedSubstitutionMap SubstitutionMap_getEmpty() {
565
562
// SILLocation
566
563
// ===----------------------------------------------------------------------===//
567
564
568
- BridgedLocation SILLocation_getAutogeneratedLocation (BridgedLocation loc) {
565
+ SILDebugLocation SILLocation_getAutogeneratedLocation (SILDebugLocation loc) {
569
566
SILDebugLocation autoGenLoc (RegularLocation::getAutoGeneratedLocation (),
570
- castToDebugLocation ( loc) .getScope ());
571
- return * reinterpret_cast <BridgedLocation *>(& autoGenLoc) ;
567
+ loc.getScope ());
568
+ return autoGenLoc;
572
569
}
573
570
574
571
// ===----------------------------------------------------------------------===//
@@ -721,9 +718,8 @@ void SILInstruction_setOperand(BridgedInstruction inst, SwiftInt index,
721
718
castToInst (inst)->setOperand ((unsigned )index, castToSILValue (value));
722
719
}
723
720
724
- BridgedLocation SILInstruction_getLocation (BridgedInstruction inst) {
725
- SILDebugLocation loc = castToInst (inst)->getDebugLocation ();
726
- return *reinterpret_cast <BridgedLocation *>(&loc);
721
+ SILDebugLocation SILInstruction_getLocation (BridgedInstruction inst) {
722
+ return castToInst (inst)->getDebugLocation ();
727
723
}
728
724
729
725
BridgedMemoryBehavior SILInstruction_getMemBehavior (BridgedInstruction inst) {
@@ -972,51 +968,52 @@ BridgedInstruction SILBuilder_createBuiltinBinaryFunction(
972
968
BridgedType operandType, BridgedType resultType,
973
969
BridgedValueArray arguments) {
974
970
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
975
- getSILDebugScope ( b.loc ));
971
+ b.loc . getScope ( ));
976
972
SmallVector<SILValue, 16 > argValues;
977
- return {builder.createBuiltinBinaryFunction (getRegularLocation (b. loc ),
978
- name, getSILType (operandType), getSILType (resultType ),
979
- getSILValues (arguments, argValues))};
973
+ return {builder.createBuiltinBinaryFunction (
974
+ RegularLocation (b. loc . getLocation ()), name, getSILType (operandType ),
975
+ getSILType (resultType), getSILValues (arguments, argValues))};
980
976
}
981
977
982
978
BridgedInstruction SILBuilder_createCondFail (BridgedBuilder b,
983
979
BridgedValue condition, StringRef message) {
984
980
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
985
- getSILDebugScope ( b.loc ));
986
- return {builder.createCondFail (getRegularLocation (b.loc ),
981
+ b.loc . getScope ( ));
982
+ return {builder.createCondFail (RegularLocation (b.loc . getLocation () ),
987
983
castToSILValue (condition), message)};
988
984
}
989
985
990
986
BridgedInstruction SILBuilder_createIntegerLiteral (BridgedBuilder b,
991
987
BridgedType type, SwiftInt value) {
992
988
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
993
- getSILDebugScope ( b.loc ));
994
- return {builder.createIntegerLiteral (getRegularLocation (b.loc ),
989
+ b.loc . getScope ( ));
990
+ return {builder.createIntegerLiteral (RegularLocation (b.loc . getLocation () ),
995
991
getSILType (type), value)};
996
992
}
997
993
998
994
BridgedInstruction SILBuilder_createAllocStack (BridgedBuilder b,
999
995
BridgedType type, SwiftInt hasDynamicLifetime, SwiftInt isLexical,
1000
996
SwiftInt wasMoved) {
1001
997
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1002
- getSILDebugScope (b.loc ));
1003
- return {builder.createAllocStack (getRegularLocation (b.loc ), getSILType (type),
1004
- None, hasDynamicLifetime != 0 , isLexical != 0 , wasMoved != 0 )};
998
+ b.loc .getScope ());
999
+ return {builder.createAllocStack (
1000
+ RegularLocation (b.loc .getLocation ()), getSILType (type), None,
1001
+ hasDynamicLifetime != 0 , isLexical != 0 , wasMoved != 0 )};
1005
1002
}
1006
1003
1007
1004
BridgedInstruction SILBuilder_createDeallocStack (BridgedBuilder b,
1008
1005
BridgedValue operand) {
1009
1006
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1010
- getSILDebugScope ( b.loc ));
1011
- return {builder.createDeallocStack (getRegularLocation (b.loc ),
1007
+ b.loc . getScope ( ));
1008
+ return {builder.createDeallocStack (RegularLocation (b.loc . getLocation () ),
1012
1009
castToSILValue (operand))};
1013
1010
}
1014
1011
1015
1012
BridgedInstruction SILBuilder_createDeallocStackRef (BridgedBuilder b,
1016
1013
BridgedValue operand) {
1017
1014
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1018
- getSILDebugScope ( b.loc ));
1019
- return {builder.createDeallocStackRef (getRegularLocation (b.loc ),
1015
+ b.loc . getScope ( ));
1016
+ return {builder.createDeallocStackRef (RegularLocation (b.loc . getLocation () ),
1020
1017
castToSILValue (operand))};
1021
1018
}
1022
1019
@@ -1025,17 +1022,17 @@ SILBuilder_createUncheckedRefCast(BridgedBuilder b,
1025
1022
BridgedValue op,
1026
1023
BridgedType type) {
1027
1024
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1028
- getSILDebugScope ( b.loc ));
1029
- return {builder.createUncheckedRefCast (getRegularLocation (b.loc ),
1025
+ b.loc . getScope ( ));
1026
+ return {builder.createUncheckedRefCast (RegularLocation (b.loc . getLocation () ),
1030
1027
castToSILValue (op), getSILType (type))};
1031
1028
}
1032
1029
1033
1030
BridgedInstruction SILBuilder_createSetDeallocating (BridgedBuilder b,
1034
1031
BridgedValue op, bool isAtomic) {
1035
1032
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1036
- getSILDebugScope ( b.loc ));
1033
+ b.loc . getScope ( ));
1037
1034
return {builder.createSetDeallocating (
1038
- getRegularLocation (b.loc ), castToSILValue (op),
1035
+ RegularLocation (b.loc . getLocation () ), castToSILValue (op),
1039
1036
isAtomic ? RefCountingInst::Atomicity::Atomic
1040
1037
: RefCountingInst::Atomicity::NonAtomic)};
1041
1038
}
@@ -1044,34 +1041,35 @@ BridgedInstruction
1044
1041
SILBuilder_createFunctionRef (BridgedBuilder b,
1045
1042
BridgedFunction function) {
1046
1043
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1047
- getSILDebugScope ( b.loc ));
1048
- return {builder.createFunctionRef (getRegularLocation (b.loc ),
1044
+ b.loc . getScope ( ));
1045
+ return {builder.createFunctionRef (RegularLocation (b.loc . getLocation () ),
1049
1046
castToFunction (function))};
1050
1047
}
1051
1048
1052
1049
BridgedInstruction SILBuilder_createCopyValue (BridgedBuilder b,
1053
1050
BridgedValue op) {
1054
1051
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1055
- getSILDebugScope ( b.loc ));
1056
- return {builder.createCopyValue (getRegularLocation (b.loc ),
1052
+ b.loc . getScope ( ));
1053
+ return {builder.createCopyValue (RegularLocation (b.loc . getLocation () ),
1057
1054
castToSILValue (op))};
1058
1055
}
1059
1056
1060
1057
BridgedInstruction SILBuilder_createCopyAddr (BridgedBuilder b,
1061
1058
BridgedValue from, BridgedValue to,
1062
1059
SwiftInt takeSource, SwiftInt initializeDest) {
1063
1060
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1064
- getSILDebugScope (b.loc ));
1065
- return {builder.createCopyAddr (getRegularLocation (b.loc ), castToSILValue (from),
1066
- castToSILValue (to), IsTake_t (takeSource != 0 ),
1067
- IsInitialization_t (initializeDest != 0 ))};
1061
+ b.loc .getScope ());
1062
+ return {builder.createCopyAddr (RegularLocation (b.loc .getLocation ()),
1063
+ castToSILValue (from), castToSILValue (to),
1064
+ IsTake_t (takeSource != 0 ),
1065
+ IsInitialization_t (initializeDest != 0 ))};
1068
1066
}
1069
1067
1070
1068
BridgedInstruction SILBuilder_createDestroyValue (BridgedBuilder b,
1071
1069
BridgedValue op) {
1072
1070
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1073
- getSILDebugScope ( b.loc ));
1074
- return {builder.createDestroyValue (getRegularLocation (b.loc ),
1071
+ b.loc . getScope ( ));
1072
+ return {builder.createDestroyValue (RegularLocation (b.loc . getLocation () ),
1075
1073
castToSILValue (op))};
1076
1074
}
1077
1075
@@ -1080,11 +1078,11 @@ BridgedInstruction SILBuilder_createApply(BridgedBuilder b,
1080
1078
BridgedSubstitutionMap subMap,
1081
1079
BridgedValueArray arguments) {
1082
1080
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1083
- getSILDebugScope ( b.loc ));
1081
+ b.loc . getScope ( ));
1084
1082
SmallVector<SILValue, 16 > argValues;
1085
- return {builder.createApply (getRegularLocation (b. loc ), castToSILValue (function),
1086
- castToSubstitutionMap (subMap ),
1087
- getSILValues (arguments, argValues))};
1083
+ return {builder.createApply (
1084
+ RegularLocation (b. loc . getLocation ()), castToSILValue (function ),
1085
+ castToSubstitutionMap (subMap), getSILValues (arguments, argValues))};
1088
1086
}
1089
1087
1090
1088
static EnumElementDecl *getEnumElement (SILType enumType, int caseIndex) {
@@ -1100,12 +1098,11 @@ BridgedInstruction SILBuilder_createUncheckedEnumData(BridgedBuilder b,
1100
1098
BridgedValue enumVal, SwiftInt caseIdx,
1101
1099
BridgedType resultType) {
1102
1100
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1103
- getSILDebugScope ( b.loc ));
1101
+ b.loc . getScope ( ));
1104
1102
SILValue en = castToSILValue (enumVal);
1105
- return {builder.createUncheckedEnumData (getRegularLocation (b.loc ),
1106
- castToSILValue (enumVal),
1107
- getEnumElement (en->getType (), caseIdx),
1108
- castToSILType (resultType))};
1103
+ return {builder.createUncheckedEnumData (
1104
+ RegularLocation (b.loc .getLocation ()), castToSILValue (enumVal),
1105
+ getEnumElement (en->getType (), caseIdx), castToSILType (resultType))};
1109
1106
}
1110
1107
1111
1108
BridgedInstruction SILBuilder_createSwitchEnumInst (BridgedBuilder b,
@@ -1114,7 +1111,7 @@ BridgedInstruction SILBuilder_createSwitchEnumInst(BridgedBuilder b,
1114
1111
const void * _Nullable enumCases,
1115
1112
SwiftInt numEnumCases) {
1116
1113
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1117
- getSILDebugScope ( b.loc ));
1114
+ b.loc . getScope ( ));
1118
1115
using BridgedCase = const std::pair<SwiftInt, BridgedBasicBlock>;
1119
1116
ArrayRef<BridgedCase> cases (static_cast <BridgedCase *>(enumCases),
1120
1117
(unsigned )numEnumCases);
@@ -1129,7 +1126,7 @@ BridgedInstruction SILBuilder_createSwitchEnumInst(BridgedBuilder b,
1129
1126
assert (mappedElements.count (c.first ) && " wrong enum element index" );
1130
1127
convertedCases.push_back ({mappedElements[c.first ], castToBasicBlock (c.second )});
1131
1128
}
1132
- return {builder.createSwitchEnum (getRegularLocation (b.loc ),
1129
+ return {builder.createSwitchEnum (RegularLocation (b.loc . getLocation () ),
1133
1130
castToSILValue (enumVal),
1134
1131
castToBasicBlock (defaultBlock), convertedCases)};
1135
1132
}
@@ -1138,8 +1135,9 @@ BridgedInstruction SILBuilder_createBranch(
1138
1135
BridgedBuilder b, BridgedBasicBlock destBlock,
1139
1136
BridgedValueArray arguments) {
1140
1137
SILBuilder builder (castToInst (b.insertBefore ), castToBasicBlock (b.insertAtEnd ),
1141
- getSILDebugScope ( b.loc ));
1138
+ b.loc . getScope ( ));
1142
1139
SmallVector<SILValue, 16 > argValues;
1143
- return {builder.createBranch (getRegularLocation (b.loc ),
1144
- castToBasicBlock (destBlock), getSILValues (arguments, argValues))};
1140
+ return {builder.createBranch (RegularLocation (b.loc .getLocation ()),
1141
+ castToBasicBlock (destBlock),
1142
+ getSILValues (arguments, argValues))};
1145
1143
}
0 commit comments