Commit 873d00f4 by Jamie Madill Committed by Commit Bot

Change UNREACHABLE to use ASSERT.

The ASSERT macro is enabled with ANGLE_RELEASE_ASSERT, so we should use the same behaviour as the normal ASSERT for the other debug macros. Also remove UNREACHABLEs in the format validation code that were being hit silently. Also make some EGL tests skip instead of fail, since they were hitting UNIMPLEMENTED. BUG=angleproject:1332 BUG=angleproject:1540 BUG=angleproject:1340 Change-Id: Ie3347f2bf2459a5831b66827871998d8fbe7d4b2 Reviewed-on: https://chromium-review.googlesource.com/392490Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent d569619d
...@@ -104,24 +104,25 @@ bool DebugAnnotationsActive(); ...@@ -104,24 +104,25 @@ bool DebugAnnotationsActive();
#undef ANGLE_TRACE_ENABLED #undef ANGLE_TRACE_ENABLED
#endif #endif
#if defined(COMPILER_GCC) || __clang__
#define ANGLE_CRASH() __builtin_trap()
#else
#define ANGLE_CRASH() ((void)(*(volatile char *)0 = 0))
#endif
#if !defined(NDEBUG) #if !defined(NDEBUG)
#define ANGLE_ASSERT_IMPL(expression) assert(expression) #define ANGLE_ASSERT_IMPL(expression) assert(expression)
#else #else
// TODO(jmadill): Detect if debugger is attached and break. // TODO(jmadill): Detect if debugger is attached and break.
#define ANGLE_ASSERT_IMPL(expression) abort() #define ANGLE_ASSERT_IMPL(expression) ANGLE_CRASH()
#endif // !defined(NDEBUG) #endif // !defined(NDEBUG)
// A macro asserting a condition and outputting failures to the debug log // A macro asserting a condition and outputting failures to the debug log
#if defined(ANGLE_ENABLE_ASSERTS) #if defined(ANGLE_ENABLE_ASSERTS)
#define ASSERT(expression) \ #define ASSERT(expression) \
{ \ (expression ? static_cast<void>(0) \
if (!(expression)) \ : (ERR("\t! Assert failed in %s(%d): %s\n", __FUNCTION__, __LINE__, #expression), \
{ \ ANGLE_ASSERT_IMPL(expression)))
ERR("\t! Assert failed in %s(%d): %s\n", __FUNCTION__, __LINE__, #expression); \
ANGLE_ASSERT_IMPL(expression); \
} \
} \
ANGLE_EMPTY_STATEMENT
#define UNUSED_ASSERTION_VARIABLE(variable) #define UNUSED_ASSERTION_VARIABLE(variable)
#else #else
#define ASSERT(expression) (void(0)) #define ASSERT(expression) (void(0))
...@@ -136,27 +137,20 @@ bool DebugAnnotationsActive(); ...@@ -136,27 +137,20 @@ bool DebugAnnotationsActive();
#define NOASSERT_UNIMPLEMENTED 1 #define NOASSERT_UNIMPLEMENTED 1
#endif #endif
// Define NOASSERT_UNIMPLEMENTED to non zero to skip the assert fail in the unimplemented checks
// This will allow us to test with some automated test suites (eg dEQP) without crashing // This will allow us to test with some automated test suites (eg dEQP) without crashing
#ifndef NOASSERT_UNIMPLEMENTED #ifndef NOASSERT_UNIMPLEMENTED
#define NOASSERT_UNIMPLEMENTED 0 #define NOASSERT_UNIMPLEMENTED 0
#endif #endif
#if !defined(NDEBUG) #define UNIMPLEMENTED() \
#define UNIMPLEMENTED() { \ { \
FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \ FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); \
assert(NOASSERT_UNIMPLEMENTED); \ ASSERT(NOASSERT_UNIMPLEMENTED); \
} ANGLE_EMPTY_STATEMENT } \
#else ANGLE_EMPTY_STATEMENT
#define UNIMPLEMENTED() FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
#endif
// A macro for code which is not expected to be reached under valid assumptions // A macro for code which is not expected to be reached under valid assumptions
#if !defined(NDEBUG)
#define UNREACHABLE() \ #define UNREACHABLE() \
ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__), assert(false) (ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__), ASSERT(false))
#else
#define UNREACHABLE() ERR("\t! Unreachable reached: %s(%d)\n", __FUNCTION__, __LINE__)
#endif
#endif // COMMON_DEBUG_H_ #endif // COMMON_DEBUG_H_
...@@ -367,7 +367,6 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type) ...@@ -367,7 +367,6 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type)
break; break;
} }
UNREACHABLE();
return GL_NONE; return GL_NONE;
} }
......
...@@ -705,7 +705,6 @@ const InternalFormat &GetInternalFormatInfo(GLenum internalFormat) ...@@ -705,7 +705,6 @@ const InternalFormat &GetInternalFormatInfo(GLenum internalFormat)
else else
{ {
static const InternalFormat defaultInternalFormat; static const InternalFormat defaultInternalFormat;
UNREACHABLE();
return defaultInternalFormat; return defaultInternalFormat;
} }
} }
......
...@@ -40,7 +40,6 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type) ...@@ -40,7 +40,6 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type)
break; break;
}} }}
UNREACHABLE();
return GL_NONE; return GL_NONE;
}} }}
......
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