• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=DEF -check-prefix=NOSSP %s
2 // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=DEF -check-prefix=SSP %s
3 // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=DEF -check-prefix=SSPSTRONG %s
4 // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 3 | FileCheck -check-prefix=DEF -check-prefix=SSPREQ %s
5 
6 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-NOSSP %s
7 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 0 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-NOSSP %s
8 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 1 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSP %s
9 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 2 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSPSTRONG %s
10 // RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 3 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSPREQ %s
11 
12 typedef __SIZE_TYPE__ size_t;
13 
14 int printf(const char * _Format, ...);
15 size_t strlen(const char *s);
16 char *strcpy(char *s1, const char *s2);
17 
18 // DEF: define {{.*}}void @test1(i8* %msg) #[[A:.*]] {
test1(const char * msg)19 void test1(const char *msg) {
20   char a[strlen(msg) + 1];
21   strcpy(a, msg);
22   printf("%s\n", a);
23 }
24 
25 // NOSSP-NOT: attributes #[[A]] = {{.*}} ssp
26 // SSP: attributes #[[A]] = {{.*}} ssp{{ }}
27 // SSPSTRONG: attributes #[[A]] = {{.*}} sspstrong
28 // SSPREQ: attributes #[[A]] = {{.*}} sspreq
29 
30 // SAFESTACK-NOSSP: attributes #[[A]] = {{.*}} safestack
31 // SAFESTACK-NOSSP-NOT: ssp
32 
33 // SAFESTACK-SSP: attributes #[[A]] = {{.*}} safestack ssp{{ }}
34 // SAFESTACK-SSPSTRONG: attributes #[[A]] = {{.*}} safestack sspstrong
35 // SAFESTACK-SSPREQ: attributes #[[A]] = {{.*}} safestack sspreq
36