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:
Matt Pharr
2012-08-03 11:31:38 -07:00
parent 19d8f2e258
commit 765a0d8896
2 changed files with 5 additions and 5 deletions

View File

@@ -2499,14 +2499,14 @@ define void @__memset64(i8 * %dst, i8 %val, i64 %len) alwaysinline {
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; assert
declare i32 @printf(i8*, ...)
declare i32 @puts(i8*)
declare void @abort() noreturn
define void @__do_assert_uniform(i8 *%str, i1 %test, <WIDTH x MASK> %mask) {
br i1 %test, label %ok, label %fail
fail:
%call = call i32 (i8*, ...)* @printf(i8* %str)
%call = call i32 @puts(i8* %str)
call void @abort() noreturn
unreachable
@@ -2525,7 +2525,7 @@ define void @__do_assert_varying(i8 *%str, <WIDTH x MASK> %test,
br i1 %all_ok, label %ok, label %fail
fail:
%call = call i32 (i8*, ...)* @printf(i8* %str)
%call = call i32 @puts(i8* %str)
call void @abort() noreturn
unreachable

View File

@@ -3142,14 +3142,14 @@ AssertStmt::EmitCode(FunctionEmitContext *ctx) const {
bool isUniform = type->IsUniformType();
// 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 =
isUniform ? m->module->getFunction("__do_assert_uniform") :
m->module->getFunction("__do_assert_varying");
AssertPos(pos, assertFunc != NULL);
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,
message.c_str()) == -1) {
Error(pos, "Fatal error when generating assert string: asprintf() "