stack-protector.c revision 97e948e9c9cc2db9f0cdc13e708fe1bd8c6d05a2
1// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=NOSSP %s
2// NOSSP: define void @test1(i8* %msg) nounwind {{.*}}{
3// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=WITHSSP %s
4// WITHSSP: define void @test1(i8* %msg) nounwind ssp {{.*}}{
5// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=SSPREQ %s
6// SSPREQ: define void @test1(i8* %msg) nounwind sspreq {{.*}}{
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