Skip to content

Commit d5d981a

Browse files
svenvhAlexeySotkin
authored andcommitted
Abort on error instead of asserting 0
Let the translator abort on error instead of calling `assert(0)`. This makes the error behavior consistent across debug and release builds, and allows us to write negative tests for the translator.
1 parent fc7e390 commit d5d981a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/SPIRV/libSPIRV/SPIRVDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@
4242
using namespace SPIRV;
4343

4444
bool SPIRV::SPIRVDbgEnable = false;
45-
bool SPIRV::SPIRVDbgAssertOnError = true;
45+
bool SPIRV::SPIRVDbgAbortOnError = true;
4646
bool SPIRV::SPIRVDbgErrorMsgIncludesSourceInfo = true;

lib/SPIRV/libSPIRV/SPIRVDebug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extern bool SPIRVDbgEnable;
6363
extern bool SPIRVDbgErrorMsgIncludesSourceInfo;
6464

6565
// Enable assert on error
66-
extern bool SPIRVDbgAssertOnError;
66+
extern bool SPIRVDbgAbortOnError;
6767

6868
// Output stream for SPIRV debug information.
6969
inline spv_ostream &spvdbgs() {

lib/SPIRV/libSPIRV/SPIRVError.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ inline bool SPIRVErrorLog::checkError(bool Cond, SPIRVErrorCode ErrCode,
113113
if (SPIRVDbgErrorMsgIncludesSourceInfo)
114114
SS << " [Src: " << FileName << ":" << LineNo << " " << CondString << " ]";
115115
setError(ErrCode, SS.str());
116-
if (SPIRVDbgAssertOnError) {
116+
if (SPIRVDbgAbortOnError) {
117117
spvdbgs() << SS.str() << '\n';
118118
spvdbgs().flush();
119-
assert(0);
119+
abort();
120120
}
121121
return Cond;
122122
}

0 commit comments

Comments
 (0)