From 9c3c9af5be331939db758b0628486bfff1696ab4 Mon Sep 17 00:00:00 2001 From: firewave Date: Sat, 1 Feb 2025 19:05:39 +0100 Subject: [PATCH] fixed #13606/13607 - print (precise) float as such in ValueFlow debug output [skip ci] --- lib/token.cpp | 4 ++-- lib/vfvalue.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index aea4c3a713f..33789c735f1 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -21,6 +21,7 @@ #include "astutils.h" #include "errortypes.h" #include "library.h" +#include "mathlib.h" #include "settings.h" #include "simplecpp.h" #include "symboldatabase.h" @@ -1790,7 +1791,7 @@ void Token::printValueFlow(bool xml, std::ostream &out) const break; case ValueFlow::Value::ValueType::FLOAT: outs += "floatvalue=\""; - outs += std::to_string(value.floatValue); // TODO: should this be MathLib::toString()? + outs += MathLib::toString(value.floatValue); outs += '\"'; break; case ValueFlow::Value::ValueType::MOVED: @@ -1864,7 +1865,6 @@ void Token::printValueFlow(bool xml, std::ostream &out) const outs += "/>\n"; } - else { if (&value != &values->front()) outs += ","; diff --git a/lib/vfvalue.cpp b/lib/vfvalue.cpp index 8e694c6eeb7..9dd1d423faa 100644 --- a/lib/vfvalue.cpp +++ b/lib/vfvalue.cpp @@ -19,6 +19,7 @@ #include "vfvalue.h" #include "errortypes.h" +#include "mathlib.h" #include "token.h" #include @@ -58,7 +59,7 @@ namespace ValueFlow { ss << this->tokvalue->str(); break; case ValueType::FLOAT: - ss << this->floatValue; + ss << MathLib::toString(this->floatValue); break; case ValueType::MOVED: ss << toString(this->moveKind);