[compiler-rt] r277074 - [asan] Enable the rest of use-after-scope tests

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 16:03:27 PDT 2016


Author: vitalybuka
Date: Thu Jul 28 18:03:27 2016
New Revision: 277074

URL: http://llvm.org/viewvc/llvm-project?rev=277074&view=rev
Log:
[asan] Enable the rest of use-after-scope tests

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

PR27453

Reviewers: eugenis, kcc

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D22894

Modified:
    compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-bug.cc
    compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-removed.cc
    compiler-rt/trunk/test/asan/TestCases/use-after-scope-temp.cc

Modified: compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-bug.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-bug.cc?rev=277074&r1=277073&r2=277074&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-bug.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-bug.cc Thu Jul 28 18:03:27 2016
@@ -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 @@ int main() {
     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'
 }

Modified: compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-removed.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-removed.cc?rev=277074&r1=277073&r2=277074&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-removed.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/use-after-scope-loop-removed.cc Thu Jul 28 18:03:27 2016
@@ -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 main() {
     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'
 }

Modified: compiler-rt/trunk/test/asan/TestCases/use-after-scope-temp.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/use-after-scope-temp.cc?rev=277074&r1=277073&r2=277074&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/use-after-scope-temp.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/use-after-scope-temp.cc Thu Jul 28 18:03:27 2016
@@ -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 @@ void save(const IntHolder &holder) {
 }
 
 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;
 }




More information about the llvm-commits mailing list