Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinity fix and clang from PPA #2

Closed
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
22 changes: 5 additions & 17 deletions .github/workflows/build-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,13 @@ jobs:
steps:
- name: Check out repository
uses: actions/[email protected]
- name: Add clazy PPA
# Ubuntu2404 comes with v1.11, which is too old for the Qt6.4 shipped with Ubuntu 24.04
run: |
sudo add-apt-repository ppa:daschuer/clazy
sudo apt update
- name: Install build dependencies
run: tools/debian_buildenv.sh setup
- name: Build clazy v1.12
if: matrix.name == 'clazy'
# Ubuntu2404 comes with v1.11, which is too old for the Qt6.4 shipped with Ubuntu 2404
run: |
sudo apt-get update
sudo apt-get install -y llvm-dev libclang-dev clang
git clone --branch v1.12 --single-branch https://github.com/KDE/clazy.git
cd clazy
mkdir build
cd build
cmake ..
make -j$(nproc)
sudo make install
clazy --version
- name: Create build directory
run: mkdir build
- name: Configure (clazy)
Expand Down Expand Up @@ -75,8 +66,6 @@ jobs:
CXX: clazy
- name: Configure (clang-tidy)
if: matrix.name == 'clang-tidy'
# Our code contains the use of infinity(), which Clang >= 18 reports
# as error, if you compile with -fast-math
run: |
cmake \
-DCMAKE_BUILD_TYPE=Debug \
Expand All @@ -97,7 +86,6 @@ jobs:
-DMAD=ON \
-DMODPLUG=ON \
-DWAVPACK=ON \
-DCMAKE_CXX_FLAGS="-Wno-nan-infinity-disabled" \
..
working-directory: build
env:
Expand Down
10 changes: 5 additions & 5 deletions src/test/durationutiltest.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <limits>

#include <gtest/gtest.h>

#include "util/duration.h"

#include <QtDebug>
#include <limits>

#include "util/duration.h"
#include "util/fpclassify.h"

namespace {

Expand Down Expand Up @@ -115,7 +115,7 @@ TEST_F(DurationUtilTest, formatTime) {
formatTime("24:00:00.000", 24 * 3600);
formatTime("24:00:01.000", 24 * 3600 + 1);
formatTime("25:00:01.000", 25 * 3600 + 1);
formatTime("?", std::numeric_limits<double>::infinity());
formatTime("?", util_double_infinity());
formatTime("?", -1);
}

Expand Down
13 changes: 5 additions & 8 deletions src/test/frametest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QDebug>

#include "audio/frame.h"
#include "util/fpclassify.h"

class FrameTest : public testing::Test {
};
Expand All @@ -18,7 +19,7 @@ TEST_F(FrameTest, TestFramePosValid) {
// Denormals
EXPECT_TRUE(mixxx::audio::FramePos(0.0).isValid());
EXPECT_TRUE(mixxx::audio::FramePos(std::numeric_limits<double>::min() / 2.0).isValid());
EXPECT_FALSE(mixxx::audio::FramePos(std::numeric_limits<double>::infinity()).isValid());
EXPECT_FALSE(mixxx::audio::FramePos(util_double_infinity()).isValid());
// NaN
EXPECT_FALSE(mixxx::audio::FramePos().isValid());
EXPECT_FALSE(mixxx::audio::FramePos(std::numeric_limits<double>::quiet_NaN()).isValid());
Expand Down Expand Up @@ -54,16 +55,12 @@ TEST_F(FrameTest, TestFramePosEquality) {
mixxx::audio::FramePos(std::numeric_limits<
mixxx::audio::FramePos::value_t>::quiet_NaN()));
EXPECT_EQ(mixxx::audio::FramePos(),
mixxx::audio::FramePos(std::numeric_limits<
mixxx::audio::FramePos::value_t>::infinity()));
mixxx::audio::FramePos(util_double_infinity()));
EXPECT_EQ(mixxx::audio::FramePos(),
mixxx::audio::FramePos(
-std::numeric_limits<
mixxx::audio::FramePos::value_t>::infinity()));
mixxx::audio::FramePos(-util_double_infinity()));
EXPECT_EQ(mixxx::audio::FramePos(std::numeric_limits<
mixxx::audio::FramePos::value_t>::quiet_NaN()),
mixxx::audio::FramePos(std::numeric_limits<
mixxx::audio::FramePos::value_t>::infinity()));
mixxx::audio::FramePos(util_double_infinity()));
}

TEST_F(FrameTest, LowerFrameBoundary) {
Expand Down
6 changes: 3 additions & 3 deletions src/test/mathutiltest.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <gtest/gtest.h>

#include <QtDebug>
#include <limits>

#include "util/denormalsarezero.h"
#include "util/fpclassify.h"
#include "util/math.h"

namespace {
Expand Down Expand Up @@ -51,11 +51,11 @@ TEST_F(MathUtilTest, IsNaN) {
TEST_F(MathUtilTest, IsInf) {
// Test floats can be recognized as infinity.
EXPECT_FALSE(util_isinf(0.0f));
EXPECT_TRUE(util_isinf(std::numeric_limits<float>::infinity()));
EXPECT_TRUE(util_isinf(util_float_infinity()));

// Test doubles can be recognized as infinity.
EXPECT_FALSE(util_isinf(0.0f));
EXPECT_TRUE(util_isinf(std::numeric_limits<double>::infinity()));
EXPECT_TRUE(util_isinf(util_double_infinity()));
}

TEST_F(MathUtilTest, Denormal) {
Expand Down
9 changes: 9 additions & 0 deletions src/util/fpclassify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#endif

#include <cmath>
#include <limits>

int util_fpclassify(float x) {
return std::fpclassify(x);
Expand Down Expand Up @@ -48,3 +49,11 @@ int util_isnan(double x) {
int util_isinf(double x) {
return std::isinf(x);
}

float util_float_infinity() {
return std::numeric_limits<double>::infinity();
}
Comment on lines +53 to +55
Copy link

Choose a reason for hiding this comment

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

Suggested change
float util_float_infinity() {
return std::numeric_limits<double>::infinity();
}
float util_float_infinity() {
return std::numeric_limits<float>::infinity();
}


double util_double_infinity() {
return std::numeric_limits<double>::infinity();
}
3 changes: 3 additions & 0 deletions src/util/fpclassify.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ int util_isnan(double x);

int util_isinf(float x);
int util_isinf(double x);

float util_float_infinity();
double util_double_infinity();