fix(miscellaneous): fix misbehavior of assertions under some build types
This commit is contained in:
parent
099cba38f4
commit
897ee4f283
@ -53,13 +53,13 @@ void TestAssertionMacros()
|
||||
{
|
||||
check(true);
|
||||
//check(false);
|
||||
checkf(true, "True!");
|
||||
//checkf(false, "False!");
|
||||
checkf(true, TEXT("True!"));
|
||||
//checkf(false, TEXT("False!"));
|
||||
|
||||
always_check(true);
|
||||
//always_check(false);
|
||||
always_checkf(true, "True!");
|
||||
//always_checkf(false, "False!");
|
||||
always_checkf(true, TEXT("True!"));
|
||||
//always_checkf(false, TEXT("False!"));
|
||||
|
||||
//TestNoEntry();
|
||||
|
||||
|
@ -3,8 +3,13 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "Miscellaneous/PreprocessorHelpers.h"
|
||||
|
||||
#ifdef NDEBUG
|
||||
#undef NDEBUG
|
||||
#include <cassert>
|
||||
#define NDEBUG 1
|
||||
#else
|
||||
#include <cassert>
|
||||
#endif
|
||||
|
||||
NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
@ -37,7 +42,7 @@ NAMESPACE_PRIVATE_END
|
||||
#define always_check_no_recursion() static uint8 PREPROCESSOR_JOIN(RecursionCounter, __LINE__) = 0; always_checkf(PREPROCESSOR_JOIN(RecursionCounter, __LINE__) == 0, "Enclosing block was entered recursively."); const NAMESPACE_REDCRAFT::NAMESPACE_PRIVATE::FRecursionScopeMarker PREPROCESSOR_JOIN(ScopeMarker, __LINE__)(PREPROCESSOR_JOIN(RecursionCounter, __LINE__))
|
||||
#define always_unimplemented() always_checkf(false, "Unimplemented function called.")
|
||||
|
||||
#if BUILD_DEBUG
|
||||
#if BUILD_DEBUG || BUILD_DEVELOPMENT
|
||||
|
||||
# define check(InExpr) always_check(InExpr)
|
||||
# define checkf(InExpr, InFormat, ...) always_checkf(InExpr, InFormat, ##__VA_ARGS__)
|
||||
|
@ -31,12 +31,12 @@ FORCEINLINE void MemoryOrderCheck(EMemoryOrder Order, uint8 Require)
|
||||
{
|
||||
switch (Order)
|
||||
{
|
||||
case EMemoryOrder::Relaxed: checkf((Require) & 0x01, "Invalid memory order."); break;
|
||||
case EMemoryOrder::Consume: checkf((Require) & 0x02, "Invalid memory order."); break;
|
||||
case EMemoryOrder::Acquire: checkf((Require) & 0x04, "Invalid memory order."); break;
|
||||
case EMemoryOrder::Release: checkf((Require) & 0x08, "Invalid memory order."); break;
|
||||
case EMemoryOrder::AcquireRelease: checkf((Require) & 0x10, "Invalid memory order."); break;
|
||||
case EMemoryOrder::SequentiallyConsistent: checkf((Require) & 0x20, "Invalid memory order."); break;
|
||||
case EMemoryOrder::Relaxed: checkf((Require) & 0x01, TEXT("Invalid memory order.")); break;
|
||||
case EMemoryOrder::Consume: checkf((Require) & 0x02, TEXT("Invalid memory order.")); break;
|
||||
case EMemoryOrder::Acquire: checkf((Require) & 0x04, TEXT("Invalid memory order.")); break;
|
||||
case EMemoryOrder::Release: checkf((Require) & 0x08, TEXT("Invalid memory order.")); break;
|
||||
case EMemoryOrder::AcquireRelease: checkf((Require) & 0x10, TEXT("Invalid memory order.")); break;
|
||||
case EMemoryOrder::SequentiallyConsistent: checkf((Require) & 0x20, TEXT("Invalid memory order.")); break;
|
||||
default: check_no_entry();
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ struct TVariant
|
||||
constexpr auto Visit(F&& Func) &
|
||||
{
|
||||
using ReturnType = typename TCommonType<typename TInvokeResult<F, Types>::Type...>::Type;
|
||||
checkf(IsValid(), "It is an error to call Visit() on an wrong TVariant. Please either check IsValid().");
|
||||
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
|
||||
return ReturnType(NAMESPACE_PRIVATE::TVariantVisitHelper<ReturnType, F, Types...>::VisitLValueFuncs[GetIndex()](Forward<F>(Func), &Value));
|
||||
}
|
||||
|
||||
@ -367,7 +367,7 @@ struct TVariant
|
||||
constexpr auto Visit(F&& Func) &&
|
||||
{
|
||||
using ReturnType = typename TCommonType<typename TInvokeResult<F, Types>::Type...>::Type;
|
||||
checkf(IsValid(), "It is an error to call Visit() on an wrong TVariant. Please either check IsValid().");
|
||||
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
|
||||
return ReturnType(NAMESPACE_PRIVATE::TVariantVisitHelper<ReturnType, F, Types...>::VisitRValueFuncs[GetIndex()](Forward<F>(Func), &Value));
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ struct TVariant
|
||||
constexpr auto Visit(F&& Func) const&
|
||||
{
|
||||
using ReturnType = typename TCommonType<typename TInvokeResult<F, Types>::Type...>::Type;
|
||||
checkf(IsValid(), "It is an error to call Visit() on an wrong TVariant. Please either check IsValid().");
|
||||
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
|
||||
return ReturnType(NAMESPACE_PRIVATE::TVariantVisitHelper<ReturnType, F, Types...>::VisitConstLValueFuncs[GetIndex()](Forward<F>(Func), &Value));
|
||||
}
|
||||
|
||||
@ -383,35 +383,35 @@ struct TVariant
|
||||
constexpr auto Visit(F&& Func) const&&
|
||||
{
|
||||
using ReturnType = typename TCommonType<typename TInvokeResult<F, Types>::Type...>::Type;
|
||||
checkf(IsValid(), "It is an error to call Visit() on an wrong TVariant. Please either check IsValid().");
|
||||
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
|
||||
return ReturnType(NAMESPACE_PRIVATE::TVariantVisitHelper<ReturnType, F, Types...>::VisitConstRValueFuncs[GetIndex()](Forward<F>(Func), &Value));
|
||||
}
|
||||
|
||||
template <typename R, typename F> requires (true && ... && TIsInvocableResult<R, F, Types>::Value)
|
||||
constexpr R Visit(F&& Func) &
|
||||
{
|
||||
checkf(IsValid(), "It is an error to call Visit() on an wrong TVariant. Please either check IsValid().");
|
||||
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
|
||||
return R(NAMESPACE_PRIVATE::TVariantVisitHelper<R, F, Types...>::VisitLValueFuncs[GetIndex()](Forward<F>(Func), &Value));
|
||||
}
|
||||
|
||||
template <typename R, typename F> requires (true && ... && TIsInvocableResult<R, F, Types>::Value)
|
||||
constexpr R Visit(F&& Func) &&
|
||||
{
|
||||
checkf(IsValid(), "It is an error to call Visit() on an wrong TVariant. Please either check IsValid().");
|
||||
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
|
||||
return R(NAMESPACE_PRIVATE::TVariantVisitHelper<R, F, Types...>::VisitRValueFuncs[GetIndex()](Forward<F>(Func), &Value));
|
||||
}
|
||||
|
||||
template <typename R, typename F> requires (true && ... && TIsInvocableResult<R, F, Types>::Value)
|
||||
constexpr R Visit(F&& Func) const&
|
||||
{
|
||||
checkf(IsValid(), "It is an error to call Visit() on an wrong TVariant. Please either check IsValid().");
|
||||
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
|
||||
return R(NAMESPACE_PRIVATE::TVariantVisitHelper<R, F, Types...>::VisitConstLValueFuncs[GetIndex()](Forward<F>(Func), &Value));
|
||||
}
|
||||
|
||||
template <typename R, typename F> requires (true && ... && TIsInvocableResult<R, F, Types>::Value)
|
||||
constexpr R Visit(F&& Func) const&&
|
||||
{
|
||||
checkf(IsValid(), "It is an error to call Visit() on an wrong TVariant. Please either check IsValid().");
|
||||
checkf(IsValid(), TEXT("It is an error to call Visit() on an wrong TVariant. Please either check IsValid()."));
|
||||
return R(NAMESPACE_PRIVATE::TVariantVisitHelper<R, F, Types...>::VisitConstRValueFuncs[GetIndex()](Forward<F>(Func), &Value));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user