Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmake/compileroptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options_safe(-Wno-shadow-uncaptured-local)
add_compile_options_safe(-Wno-implicit-float-conversion)
add_compile_options_safe(-Wno-switch-enum)
add_compile_options_safe(-Wno-float-conversion)
add_compile_options_safe(-Wno-date-time)
add_compile_options(-Wno-disabled-macro-expansion)
add_compile_options_safe(-Wno-bitwise-instead-of-logical)
Expand Down
2 changes: 1 addition & 1 deletion gui/statsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void StatsDialog::setNumberOfFilesScanned(int num)
void StatsDialog::setScanDuration(double seconds)
{
// Factor the duration into units (days/hours/minutes/seconds)
int secs = seconds;
int secs = static_cast<int>(seconds);
const int days = secs / (24 * 60 * 60);
secs -= days * (24 * 60 * 60);
const int hours = secs / (60 * 60);
Expand Down
2 changes: 2 additions & 0 deletions lib/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SUPPRESS_WARNING_CLANG_PUSH("-Wtautological-type-limit-compare")
SUPPRESS_WARNING_CLANG_PUSH("-Wextra-semi-stmt")
SUPPRESS_WARNING_CLANG_PUSH("-Wzero-as-null-pointer-constant")
SUPPRESS_WARNING_CLANG_PUSH("-Wformat")
SUPPRESS_WARNING_CLANG_PUSH("-Wfloat-conversion")

#define PICOJSON_USE_INT64
#include <picojson.h>
Expand All @@ -35,6 +36,7 @@ SUPPRESS_WARNING_CLANG_POP
SUPPRESS_WARNING_CLANG_POP
SUPPRESS_WARNING_CLANG_POP
SUPPRESS_WARNING_CLANG_POP
SUPPRESS_WARNING_CLANG_POP
SUPPRESS_WARNING_GCC_POP
SUPPRESS_WARNING_POP

Expand Down
11 changes: 8 additions & 3 deletions lib/programmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,11 @@ static double asFloat(const ValueFlow::Value& value)
return value.isFloatValue() ? value.floatValue : static_cast<double>(value.intvalue);
}

static MathLib::bigint asInt(const ValueFlow::Value& value)
{
return value.isFloatValue() ? static_cast<MathLib::bigint>(value.floatValue) : value.intvalue;
}

static std::string removeAssign(const std::string& assign) {
return std::string{assign.cbegin(), assign.cend() - 1};
}
Expand All @@ -587,7 +592,7 @@ namespace {
template<class T, class U>
void operator()(T& x, const U& y) const
{
x = y;
x = static_cast<T>(y);
}
};
}
Expand Down Expand Up @@ -896,7 +901,7 @@ static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibr
return ValueFlow::Value::unknown();
ValueFlow::Value v;
combineValueProperties(args[0], args[1], v);
v.floatValue = std::scalbln(asFloat(args[0]), asFloat(args[1]));
v.floatValue = std::scalbln(asFloat(args[0]), asInt(args[1]));
Copy link
Copy Markdown
Collaborator Author

@firewave firewave Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need test coverage for this and the other mathematical functions (I have not yet checked if we have).

v.valueType = ValueFlow::Value::ValueType::FLOAT;
return v;
};
Expand All @@ -907,7 +912,7 @@ static std::unordered_map<std::string, BuiltinLibraryFunction> createBuiltinLibr
return ValueFlow::Value::unknown();
ValueFlow::Value v;
combineValueProperties(args[0], args[1], v);
v.floatValue = std::ldexp(asFloat(args[0]), asFloat(args[1]));
v.floatValue = std::ldexp(asFloat(args[0]), asInt(args[1]));
v.valueType = ValueFlow::Value::ValueType::FLOAT;
return v;
};
Expand Down