56 lines · c
1// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=DEF -check-prefix=NOSSP %s2// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=DEF -check-prefix=SSP %s3// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=DEF -check-prefix=SSPSTRONG %s4// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 3 | FileCheck -check-prefix=DEF -check-prefix=SSPREQ %s5 6// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-NOSSP %s7// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 0 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-NOSSP %s8// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 1 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSP %s9// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 2 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSPSTRONG %s10// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=safe-stack -stack-protector 3 | FileCheck -check-prefix=DEF -check-prefix=SAFESTACK-SSPREQ %s11 12typedef __SIZE_TYPE__ size_t;13 14int printf(const char * _Format, ...);15size_t strlen(const char *s);16char *strcpy(char *s1, const char *s2);17 18// DEF: define {{.*}}void @test1(ptr noundef %msg) #[[A:.*]] {19void test1(const char *msg) {20 char a[strlen(msg) + 1];21 strcpy(a, msg);22 printf("%s\n", a);23}24 25// DEF: define {{.*}}void @test2(ptr noundef %msg) #[[B:.*]] {26__attribute__((no_stack_protector))27void test2(const char *msg) {28 char a[strlen(msg) + 1];29 strcpy(a, msg);30 printf("%s\n", a);31}32 33// NOSSP-NOT: attributes #[[A]] = {{.*}} ssp34// SSP: attributes #[[A]] = {{.*}} ssp{{ }}35// SSPSTRONG: attributes #[[A]] = {{.*}} sspstrong36// SSPREQ: attributes #[[A]] = {{.*}} sspreq37 38// SAFESTACK-NOSSP: attributes #[[A]] = {{.*}} safestack39// SAFESTACK-NOSSP-NOT: ssp40 41// SAFESTACK-SSP: attributes #[[A]] = {{.*}} safestack ssp{{ }}42// SAFESTACK-SSPSTRONG: attributes #[[A]] = {{.*}} safestack sspstrong43// SAFESTACK-SSPREQ: attributes #[[A]] = {{.*}} safestack sspreq44 45// NOSSP-NOT: attributes #[[B]] = {{.*}} ssp46// SSP-NOT: attributes #[[B]] = {{.*}} ssp{{ }}47// SSPSTRONG-NOT: attributes #[[B]] = {{.*}} sspstrong48// SSPREQ-NOT: attributes #[[B]] = {{.*}} sspreq49 50// SAFESTACK-SSP: attributes #[[B]] = {{.*}} safestack51// SAFESTACK-SSP-NOT: attributes #[[B]] = {{.*}} safestack ssp{{ }}52// SAFESTACK-SSPSTRONG: attributes #[[B]] = {{.*}} safestack53// SAFESTACK-SSPSTRONG-NOT: attributes #[[B]] = {{.*}} safestack sspstrong54// SAFESTACK-SSPREQ: attributes #[[B]] = {{.*}} safestack55// SAFESTACK-SSPREQ-NOT: attributes #[[B]] = {{.*}} safestack sspreq56