[compiler-rt] 0f7e3a5 - [NFC][scudo] Simplify UseQuarantine initialization

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 1 12:57:12 PDT 2021


Author: Vitaly Buka
Date: 2021-04-01T12:57:07-07:00
New Revision: 0f7e3a55463d2ed9abc60c6fd0126bcb19fc6d69

URL: https://github.com/llvm/llvm-project/commit/0f7e3a55463d2ed9abc60c6fd0126bcb19fc6d69
DIFF: https://github.com/llvm/llvm-project/commit/0f7e3a55463d2ed9abc60c6fd0126bcb19fc6d69.diff

LOG: [NFC][scudo] Simplify UseQuarantine initialization

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/tests/combined_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
index a6c6d828cf647..703d9e12bdcaf 100644
--- a/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
@@ -24,6 +24,11 @@ static bool Ready;
 
 static constexpr scudo::Chunk::Origin Origin = scudo::Chunk::Origin::Malloc;
 
+template <class Config> struct UseQuarantineSetter {
+  UseQuarantineSetter(bool Value) { UseQuarantine = Value; }
+  ~UseQuarantineSetter() { UseQuarantine = true; }
+};
+
 // Fuchsia complains that the function is not used.
 UNUSED static void disableDebuggerdMaybe() {
 #if SCUDO_ANDROID
@@ -80,6 +85,8 @@ template <typename Config> struct TestAllocator : scudo::Allocator<Config> {
 };
 
 template <class Config> static void testAllocator() {
+  UseQuarantineSetter<Config> MUQ(
+      std::is_same<Config, scudo::AndroidConfig>::value);
   using AllocatorT = TestAllocator<Config>;
   auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());
 
@@ -318,13 +325,11 @@ void testSEGV() {
 }
 
 TEST(ScudoCombinedTest, BasicCombined) {
-  UseQuarantine = false;
   testAllocator<scudo::AndroidSvelteConfig>();
 #if SCUDO_FUCHSIA
   testAllocator<scudo::FuchsiaConfig>();
 #else
   testAllocator<scudo::DefaultConfig>();
-  UseQuarantine = true;
   testAllocator<scudo::AndroidConfig>();
   testSEGV();
 #endif
@@ -369,13 +374,11 @@ template <class Config> static void testAllocatorThreaded() {
 }
 
 TEST(ScudoCombinedTest, ThreadedCombined) {
-  UseQuarantine = false;
   testAllocatorThreaded<scudo::AndroidSvelteConfig>();
 #if SCUDO_FUCHSIA
   testAllocatorThreaded<scudo::FuchsiaConfig>();
 #else
   testAllocatorThreaded<scudo::DefaultConfig>();
-  UseQuarantine = true;
   testAllocatorThreaded<scudo::AndroidConfig>();
 #endif
 }


        


More information about the llvm-commits mailing list