Use puts() rather than printf() for printing assertion failure strings.
This way, we don't lose '%'s in the assertion strings. Issue #342.
This commit is contained in:
@@ -2499,14 +2499,14 @@ define void @__memset64(i8 * %dst, i8 %val, i64 %len) alwaysinline {
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; assert
|
;; assert
|
||||||
|
|
||||||
declare i32 @printf(i8*, ...)
|
declare i32 @puts(i8*)
|
||||||
declare void @abort() noreturn
|
declare void @abort() noreturn
|
||||||
|
|
||||||
define void @__do_assert_uniform(i8 *%str, i1 %test, <WIDTH x MASK> %mask) {
|
define void @__do_assert_uniform(i8 *%str, i1 %test, <WIDTH x MASK> %mask) {
|
||||||
br i1 %test, label %ok, label %fail
|
br i1 %test, label %ok, label %fail
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
%call = call i32 (i8*, ...)* @printf(i8* %str)
|
%call = call i32 @puts(i8* %str)
|
||||||
call void @abort() noreturn
|
call void @abort() noreturn
|
||||||
unreachable
|
unreachable
|
||||||
|
|
||||||
@@ -2525,7 +2525,7 @@ define void @__do_assert_varying(i8 *%str, <WIDTH x MASK> %test,
|
|||||||
br i1 %all_ok, label %ok, label %fail
|
br i1 %all_ok, label %ok, label %fail
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
%call = call i32 (i8*, ...)* @printf(i8* %str)
|
%call = call i32 @puts(i8* %str)
|
||||||
call void @abort() noreturn
|
call void @abort() noreturn
|
||||||
unreachable
|
unreachable
|
||||||
|
|
||||||
|
|||||||
4
stmt.cpp
4
stmt.cpp
@@ -3142,14 +3142,14 @@ AssertStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
bool isUniform = type->IsUniformType();
|
bool isUniform = type->IsUniformType();
|
||||||
|
|
||||||
// The actual functionality to do the check and then handle falure is
|
// The actual functionality to do the check and then handle falure is
|
||||||
// done via a builtin written in bitcode in builtins.m4.
|
// done via a builtin written in bitcode in builtins/util.m4.
|
||||||
llvm::Function *assertFunc =
|
llvm::Function *assertFunc =
|
||||||
isUniform ? m->module->getFunction("__do_assert_uniform") :
|
isUniform ? m->module->getFunction("__do_assert_uniform") :
|
||||||
m->module->getFunction("__do_assert_varying");
|
m->module->getFunction("__do_assert_varying");
|
||||||
AssertPos(pos, assertFunc != NULL);
|
AssertPos(pos, assertFunc != NULL);
|
||||||
|
|
||||||
char *errorString;
|
char *errorString;
|
||||||
if (asprintf(&errorString, "%s:%d:%d: Assertion failed: %s\n",
|
if (asprintf(&errorString, "%s:%d:%d: Assertion failed: %s",
|
||||||
pos.name, pos.first_line, pos.first_column,
|
pos.name, pos.first_line, pos.first_column,
|
||||||
message.c_str()) == -1) {
|
message.c_str()) == -1) {
|
||||||
Error(pos, "Fatal error when generating assert string: asprintf() "
|
Error(pos, "Fatal error when generating assert string: asprintf() "
|
||||||
|
|||||||
Reference in New Issue
Block a user