aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-10-26 18:35:08 +0000
committerMike Stump <mrs@apple.com>2009-10-26 18:35:08 +0000
commit64eda9e50b593f935c95bd1edc98c4bfda03f601 (patch)
tree06421766987aafc8d11fc2554268d4531b1732a1 /test/CodeGen
parenta98c0348f6bbc0d3c473f8d1e46d15493324f0e5 (diff)
__builtin_object_size refinements. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r--test/CodeGen/object-size.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/CodeGen/object-size.c b/test/CodeGen/object-size.c
new file mode 100644
index 0000000000..b686116989
--- /dev/null
+++ b/test/CodeGen/object-size.c
@@ -0,0 +1,33 @@
+// RUN: clang-cc -triple x86_64-apple-darwin -S -D_FORTIFY_SOURCE=2 %s -o %t.s &&
+// RUN: FileCheck --input-file=%t.s %s
+#include <string.h>
+
+char gbuf[63];
+char *gp;
+
+void test1() {
+ // CHECK: movabsq $59, %rdx
+ // CHECK-NEXT: movq %rax, %rdi
+ // CHECK-NEXT: movq %rcx, %rsi
+ // CHECK-NEXT: call ___strcpy_chk
+ strcpy(&gbuf[4], "Hi there");
+}
+
+void test2() {
+ // CHECK: movabsq $63, %rdx
+ // CHECK-NEXT: movq %rax, %rdi
+ // CHECK-NEXT: movq %rcx, %rsi
+ // CHECK-NEXT: call ___strcpy_chk
+ strcpy(gbuf, "Hi there");
+}
+
+void test4() {
+ // CHECK: call ___inline_strcpy_chk
+ strcpy(gp, "Hi");
+}
+
+void test3() {
+ int i;
+ // CHECK: call ___inline_strcpy_chk
+ strcpy((++i, gbuf), "Hi");
+}