From 5ee902bb5f3a843230f45dcd7b8101de71da7c83 Mon Sep 17 00:00:00 2001 From: Jinsong Ji Date: Wed, 27 May 2020 03:39:59 +0000 Subject: [PATCH] [compiler-rt][asan] Add noinline to use-after-scope testcases Some testcases are unexpectedly passing with NPM. This is because the target functions are inlined in NPM. I think we should add noinline attribute to keep these test points. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D79648 --- compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp | 2 +- compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp | 2 +- compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp index 8d4f772..43c1710 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp @@ -5,7 +5,7 @@ struct IntHolder { explicit IntHolder(int *val = 0) : val_(val) { } - ~IntHolder() { + __attribute__((noinline)) ~IntHolder() { printf("Value: %d\n", *val_); // BOOM // CHECK: ERROR: AddressSanitizer: stack-use-after-scope // CHECK: #0 0x{{.*}} in IntHolder::~IntHolder{{.*}}.cpp:[[@LINE-2]] diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp index b97f312..2cfc7ce 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp @@ -8,7 +8,7 @@ struct IntHolder { const IntHolder *saved; -void save(const IntHolder &holder) { +__attribute__((noinline)) void save(const IntHolder &holder) { saved = &holder; } diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp b/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp index 99e4f25..3e6f52a 100644 --- a/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp @@ -3,7 +3,7 @@ struct IntHolder { - const IntHolder& Self() const { + __attribute__((noinline)) const IntHolder &Self() const { return *this; } int val = 3; -- 2.7.4