summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/sanitize-use-after-scope.c
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-04-02 13:19:46 +0000
committerAlexey Samsonov <samsonov@google.com>2013-04-02 13:19:46 +0000
commit262f05bab07bde0d59e2a19493d8ffc86cddd37c (patch)
tree5e059a8635c549e297c3797b040e72be381969da /clang/test/CodeGen/sanitize-use-after-scope.c
parentb5dad75e38d449a1421d5f14ccf55857fe5599fe (diff)
downloadbcm5719-llvm-262f05bab07bde0d59e2a19493d8ffc86cddd37c.tar.gz
bcm5719-llvm-262f05bab07bde0d59e2a19493d8ffc86cddd37c.zip
[ASan] Emit lifetime markers for local variables in -fsanitize=use-after-scope mode
llvm-svn: 178538
Diffstat (limited to 'clang/test/CodeGen/sanitize-use-after-scope.c')
-rw-r--r--clang/test/CodeGen/sanitize-use-after-scope.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/CodeGen/sanitize-use-after-scope.c b/clang/test/CodeGen/sanitize-use-after-scope.c
new file mode 100644
index 00000000000..8f920385bc2
--- /dev/null
+++ b/clang/test/CodeGen/sanitize-use-after-scope.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - -fsanitize=address,use-after-scope %s \
+// RUN: | FileCheck %s -check-prefix=USE-AFTER-SCOPE
+// RUN: %clang_cc1 -S -emit-llvm -o - -fsanitize=address %s \
+// RUN: | FileCheck %s -check-prefix=ADDRESS-ONLY
+
+extern int bar(char *A, int n);
+
+// ADDRESS-ONLY-NOT: @llvm.lifetime.start
+int foo (int n) {
+ if (n) {
+ // USE-AFTER-SCOPE: @llvm.lifetime.start(i64 10, i8* {{.*}})
+ char A[10];
+ return bar(A, 1);
+ // USE-AFTER-SCOPE: @llvm.lifetime.end(i64 10, i8* {{.*}})
+ } else {
+ // USE-AFTER-SCOPE: @llvm.lifetime.start(i64 20, i8* {{.*}})
+ char A[20];
+ return bar(A, 2);
+ // USE-AFTER-SCOPE: @llvm.lifetime.end(i64 20, i8* {{.*}})
+ }
+}
+
OpenPOWER on IntegriCloud