Add stack protector support to clang. This generates the 'ssp' and 'sspreq'
function attributes. There are predefined macros that are defined when stack
protectors are used: __SSP__=1 with -fstack-protector and __SSP_ALL__=2 with
-fstack-protector-all.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74405 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGen/stack-protector.c b/test/CodeGen/stack-protector.c
new file mode 100644
index 0000000..bdac853
--- /dev/null
+++ b/test/CodeGen/stack-protector.c
@@ -0,0 +1,22 @@
+// RUN: clang-cc -triple i686-unknown-unknown -emit-llvm -o %t %s &&
+// RUN: not grep 'ssp' %t &&
+// RUN: clang-cc -triple i686-apple-darwin9 -emit-llvm -o %t %s &&
+// RUN: not grep 'ssp' %t &&
+// RUN: clang-cc -triple i686-apple-darwin10 -emit-llvm -o %t %s &&
+// RUN: grep 'ssp' %t &&
+// RUN: clang -fstack-protector-all -emit-llvm -S -o %t %s &&
+// RUN: grep 'sspreq' %t &&
+// RUN: clang -fstack-protector -emit-llvm -S -o %t %s &&
+// RUN: grep 'ssp' %t &&
+// RUN: clang -fno-stack-protector -emit-llvm -S -o %t %s &&
+// RUN: not grep 'ssp' %t &&
+// RUN: true
+
+#include <stdio.h>
+#include <string.h>
+
+void test1(const char *msg) {
+ char a[strlen(msg) + 1];
+ strcpy(a, msg);
+ printf("%s\n", a);
+}