Skip to content

Commit

Permalink
More bug fixes and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Jun 7, 2023
1 parent 0da4fcd commit f9bd2df
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 21 deletions.
2 changes: 2 additions & 0 deletions ext/googletest/googletest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ endif()

# Project version:



cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0048 NEW)
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
Expand Down
74 changes: 72 additions & 2 deletions ext/googletest/googletest/include/gtest/gtest-printers.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,71 @@
#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
#define GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_


#ifndef G_DISABLE_CLANG_WARNINGS
#if defined(__clang__)
#define G_DISABLE_CLANG_WARNINGS \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wextra\"") \
_Pragma("clang diagnostic ignored \"-Wsign-compare\"") \
_Pragma("clang diagnostic ignored \"-Wsign-conversion\"") \
_Pragma("clang diagnostic ignored \"-Wshorten-64-to-32\"") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
_Pragma("clang diagnostic ignored \"-Wundef\"") \
_Pragma("clang diagnostic ignored \"-Wunused-parameter\"") \
_Pragma("clang diagnostic ignored \"-Wunused-variable\"") \
_Pragma("clang diagnostic ignored \"-Wunused-function\"") \
_Pragma("clang diagnostic ignored \"-Wunused-private-field\"") \
_Pragma("clang diagnostic ignored \"-Wunused-template\"") \
_Pragma("clang diagnostic ignored \"-Wunused-local-typedef\"") \
_Pragma("clang diagnostic ignored \"-Wunused-member-function\"") \
_Pragma("clang diagnostic ignored \"-Wunused-const-variable\"") \
_Pragma("clang diagnostic ignored \"-Wunused-const-variable\"") \
_Pragma("clang diagnostic ignored \"-Wunused-value\"") \
_Pragma("clang diagnostic ignored \"-Wused-but-marked-unused\"") \
_Pragma("clang diagnostic ignored \"-Wzero-as-null-pointer-constant\"") \
_Pragma("clang diagnostic ignored \"-Wimplicit-int-float-conversion\"")
#else
#define G_DISABLE_CLANG_WARNINGS
#endif // G_DISABLE_CLANG_WARNINGS
#endif

#ifndef G_REENABLE_CLANG_WARNINGS
#if defined(__clang__)
#define G_REENABLE_CLANG_WARNINGS \
_Pragma("clang diagnostic pop")
#else
#define G_REENABLE_CLANG_WARNINGS
#endif // // defined(__clang__)
#endif


#ifndef G_DISABLE_GCC_WARNINGS
#if defined(__GNUC__) && !defined(__clang__)
#define G_DISABLE_GCC_WARNINGS \
_Pragma("GCC diagnostic push")\

#else
#define G_DISABLE_GCC_WARNINGS
#endif // G_DISABLE_GCC_WARNINGS
#endif // G_DISABLE_GCC_WARNINGS



#ifndef G_REENABLE_GCC_WARNINGS
#if defined(__GNUC__) && !defined(__clang__)
#define G_REENABLE_GCC_WARNINGS \
_Pragma("GCC diagnostic pop")
#else
#define G_REENABLE_GCC_WARNINGS
#endif // G_REENABLE_GCC_WARNINGS
#endif



G_DISABLE_CLANG_WARNINGS
G_DISABLE_GCC_WARNINGS

#include <functional>
#include <memory>
#include <ostream> // NOLINT
Expand All @@ -112,6 +177,8 @@
#include <utility>
#include <vector>



#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-port.h"

Expand Down Expand Up @@ -541,14 +608,14 @@ int AppropriateResolution(FloatType val) {
} else if (val >= 1e6) { // 1,000,000 to 9,999,999
divfor6 = 10;
}
if (static_cast<int32_t>(val / divfor6 + 0.5) * divfor6 == val) return 6;
if (static_cast<int32_t>(val / divfor6 + 0.5) * divfor6 == val) return 6; // NOLINT
}
return full;
}

inline void PrintTo(float f, ::std::ostream* os) {
auto old_precision = os->precision();
os->precision(AppropriateResolution(f));
os->precision(AppropriateResolution(f));// NOLINT
*os << f;
os->precision(old_precision);
}
Expand Down Expand Up @@ -1128,4 +1195,7 @@ ::std::string PrintToString(const T& value) {
// declarations from this file.
#include "gtest/internal/custom/gtest-printers.h"

G_REENABLE_GCC_WARNINGS
G_REENABLE_CLANG_WARNINGS

#endif // GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
11 changes: 9 additions & 2 deletions include/mim/detail/type/type_quaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ struct Quaternion {
static constexpr auto size() { return sizeV; }

constexpr T& operator[](size_type i) {
assert(i >= 0 && i < this->size());
if (i > this->size())
throw std::out_of_range("Quaternion::operator[]");

#if MIM_FORCE_QUATERNION_XYZW
return (&x)[i];
#else
return (&w)[i];
#endif
}
constexpr T const& operator[](size_type i) const {
assert(i >= 0 && i < this->size());
if (i > this->size())
throw std::out_of_range("Quaternion::operator[]");

#if MIM_FORCE_QUATERNION_XYZW
return (&x)[i];
#else
Expand Down Expand Up @@ -77,8 +81,10 @@ struct Quaternion {

constexpr explicit Quaternion(VectorT<3, T, Q> const& euler);

/* TODO: Once matrix is implemented bring this back in.
constexpr explicit Quaternion(MatrixT<3, 3, T, Q> const& m);
constexpr explicit Quaternion(MatrixT<4, 4, T, Q> const& m);
*/

constexpr Quaternion<T, Q>& operator=(Quaternion<T, Q> const& q) = default;

Expand All @@ -96,6 +102,7 @@ struct Quaternion {
constexpr Quaternion<T, Q>& operator/=(U const& scalar);
};


template <typename T, qualifier Q>
constexpr Quaternion<T, Q> operator+(Quaternion<T, Q> const& q);

Expand Down
41 changes: 36 additions & 5 deletions include/mim/detail/type/type_quaternion.inl
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,17 @@ constexpr Quaternion<T, Q>::Quaternion(const VectorT<3, T, Q>& euler) {
z = c.x * c.y * s.z - s.x * s.y * c.z;
}

/* TODO: Once matrix is implemented bring this back in.
template <typename T, qualifier Q>
constexpr Quaternion<T, Q>::Quaternion(const MatrixT<3, 3, T, Q>& m) {}
constexpr Quaternion<T, Q>::Quaternion(const MatrixT<3, 3, T, Q>& m) {
}
template <typename T, qualifier Q>
constexpr Quaternion<T, Q>::Quaternion(const MatrixT<4, 4, T, Q>& m) {}
constexpr Quaternion<T, Q>::Quaternion(const MatrixT<4, 4, T, Q>& m) {
}
*/

template <typename T, qualifier Q>
template <typename U>
Expand All @@ -109,11 +115,23 @@ constexpr Quaternion<T, Q>& Quaternion<T, Q>::operator=(const Quaternion<U, Q>&

template <typename T, qualifier Q>
template <typename U>
constexpr Quaternion<T, Q>& Quaternion<T, Q>::operator+=(const Quaternion<U, Q>& q) {}
constexpr Quaternion<T, Q>& Quaternion<T, Q>::operator+=(const Quaternion<U, Q>& q) {
this->x += static_cast<T>(q.w);
this->y += static_cast<T>(q.x);
this->z += static_cast<T>(q.y);
this->w += static_cast<T>(q.z);
return *this;
}

template <typename T, qualifier Q>
template <typename U>
constexpr Quaternion<T, Q>& Quaternion<T, Q>::operator-=(const Quaternion<U, Q>& q) {}
constexpr Quaternion<T, Q>& Quaternion<T, Q>::operator-=(const Quaternion<U, Q>& q) {
this->x -= static_cast<T>(q.w);
this->y -= static_cast<T>(q.x);
this->z -= static_cast<T>(q.y);
this->w -= static_cast<T>(q.z);
return *this;
}

template <typename T, qualifier Q>
template <typename U>
Expand All @@ -130,7 +148,20 @@ constexpr Quaternion<T, Q>& Quaternion<T, Q>::operator*=(const Quaternion<U, Q>&

template <typename T, qualifier Q>
template <typename U>
constexpr Quaternion<T, Q>& Quaternion<T, Q>::operator*=(const U& scalar) {}
constexpr Quaternion<T, Q>& Quaternion<T, Q>::operator/=(const U& scalar)
{
return *this *= static_cast<T>(1) / scalar;
}

template <typename T, qualifier Q>
template <typename U>
constexpr Quaternion<T, Q>& Quaternion<T, Q>::operator*=(const U& scalar) {
this->x *= scalar;
this->y *= scalar;
this->z *= scalar;
this->w *= scalar;
return *this;
}

template <typename T, qualifier Q>
constexpr Quaternion<T, Q> operator+(const Quaternion<T, Q>& q)
Expand Down
7 changes: 0 additions & 7 deletions include/mim/internal/config/compiler_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,6 @@
#endif


// ------------------------------------------------------------------------
// MIM_DISABLE_ALL_CLANG_WARNINGS / MIM_RESTORE_ALL_CLANG_WARNINGS
//
// The situation for clang is the same as for GCC. See above.
// ------------------------------------------------------------------------


// ------------------------------------------------------------------------
// MIM_ENABLE_CLANG_WARNING_AS_ERROR / MIM_DISABLE_CLANG_WARNING_AS_ERROR
//
Expand Down
7 changes: 4 additions & 3 deletions include/mim/internal/float16compressor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include "mim/internal/setup.hpp"

// Disable warnings for conversion from float to int
MIM_ENABLE_IGNORE_GCC_WARNING(-Wconversion)
MIM_DISABLE_GCC_WARNING(-Wconversion)
MIM_DISABLE_CLANG_WARNING(-Wconversion)

#if defined(MIM_ARCH_SSE2)
#include <emmintrin.h>
Expand Down Expand Up @@ -155,7 +156,7 @@ class Float16Compressor {
}

#endif
MIM_DISABLE_IGNORE_GCC_WARNING(-Wconversion)

MIM_RESTORE_GCC_WARNING()
MIM_RESTORE_CLANG_WARNING()
};
} // namespace mim
6 changes: 4 additions & 2 deletions include/mim/internal/misc/pcg_extras.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>&
return out << uint32_t(value);
}

MIM_ENABLE_IGNORE_GCC_WARNING(-Wunused-but-set-parameter)
MIM_DISABLE_GCC_WARNING(-Wunused-but-set-parameter)
MIM_DISABLE_CLANG_WARNING(-Wunused-but-set-parameter)

template <typename CharT, typename Traits>
std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>& in, uint8_t target) {
Expand All @@ -217,7 +218,8 @@ std::basic_istream<CharT, Traits>& operator>>(std::basic_istream<CharT, Traits>&
return in;
}

MIM_DISABLE_IGNORE_GCC_WARNING(-Wunused-but-set-parameter)
MIM_RESTORE_GCC_WARNING()
MIM_RESTORE_CLANG_WARNING()

/* Unfortunately, the above functions don't get found in preference to the
* built in ones, so we create some more specific overloads that will.
Expand Down

0 comments on commit f9bd2df

Please sign in to comment.