Skip to content

Commit e1f4057

Browse files
committed
ConstantFolding: only print a warning for infinity floating point literals if it has an AST node
This avoids false alarms for floating point literals which are imported from the `var infinity` getter of floating point types.
1 parent 963edb7 commit e1f4057

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/SILOptimizer/Utils/ConstantFolding.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,8 @@ void ConstantFolder::initializeWorklist(SILFunction &f) {
18861886
// to be folded, if needed.
18871887
if (auto *floatLit = dyn_cast<FloatLiteralInst>(inst)) {
18881888
APFloat fpVal = floatLit->getValue();
1889-
if (EnableDiagnostics && fpVal.isInfinity()) {
1889+
if (EnableDiagnostics && fpVal.isInfinity() &&
1890+
floatLit->getLoc().getAsASTNode<FloatLiteralExpr>()) {
18901891
SmallString<10> litStr;
18911892
tryExtractLiteralText(floatLit, litStr);
18921893
diagnose(inst->getModule().getASTContext(), inst->getLoc().getSourceLoc(),

0 commit comments

Comments
 (0)