stack-protector.c revision f7a9da053f5bd6c18450c1796d953b42c3b7ad3a
1// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=NOSSP %s
2// NOSSP: define void @test1(i8* %msg) #0 {
3// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=WITHSSP %s
4// WITHSSP: define void @test1(i8* %msg) #0 {
5// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=SSPREQ %s
6// SSPREQ: define void @test1(i8* %msg) #0 {
7
8typedef __SIZE_TYPE__ size_t;
9
10int printf(const char * _Format, ...);
11size_t strlen(const char *s);
12char *strcpy(char *s1, const char *s2);
13
14void test1(const char *msg) {
15  char a[strlen(msg) + 1];
16  strcpy(a, msg);
17  printf("%s\n", a);
18}
19
20// NOSSP: attributes #0 = { nounwind "target-features"={{.*}} }
21// NOSSP: attributes #1 = { "target-features"={{.*}} }
22// NOSSP: attributes #2 = { nounwind }
23
24// WITHSSP: attributes #0 = { nounwind ssp "target-features"={{.*}} }
25// WITHSSP: attributes #1 = { "target-features"={{.*}} }
26// WITHSSP: attributes #2 = { nounwind }
27
28// SSPREQ: attributes #0 = { nounwind sspreq "target-features"={{.*}} }
29// SSPREQ: attributes #1 = { "target-features"={{.*}} }
30// SSPREQ: attributes #2 = { nounwind }
31