From 10bd7e1c5b355a193a59e3b3fdfe632f4d977c52 Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Mon, 26 Oct 2009 21:38:39 +0000 Subject: __builtin_object_size refinements. When we run out of object, be sure to clamp at 0 bytes left. WIP. llvm-svn: 85157 --- clang/test/CodeGen/object-size.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'clang/test/CodeGen/object-size.c') diff --git a/clang/test/CodeGen/object-size.c b/clang/test/CodeGen/object-size.c index b6861169893..36dc341e932 100644 --- a/clang/test/CodeGen/object-size.c +++ b/clang/test/CodeGen/object-size.c @@ -21,13 +21,29 @@ void test2() { strcpy(gbuf, "Hi there"); } +void test3() { + // CHECK: movabsq $0, %rdx + // CHECK-NEXT: movq %rax, %rdi + // CHECK-NEXT: movq %rcx, %rsi + // CHECK-NEXT: call ___strcpy_chk + strcpy(&gbuf[100], "Hi there"); +} + void test4() { + // CHECK: movabsq $0, %rdx + // CHECK-NEXT: movq %rax, %rdi + // CHECK-NEXT: movq %rcx, %rsi + // CHECK-NEXT: call ___strcpy_chk + strcpy((char*)(void*)&gbuf[-1], "Hi there"); +} + +void test5() { // CHECK: call ___inline_strcpy_chk - strcpy(gp, "Hi"); + strcpy(gp, "Hi there"); } -void test3() { +void test6() { int i; // CHECK: call ___inline_strcpy_chk - strcpy((++i, gbuf), "Hi"); + strcpy((++i, gbuf), "Hi there"); } -- cgit v1.2.3