Skip to content

Commit c6cfb00

Browse files
committed
fixed #13606 - fixed precision of float values in ValueFlow XML debug output
1 parent 7a549bc commit c6cfb00

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/token.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "astutils.h"
2222
#include "errortypes.h"
2323
#include "library.h"
24+
#include "mathlib.h"
2425
#include "settings.h"
2526
#include "simplecpp.h"
2627
#include "symboldatabase.h"
@@ -1801,7 +1802,7 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
18011802
break;
18021803
case ValueFlow::Value::ValueType::FLOAT:
18031804
outs += "floatvalue=\"";
1804-
outs += std::to_string(value.floatValue); // TODO: should this be MathLib::toString()?
1805+
outs += MathLib::toString(value.floatValue);
18051806
outs += '\"';
18061807
break;
18071808
case ValueFlow::Value::ValueType::MOVED:
@@ -1875,7 +1876,6 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
18751876

18761877
outs += "/>\n";
18771878
}
1878-
18791879
else {
18801880
if (&value != &values->front())
18811881
outs += ",";

test/cli/other_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3129,8 +3129,8 @@ def test_debug_valueflow_xml(tmp_path): # #13606
31293129
value_elem = valueflow_elem[0].findall('values/value')
31303130
assert len(value_elem) == 3
31313131
assert 'floatvalue' in value_elem[0].attrib
3132-
assert value_elem[0].attrib['floatvalue'] == '0.000000'
3132+
assert value_elem[0].attrib['floatvalue'] == '1e-07'
31333133
assert 'floatvalue' in value_elem[1].attrib
3134-
assert value_elem[1].attrib['floatvalue'] == '0.000000'
3134+
assert value_elem[1].attrib['floatvalue'] == '1e-07'
31353135
assert 'floatvalue' in value_elem[2].attrib
3136-
assert value_elem[2].attrib['floatvalue'] == '0.000000'
3136+
assert value_elem[2].attrib['floatvalue'] == '1e-07'

0 commit comments

Comments
 (0)