@@ -875,28 +875,7 @@ constantFoldAndCheckIntegerConversions(BuiltinInst *BI,
875
875
template <unsigned N>
876
876
static bool tryExtractLiteralText (FloatLiteralInst *flitInst,
877
877
SmallString<N> &fpStr) {
878
-
879
- Expr *expr = flitInst->getLoc ().getAsASTNode <Expr>();
880
- if (!expr)
881
- return false ;
882
-
883
- // 'expr' may not be a FloatLiteralExpr since 'flitInst' could have been
884
- // created by the ConstantFolder by folding floating-point constructor calls.
885
- // So we iterate through the sequence of folded constructors if any, and
886
- // try to extract the FloatLiteralExpr.
887
- while (auto *callExpr = dyn_cast<CallExpr>(expr)) {
888
- if (callExpr->getNumArguments () != 1 ||
889
- !dyn_cast<ConstructorRefCallExpr>(callExpr->getFn ()))
890
- break ;
891
-
892
- auto *tupleExpr = dyn_cast<TupleExpr>(callExpr->getArg ());
893
- if (!tupleExpr)
894
- break ;
895
-
896
- expr = tupleExpr->getElement (0 );
897
- }
898
-
899
- auto *flitExpr = dyn_cast<FloatLiteralExpr>(expr);
878
+ auto *flitExpr = flitInst->getLoc ().getAsASTNode <FloatLiteralExpr>();
900
879
if (!flitExpr)
901
880
return false ;
902
881
@@ -1074,27 +1053,8 @@ bool isLossyUnderflow(APFloat srcVal, BuiltinFloatType *srcType,
1074
1053
// / This function determines whether the float literal in the given
1075
1054
// / SIL instruction is specified using hex-float notation in the Swift source.
1076
1055
bool isHexLiteralInSource (FloatLiteralInst *flitInst) {
1077
- Expr *expr = flitInst->getLoc ().getAsASTNode <Expr>();
1078
- if (!expr)
1079
- return false ;
1080
-
1081
- // Iterate through a sequence of folded implicit constructors if any, and
1082
- // try to extract the FloatLiteralExpr.
1083
- while (auto *callExpr = dyn_cast<CallExpr>(expr)) {
1084
- if (!callExpr->isImplicit () || callExpr->getNumArguments () != 1 ||
1085
- !dyn_cast<ConstructorRefCallExpr>(callExpr->getFn ()))
1086
- break ;
1087
-
1088
- auto *tupleExpr = dyn_cast<TupleExpr>(callExpr->getArg ());
1089
- if (!tupleExpr)
1090
- break ;
1091
-
1092
- expr = tupleExpr->getElement (0 );
1093
- }
1094
- auto *flitExpr = dyn_cast<FloatLiteralExpr>(expr);
1095
- if (!flitExpr)
1096
- return false ;
1097
- return flitExpr->getDigitsText ().startswith (" 0x" );
1056
+ auto *flitExpr = flitInst->getLoc ().getAsASTNode <FloatLiteralExpr>();
1057
+ return flitExpr && flitExpr->getDigitsText ().startswith (" 0x" );
1098
1058
}
1099
1059
1100
1060
bool maybeExplicitFPCons (BuiltinInst *BI, const BuiltinInfo &Builtin) {
0 commit comments