aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/object-size.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGen/object-size.c')
-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");
+}