[PATCH] D22894: [asan] Enable the rest of use-after-scope tests

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 17:25:51 PDT 2016


vitalybuka created this revision.
vitalybuka added reviewers: eugenis, kcc.
vitalybuka added a subscriber: llvm-commits.
Herald added a subscriber: kubabrecka.

Test where broken because of missing lifetime markers for temps and
because of aggressive optimization which removed markers in some cases.

PR27453

https://reviews.llvm.org/D22894

Files:
  test/asan/TestCases/use-after-scope-loop-bug.cc
  test/asan/TestCases/use-after-scope-loop-removed.cc
  test/asan/TestCases/use-after-scope-temp.cc

Index: test/asan/TestCases/use-after-scope-temp.cc
===================================================================
--- test/asan/TestCases/use-after-scope-temp.cc
+++ test/asan/TestCases/use-after-scope-temp.cc
@@ -1,8 +1,6 @@
-// RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
+// RUN: %clangxx_asan %stdcxx11 -O1 -fsanitize-address-use-after-scope %s -o %t && \
 // RUN:     not %run %t 2>&1 | FileCheck %s
-//
-// Lifetime for temporaries is not emitted yet.
-// XFAIL: *
+
 
 struct IntHolder {
   int val;
@@ -15,9 +13,9 @@
 }
 
 int main(int argc, char *argv[]) {
-  save({10});
+  save({argc});
   int x = saved->val;  // BOOM
-// CHECK: ERROR: AddressSanitizer: stack-use-after-scope
-// CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-temp.cc:[[@LINE-2]]
+  // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
+  // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-temp.cc:[[@LINE-2]]
   return x;
 }
Index: test/asan/TestCases/use-after-scope-loop-removed.cc
===================================================================
--- test/asan/TestCases/use-after-scope-loop-removed.cc
+++ test/asan/TestCases/use-after-scope-loop-removed.cc
@@ -1,9 +1,5 @@
 // RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
 // RUN:     not %run %t 2>&1 | FileCheck %s
-//
-// FIXME: Compiler removes for-loop but keeps x variable. For unknown reason
-// @llvm.lifetime.* are not emitted for x.
-// XFAIL: *
 
 #include <stdlib.h>
 
@@ -14,6 +10,9 @@
     int x;
     p = &x;
   }
-  return **p;  // BOOM
+  return *p;  // BOOM
   // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
+  // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-loop-removed.cc:[[@LINE-2]]
+  // CHECK: Address 0x{{.*}} is located in stack of thread T{{.*}} at offset [[OFFSET:[^ ]+]] in frame
+  // {{\[}}[[OFFSET]], {{[0-9]+}}) 'x'
 }
Index: test/asan/TestCases/use-after-scope-loop-bug.cc
===================================================================
--- test/asan/TestCases/use-after-scope-loop-bug.cc
+++ test/asan/TestCases/use-after-scope-loop-bug.cc
@@ -1,8 +1,5 @@
 // RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
 // RUN:     not %run %t 2>&1 | FileCheck %s
-//
-// FIXME: @llvm.lifetime.* are not emitted for x.
-// XFAIL: *
 
 int *p;
 
@@ -13,4 +10,8 @@
     p = x + i;
   }
   return *p;  // BOOM
+  // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
+  // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-loop-bug.cc:[[@LINE-2]]
+  // CHECK: Address 0x{{.*}} is located in stack of thread T{{.*}} at offset [[OFFSET:[^ ]+]] in frame
+  // {{\[}}[[OFFSET]], {{[0-9]+}}) 'x'
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22894.65846.patch
Type: text/x-patch
Size: 2667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160728/3629fc05/attachment.bin>


More information about the llvm-commits mailing list