Skip to content

Commit 08f01de

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 87da3b7 commit 08f01de

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
@@ -1665,7 +1665,8 @@ void ConstantFolder::initializeWorklist(SILFunction &f) {
16651665
// to be folded, if needed.
16661666
if (auto *floatLit = dyn_cast<FloatLiteralInst>(inst)) {
16671667
APFloat fpVal = floatLit->getValue();
1668-
if (EnableDiagnostics && fpVal.isInfinity()) {
1668+
if (EnableDiagnostics && fpVal.isInfinity() &&
1669+
floatLit->getLoc().getAsASTNode<FloatLiteralExpr>()) {
16691670
SmallString<10> litStr;
16701671
tryExtractLiteralText(floatLit, litStr);
16711672
diagnose(inst->getModule().getASTContext(), inst->getLoc().getSourceLoc(),

0 commit comments

Comments
 (0)