Commit bb7534ee by Yuly Novikov Committed by Commit Bot

Use ASSERT() instead of assert() when possible.

Since ASSERT() works in Release builds. Left assert() in a few places where calling a function may not be safe. Bug: angleproject:4396 Change-Id: Ic75a3d41d846e327097f8c37fe2336dcd3be6cb8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2057745Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
parent 9f4ab98d
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "common/tls.h" #include "common/tls.h"
#include <assert.h> #include "common/debug.h"
#ifdef ANGLE_ENABLE_WINDOWS_UWP #ifdef ANGLE_ENABLE_WINDOWS_UWP
# include <map> # include <map>
...@@ -62,14 +62,14 @@ TLSIndex CreateTLSIndex() ...@@ -62,14 +62,14 @@ TLSIndex CreateTLSIndex()
} }
#endif #endif
assert(index != TLS_INVALID_INDEX && ASSERT(index != TLS_INVALID_INDEX &&
"CreateTLSIndex(): Unable to allocate Thread Local Storage"); "CreateTLSIndex(): Unable to allocate Thread Local Storage");
return index; return index;
} }
bool DestroyTLSIndex(TLSIndex index) bool DestroyTLSIndex(TLSIndex index)
{ {
assert(index != TLS_INVALID_INDEX && "DestroyTLSIndex(): Invalid TLS Index"); ASSERT(index != TLS_INVALID_INDEX && "DestroyTLSIndex(): Invalid TLS Index");
if (index == TLS_INVALID_INDEX) if (index == TLS_INVALID_INDEX)
{ {
return false; return false;
...@@ -77,8 +77,8 @@ bool DestroyTLSIndex(TLSIndex index) ...@@ -77,8 +77,8 @@ bool DestroyTLSIndex(TLSIndex index)
#ifdef ANGLE_PLATFORM_WINDOWS #ifdef ANGLE_PLATFORM_WINDOWS
# ifdef ANGLE_ENABLE_WINDOWS_UWP # ifdef ANGLE_ENABLE_WINDOWS_UWP
assert(index < nextTlsIndex); ASSERT(index < nextTlsIndex);
assert(find(freeTlsIndices.begin(), freeTlsIndices.end(), index) == freeTlsIndices.end()); ASSERT(find(freeTlsIndices.begin(), freeTlsIndices.end(), index) == freeTlsIndices.end());
freeTlsIndices.push_back(index); freeTlsIndices.push_back(index);
for (auto threadData : allThreadData) for (auto threadData : allThreadData)
...@@ -99,7 +99,7 @@ bool DestroyTLSIndex(TLSIndex index) ...@@ -99,7 +99,7 @@ bool DestroyTLSIndex(TLSIndex index)
bool SetTLSValue(TLSIndex index, void *value) bool SetTLSValue(TLSIndex index, void *value)
{ {
assert(index != TLS_INVALID_INDEX && "SetTLSValue(): Invalid TLS Index"); ASSERT(index != TLS_INVALID_INDEX && "SetTLSValue(): Invalid TLS Index");
if (index == TLS_INVALID_INDEX) if (index == TLS_INVALID_INDEX)
{ {
return false; return false;
...@@ -131,7 +131,7 @@ bool SetTLSValue(TLSIndex index, void *value) ...@@ -131,7 +131,7 @@ bool SetTLSValue(TLSIndex index, void *value)
void *GetTLSValue(TLSIndex index) void *GetTLSValue(TLSIndex index)
{ {
assert(index != TLS_INVALID_INDEX && "GetTLSValue(): Invalid TLS Index"); ASSERT(index != TLS_INVALID_INDEX && "GetTLSValue(): Invalid TLS Index");
if (index == TLS_INVALID_INDEX) if (index == TLS_INVALID_INDEX)
{ {
return nullptr; return nullptr;
......
...@@ -276,7 +276,7 @@ inline bool IsIntegerSampler(TBasicType type) ...@@ -276,7 +276,7 @@ inline bool IsIntegerSampler(TBasicType type)
case EbtSamplerVideoWEBGL: case EbtSamplerVideoWEBGL:
return false; return false;
default: default:
assert(!IsSampler(type)); ASSERT(!IsSampler(type));
} }
return false; return false;
...@@ -311,7 +311,7 @@ inline bool IsIntegerSamplerUnsigned(TBasicType type) ...@@ -311,7 +311,7 @@ inline bool IsIntegerSamplerUnsigned(TBasicType type)
case EbtUSamplerCubeArray: case EbtUSamplerCubeArray:
return true; return true;
default: default:
assert(!IsIntegerSampler(type)); ASSERT(!IsIntegerSampler(type));
} }
return false; return false;
...@@ -469,7 +469,7 @@ inline bool IsSampler2D(TBasicType type) ...@@ -469,7 +469,7 @@ inline bool IsSampler2D(TBasicType type)
case EbtUSamplerCubeArray: case EbtUSamplerCubeArray:
return false; return false;
default: default:
assert(!IsSampler(type)); ASSERT(!IsSampler(type));
} }
return false; return false;
...@@ -525,7 +525,7 @@ inline bool IsSamplerCube(TBasicType type) ...@@ -525,7 +525,7 @@ inline bool IsSamplerCube(TBasicType type)
case EbtSamplerVideoWEBGL: case EbtSamplerVideoWEBGL:
return false; return false;
default: default:
assert(!IsSampler(type)); ASSERT(!IsSampler(type));
} }
return false; return false;
...@@ -581,7 +581,7 @@ inline bool IsSampler3D(TBasicType type) ...@@ -581,7 +581,7 @@ inline bool IsSampler3D(TBasicType type)
case EbtSamplerVideoWEBGL: case EbtSamplerVideoWEBGL:
return false; return false;
default: default:
assert(!IsSampler(type)); ASSERT(!IsSampler(type));
} }
return false; return false;
...@@ -637,7 +637,7 @@ inline bool IsSamplerArray(TBasicType type) ...@@ -637,7 +637,7 @@ inline bool IsSamplerArray(TBasicType type)
case EbtSamplerVideoWEBGL: case EbtSamplerVideoWEBGL:
return false; return false;
default: default:
assert(!IsSampler(type)); ASSERT(!IsSampler(type));
} }
return false; return false;
...@@ -693,7 +693,7 @@ inline bool IsShadowSampler(TBasicType type) ...@@ -693,7 +693,7 @@ inline bool IsShadowSampler(TBasicType type)
case EbtSamplerVideoWEBGL: case EbtSamplerVideoWEBGL:
return false; return false;
default: default:
assert(!IsSampler(type)); ASSERT(!IsSampler(type));
} }
return false; return false;
...@@ -742,7 +742,7 @@ inline bool IsImage2D(TBasicType type) ...@@ -742,7 +742,7 @@ inline bool IsImage2D(TBasicType type)
case EbtUImageBuffer: case EbtUImageBuffer:
return false; return false;
default: default:
assert(!IsImage(type)); ASSERT(!IsImage(type));
} }
return false; return false;
...@@ -791,7 +791,7 @@ inline bool IsImage3D(TBasicType type) ...@@ -791,7 +791,7 @@ inline bool IsImage3D(TBasicType type)
case EbtUImageBuffer: case EbtUImageBuffer:
return false; return false;
default: default:
assert(!IsImage(type)); ASSERT(!IsImage(type));
} }
return false; return false;
...@@ -840,7 +840,7 @@ inline bool IsImage2DArray(TBasicType type) ...@@ -840,7 +840,7 @@ inline bool IsImage2DArray(TBasicType type)
case EbtUImageBuffer: case EbtUImageBuffer:
return false; return false;
default: default:
assert(!IsImage(type)); ASSERT(!IsImage(type));
} }
return false; return false;
...@@ -889,7 +889,7 @@ inline bool IsImageCube(TBasicType type) ...@@ -889,7 +889,7 @@ inline bool IsImageCube(TBasicType type)
case EbtUImageBuffer: case EbtUImageBuffer:
return false; return false;
default: default:
assert(!IsImage(type)); ASSERT(!IsImage(type));
} }
return false; return false;
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#ifndef COMPILER_TRANSLATOR_CONSTANTUNION_H_ #ifndef COMPILER_TRANSLATOR_CONSTANTUNION_H_
#define COMPILER_TRANSLATOR_CONSTANTUNION_H_ #define COMPILER_TRANSLATOR_CONSTANTUNION_H_
#include <assert.h>
#include "compiler/translator/BaseTypes.h" #include "compiler/translator/BaseTypes.h"
#include "compiler/translator/Common.h" #include "compiler/translator/Common.h"
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
#include "compiler/translator/PoolAlloc.h" #include "compiler/translator/PoolAlloc.h"
#include <assert.h> #include "common/debug.h"
#include "common/tls.h" #include "common/tls.h"
TLSIndex PoolIndex = TLS_INVALID_INDEX; TLSIndex PoolIndex = TLS_INVALID_INDEX;
bool InitializePoolIndex() bool InitializePoolIndex()
{ {
assert(PoolIndex == TLS_INVALID_INDEX); ASSERT(PoolIndex == TLS_INVALID_INDEX);
PoolIndex = CreateTLSIndex(); PoolIndex = CreateTLSIndex();
return PoolIndex != TLS_INVALID_INDEX; return PoolIndex != TLS_INVALID_INDEX;
...@@ -21,7 +21,7 @@ bool InitializePoolIndex() ...@@ -21,7 +21,7 @@ bool InitializePoolIndex()
void FreePoolIndex() void FreePoolIndex()
{ {
assert(PoolIndex != TLS_INVALID_INDEX); ASSERT(PoolIndex != TLS_INVALID_INDEX);
DestroyTLSIndex(PoolIndex); DestroyTLSIndex(PoolIndex);
PoolIndex = TLS_INVALID_INDEX; PoolIndex = TLS_INVALID_INDEX;
...@@ -29,12 +29,12 @@ void FreePoolIndex() ...@@ -29,12 +29,12 @@ void FreePoolIndex()
angle::PoolAllocator *GetGlobalPoolAllocator() angle::PoolAllocator *GetGlobalPoolAllocator()
{ {
assert(PoolIndex != TLS_INVALID_INDEX); ASSERT(PoolIndex != TLS_INVALID_INDEX);
return static_cast<angle::PoolAllocator *>(GetTLSValue(PoolIndex)); return static_cast<angle::PoolAllocator *>(GetTLSValue(PoolIndex));
} }
void SetGlobalPoolAllocator(angle::PoolAllocator *poolAllocator) void SetGlobalPoolAllocator(angle::PoolAllocator *poolAllocator)
{ {
assert(PoolIndex != TLS_INVALID_INDEX); ASSERT(PoolIndex != TLS_INVALID_INDEX);
SetTLSValue(PoolIndex, poolAllocator); SetTLSValue(PoolIndex, poolAllocator);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment