From d707c838d1eeb79b2e82cd0385e69d5798984da2 Mon Sep 17 00:00:00 2001 From: Matthew Andres Moreno Date: Fri, 14 Oct 2022 03:04:42 -0700 Subject: [PATCH] Simplify assert macro for clang compatibility --- include/netuit/arrange/AdjacencyFileTopologyFactory.hpp | 2 +- include/uitsl/algorithm/clamp_cast.hpp | 2 +- include/uitsl/debug/uitsl_always_assert.hpp | 5 ++++- include/uitsl/fetch/fetch_native.hpp | 2 +- tests/uitsl/debug/uitsl_always_assert.cpp | 6 +++--- tests/uitsl/debug/uitsl_assert.cpp | 6 +++--- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/netuit/arrange/AdjacencyFileTopologyFactory.hpp b/include/netuit/arrange/AdjacencyFileTopologyFactory.hpp index c64cefb20..0d214697f 100644 --- a/include/netuit/arrange/AdjacencyFileTopologyFactory.hpp +++ b/include/netuit/arrange/AdjacencyFileTopologyFactory.hpp @@ -15,7 +15,7 @@ namespace netuit { inline Topology make_adjacency_file_topology(const std::string& filename) { std::ifstream file(filename); - uitsl_always_assert(file); + uitsl_always_assert(file, ""); return dynamic_cast(file); } diff --git a/include/uitsl/algorithm/clamp_cast.hpp b/include/uitsl/algorithm/clamp_cast.hpp index c9a560a82..d3a4013bd 100644 --- a/include/uitsl/algorithm/clamp_cast.hpp +++ b/include/uitsl/algorithm/clamp_cast.hpp @@ -35,7 +35,7 @@ To clamp_cast( const From from ) { #ifdef __EMSCRIPTEN__ // necessary to keep nan sanitization from getting optimized away // and (I assume?) implicitly taken care of via the static_cast - uitsl_always_assert( !std::isnan( clamped ) ); + uitsl_always_assert( !std::isnan( clamped ), "" ); #endif return static_cast( clamped ); diff --git a/include/uitsl/debug/uitsl_always_assert.hpp b/include/uitsl/debug/uitsl_always_assert.hpp index 39afca65b..89e373589 100644 --- a/include/uitsl/debug/uitsl_always_assert.hpp +++ b/include/uitsl/debug/uitsl_always_assert.hpp @@ -30,11 +30,14 @@ do { \ std::cout << "LINE: " << __LINE__ << '\n'; \ std::cout << '\n'; \ std::cout << "MESSAGE:\n"; \ + std::cout << uitsl_ns::SetSeparator(" << ") << __VA_ARGS__;; \ std::cout << UITSL_STRINGIFY(__VA_ARGS__) << '\n'; \ - std::cout << uitsl_ns::SetSeparator(" << ") __VA_OPT__(<<) __VA_ARGS__; \ std::cout << '\n'; \ std::abort(); \ } \ } while(0) +// clang doesn't support __VA_OPT__ yet +// std::cout << uitsl_ns::SetSeparator(" << ") __VA_OPT__(<<) __VA_ARGS__; \ + #endif // #ifndef UITSL_DEBUG_UITSL_ALWAYS_ASSERT_HPP_INCLUDE diff --git a/include/uitsl/fetch/fetch_native.hpp b/include/uitsl/fetch/fetch_native.hpp index eb9482cae..35fb895a7 100644 --- a/include/uitsl/fetch/fetch_native.hpp +++ b/include/uitsl/fetch/fetch_native.hpp @@ -53,7 +53,7 @@ inline std::filesystem::path fetch_native( const std::string& url ) { [&curl_handle](){ curl_easy_cleanup( curl_handle ); } ); - uitsl_always_assert( curl_handle ); + uitsl_always_assert( curl_handle, "" ); uitsl::err_verify( curl_easy_setopt( curl_handle, CURLOPT_URL, url.c_str()) diff --git a/tests/uitsl/debug/uitsl_always_assert.cpp b/tests/uitsl/debug/uitsl_always_assert.cpp index d5934dff7..1f76956c8 100644 --- a/tests/uitsl/debug/uitsl_always_assert.cpp +++ b/tests/uitsl/debug/uitsl_always_assert.cpp @@ -6,9 +6,9 @@ TEST_CASE("uitsl_always_assert", "[nproc:1]") { // uitsl_always_assert(false); - uitsl_always_assert(true); - - uitsl_always_assert(true, ); + // uitsl_always_assert(true); + // + // uitsl_always_assert(true, ); uitsl_always_assert(true, ""); diff --git a/tests/uitsl/debug/uitsl_assert.cpp b/tests/uitsl/debug/uitsl_assert.cpp index 49d4e9b90..b26cb7b64 100644 --- a/tests/uitsl/debug/uitsl_assert.cpp +++ b/tests/uitsl/debug/uitsl_assert.cpp @@ -7,9 +7,9 @@ TEST_CASE("uitsl_assert", "[nproc:1]") { - uitsl_assert(true); - - uitsl_assert(true, ); + // uitsl_assert(true); + // + // uitsl_assert(true, ); uitsl_assert(true, "");