mboehme created this revision.
Herald added a subscriber: thopre.
Herald added a project: All.
mboehme requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

We have recently started seeing deadlocks in death tests while running in an
internal test environment.

Per the documentation here, there are issues with death tests in the presence of
threads:

https://github.com/google/googletest/blob/main/docs/advanced.md#death-tests-and-threads

To avoid the deadlocks, I first tried appending `DeathTest` to the relevant
test suite names, which has the effect of running these test suites before all
other tests. However, this did not prevent the deadlocks.

This patch therefore uses the option of setting the `death_test_style` flag to
`"threadsafe"` (see description in the page linked above under "Death Test
Styles"), and this prevents the deadlocks.

As the page linked above notes, "flags are saved before each test and restored
afterwards", so the flag affects only the tests where it is set. This is
important because the "threadsafe" death test style "trades increased test
execution time (potentially dramatically so) for improved thread safety", so we
likely don't want to set it for all tests. The tests where I've added the flag
don't appear to suffer a significantly increated execution time.

This patch changes a number of unit tests across LLVM and Clang. As this patch
fixes a test infrastructure issue and doesn't affect the behavior of the tests
themselves, it seemed appropriate to change all death tests in a single patch.
However, if reviewers would prefer me to split this up into separate patches
form LLVM and Clang, I'm happy to do that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152696

Files:
  clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
  clang/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
  clang/unittests/Basic/FileManagerTest.cpp
  clang/unittests/Basic/LineOffsetMappingTest.cpp
  clang/unittests/Basic/SarifTest.cpp
  clang/unittests/Lex/LexerTest.cpp
  clang/unittests/Serialization/InMemoryModuleCacheTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp
  llvm/unittests/ADT/APFloatTest.cpp
  llvm/unittests/ADT/APIntTest.cpp
  llvm/unittests/ADT/APSIntTest.cpp
  llvm/unittests/ADT/AnyTest.cpp
  llvm/unittests/ADT/BumpPtrListTest.cpp
  llvm/unittests/ADT/IteratorTest.cpp
  llvm/unittests/ADT/STLExtrasTest.cpp
  llvm/unittests/ADT/SequenceTest.cpp
  llvm/unittests/ADT/SmallVectorTest.cpp
  llvm/unittests/AsmParser/AsmParserTest.cpp
  llvm/unittests/BinaryFormat/MsgPackWriterTest.cpp
  llvm/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp
  llvm/unittests/CodeGen/LowLevelTypeTest.cpp
  llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp
  llvm/unittests/FileCheck/FileCheckTest.cpp
  llvm/unittests/IR/ConstantsTest.cpp
  llvm/unittests/IR/MetadataTest.cpp
  llvm/unittests/IR/ValueHandleTest.cpp
  llvm/unittests/IR/ValueTest.cpp
  llvm/unittests/Support/DataExtractorTest.cpp
  llvm/unittests/Support/ErrorTest.cpp
  llvm/unittests/Support/Path.cpp
  llvm/unittests/Support/YAMLIOTest.cpp
  llvm/unittests/Support/raw_pwrite_stream_test.cpp
  llvm/unittests/Transforms/Utils/ValueMapperTest.cpp

Index: llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
===================================================================
--- llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
+++ llvm/unittests/Transforms/Utils/ValueMapperTest.cpp
@@ -265,6 +265,8 @@
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
 TEST(ValueMapperTest, mapMetadataLocalAsMetadata) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   LLVMContext C;
   FunctionType *FTy =
       FunctionType::get(Type::getVoidTy(C), Type::getInt8Ty(C), false);
Index: llvm/unittests/Support/raw_pwrite_stream_test.cpp
===================================================================
--- llvm/unittests/Support/raw_pwrite_stream_test.cpp
+++ llvm/unittests/Support/raw_pwrite_stream_test.cpp
@@ -38,6 +38,8 @@
 
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(OS.pwrite("12345", 5, 0),
                "We don't support extending the stream");
 #endif
@@ -74,6 +76,8 @@
 
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(OS.pwrite("12345", 5, 0),
                "We don't support extending the stream");
 #endif
Index: llvm/unittests/Support/YAMLIOTest.cpp
===================================================================
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -3064,6 +3064,8 @@
   Output yout(ostr);
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(yout << node, "plain scalar documents are not supported");
 #endif
 #endif
Index: llvm/unittests/Support/Path.cpp
===================================================================
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1429,6 +1429,8 @@
     MaybeMFR = std::move(mfr);
     EXPECT_FALSE(mfr);
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+    testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
     EXPECT_DEATH(mfr.data(), "Mapping failed but used anyway!");
     EXPECT_DEATH(mfr.size(), "Mapping failed but used anyway!");
 #endif
Index: llvm/unittests/Support/ErrorTest.cpp
===================================================================
--- llvm/unittests/Support/ErrorTest.cpp
+++ llvm/unittests/Support/ErrorTest.cpp
@@ -923,6 +923,8 @@
 
 TEST(Error, FileErrorTest) {
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+    testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
     EXPECT_DEATH(
       {
         Error S = Error::success();
Index: llvm/unittests/Support/DataExtractorTest.cpp
===================================================================
--- llvm/unittests/Support/DataExtractorTest.cpp
+++ llvm/unittests/Support/DataExtractorTest.cpp
@@ -229,6 +229,8 @@
 #if defined(GTEST_HAS_DEATH_TEST) && defined(_DEBUG) &&                        \
     LLVM_ENABLE_ABI_BREAKING_CHECKS
 TEST(DataExtractorDeathTest, Cursor) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   DataExtractor DE(StringRef("AB"), false, 8);
 
   // Even an unused cursor must be checked for errors:
Index: llvm/unittests/IR/ValueTest.cpp
===================================================================
--- llvm/unittests/IR/ValueTest.cpp
+++ llvm/unittests/IR/ValueTest.cpp
@@ -95,6 +95,8 @@
 #ifndef NDEBUG
 
 TEST(GlobalTest, AlignDeath) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   LLVMContext Ctx;
   std::unique_ptr<Module> M(new Module("TestModule", Ctx));
   Type *Int32Ty = Type::getInt32Ty(Ctx);
Index: llvm/unittests/IR/ValueHandleTest.cpp
===================================================================
--- llvm/unittests/IR/ValueHandleTest.cpp
+++ llvm/unittests/IR/ValueHandleTest.cpp
@@ -191,6 +191,8 @@
 #ifdef GTEST_HAS_DEATH_TEST
 
 TEST_F(ValueHandle, AssertingVH_Asserts) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   AssertingVH<Value> AVH(BitcastV.get());
   EXPECT_DEATH({BitcastV.reset();},
                "An asserting value handle still pointed to this value!");
@@ -533,6 +535,8 @@
 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
 
 TEST_F(ValueHandle, PoisoningVH_Asserts) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   PoisoningVH<Value> VH(BitcastV.get());
 
   // The poisoned handle shouldn't assert when the value is deleted.
@@ -553,6 +557,8 @@
 #endif // LLVM_ENABLE_ABI_BREAKING_CHECKS
 
 TEST_F(ValueHandle, TrackingVH_Asserts) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   {
     TrackingVH<Value> VH(BitcastV.get());
 
Index: llvm/unittests/IR/MetadataTest.cpp
===================================================================
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -4036,6 +4036,8 @@
 // leading to infinite loops.
 #if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG) && !defined(GTEST_HAS_SEH)
 TEST_F(DistinctMDOperandPlaceholderTest, MetadataAsValue) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // This shouldn't crash.
   DistinctMDOperandPlaceholder PH(7);
   EXPECT_DEATH(MetadataAsValue::get(Context, &PH),
@@ -4043,12 +4045,16 @@
 }
 
 TEST_F(DistinctMDOperandPlaceholderTest, UniquedMDNode) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // This shouldn't crash.
   DistinctMDOperandPlaceholder PH(7);
   EXPECT_DEATH(MDTuple::get(Context, &PH), "Unexpected callback to owner");
 }
 
 TEST_F(DistinctMDOperandPlaceholderTest, SecondDistinctMDNode) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // This shouldn't crash.
   DistinctMDOperandPlaceholder PH(7);
   MDTuple::getDistinct(Context, &PH);
@@ -4057,6 +4063,8 @@
 }
 
 TEST_F(DistinctMDOperandPlaceholderTest, TrackingMDRefAndDistinctMDNode) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // TrackingMDRef doesn't install an owner callback, so it can't be detected
   // as an invalid use.  However, using a placeholder in a TrackingMDRef *and*
   // a distinct node isn't possible and we should assert.
@@ -4249,6 +4257,8 @@
 #if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG) && !defined(GTEST_HAS_SEH)
 typedef MetadataTest MDTupleAllocationDeathTest;
 TEST_F(MDTupleAllocationDeathTest, ResizeRejected) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   MDTuple *A = MDTuple::get(Context, None);
   auto *Value1 = getConstantAsMetadata();
   EXPECT_DEATH(A->push_back(Value1),
Index: llvm/unittests/IR/ConstantsTest.cpp
===================================================================
--- llvm/unittests/IR/ConstantsTest.cpp
+++ llvm/unittests/IR/ConstantsTest.cpp
@@ -300,6 +300,8 @@
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
 TEST(ConstantsTest, ReplaceWithConstantTest) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   LLVMContext Context;
   std::unique_ptr<Module> M(new Module("MyModule", Context));
 
Index: llvm/unittests/FileCheck/FileCheckTest.cpp
===================================================================
--- llvm/unittests/FileCheck/FileCheckTest.cpp
+++ llvm/unittests/FileCheck/FileCheckTest.cpp
@@ -1647,6 +1647,8 @@
   ASSERT_THAT_ERROR(std::move(Res.TheError), Succeeded());
 
 #ifndef NDEBUG
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // Recreating @LINE pseudo numeric variable fails.
   EXPECT_DEATH(Cxt.createLineVariable(),
                "@LINE pseudo numeric variable already created");
Index: llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp
===================================================================
--- llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp
+++ llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp
@@ -29,6 +29,8 @@
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
 TEST(MachineInstrBundleIteratorTest, CheckForBundles) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   MyBundledInstr MBI;
   auto I = MBI.getIterator();
   auto RI = I.getReverse();
Index: llvm/unittests/CodeGen/LowLevelTypeTest.cpp
===================================================================
--- llvm/unittests/CodeGen/LowLevelTypeTest.cpp
+++ llvm/unittests/CodeGen/LowLevelTypeTest.cpp
@@ -222,6 +222,8 @@
 
 // Invalid to directly change the element size for pointers.
 TEST(LowLevelTypeTest, ChangeElementTypeDeath) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   const LLT P0 = LLT::pointer(0, 32);
   const LLT V2P0 = LLT::fixed_vector(2, P0);
 
Index: llvm/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp
===================================================================
--- llvm/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp
+++ llvm/unittests/CodeGen/GlobalISel/MachineIRBuilderTest.cpp
@@ -41,6 +41,8 @@
 #ifndef NDEBUG
 
 TEST_F(AArch64GISelMITest, TestBuildConstantFConstantDeath) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   setUp();
   if (!TM)
     GTEST_SKIP();
Index: llvm/unittests/BinaryFormat/MsgPackWriterTest.cpp
===================================================================
--- llvm/unittests/BinaryFormat/MsgPackWriterTest.cpp
+++ llvm/unittests/BinaryFormat/MsgPackWriterTest.cpp
@@ -516,6 +516,8 @@
 
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(CompatWriter.write(MemoryBufferRef(s, "")), "compatible mode");
 #endif
 #endif
Index: llvm/unittests/AsmParser/AsmParserTest.cpp
===================================================================
--- llvm/unittests/AsmParser/AsmParserTest.cpp
+++ llvm/unittests/AsmParser/AsmParserTest.cpp
@@ -35,6 +35,8 @@
 #ifndef NDEBUG
 
 TEST(AsmParserTest, NonNullTerminatedInput) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   LLVMContext Ctx;
   StringRef Source = "; Empty module \n\1\2";
   SMDiagnostic Error;
Index: llvm/unittests/ADT/SmallVectorTest.cpp
===================================================================
--- llvm/unittests/ADT/SmallVectorTest.cpp
+++ llvm/unittests/ADT/SmallVectorTest.cpp
@@ -360,6 +360,8 @@
   EXPECT_EQ(5, Constructable::getNumDestructorCalls());
 
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(V.truncate(2), "Cannot increase size");
 #endif
   V.truncate(1);
@@ -1340,6 +1342,8 @@
   auto &V = this->V;
   (void)V;
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(V.append(V.begin(), V.begin() + 1), this->AssertionMessage);
 
   ASSERT_EQ(3u, NumBuiltinElts(V));
@@ -1394,6 +1398,8 @@
 TYPED_TEST(SmallVectorReferenceInvalidationTest, AssignRange) {
   auto &V = this->V;
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(V.assign(V.begin(), V.end()), this->AssertionMessage);
   EXPECT_DEATH(V.assign(V.begin(), V.end() - 1), this->AssertionMessage);
 #endif
@@ -1474,6 +1480,8 @@
   auto &V = this->V;
   (void)V;
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(V.insert(V.begin(), V.begin(), V.begin() + 1),
                this->AssertionMessage);
 
Index: llvm/unittests/ADT/SequenceTest.cpp
===================================================================
--- llvm/unittests/ADT/SequenceTest.cpp
+++ llvm/unittests/ADT/SequenceTest.cpp
@@ -72,6 +72,8 @@
 
 #if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
 TEST(StrongIntDeathTest, OutOfBounds) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // Values above 'INTMAX_MAX' are not representable.
   EXPECT_DEATH(CheckedInt::from<uintmax_t>(INTMAX_MAX + 1ULL), "Out of bounds");
   EXPECT_DEATH(CheckedInt::from<uintmax_t>(UINTMAX_MAX), "Out of bounds");
Index: llvm/unittests/ADT/STLExtrasTest.cpp
===================================================================
--- llvm/unittests/ADT/STLExtrasTest.cpp
+++ llvm/unittests/ADT/STLExtrasTest.cpp
@@ -269,6 +269,8 @@
 
 #if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
 TEST(STLExtrasTest, EnumerateDifferentLengths) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   std::vector<int> Ints = {0, 1};
   bool Bools[] = {true, false, true};
   std::string Chars = "abc";
Index: llvm/unittests/ADT/IteratorTest.cpp
===================================================================
--- llvm/unittests/ADT/IteratorTest.cpp
+++ llvm/unittests/ADT/IteratorTest.cpp
@@ -566,6 +566,8 @@
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
 // Make sure that we can detect when the first range is not the shortest.
 TEST(ZipIteratorTest, ZipFirstNotShortest) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   const std::array<unsigned, 6> longer = {};
   const std::array<unsigned, 4> shorter = {};
 
Index: llvm/unittests/ADT/BumpPtrListTest.cpp
===================================================================
--- llvm/unittests/ADT/BumpPtrListTest.cpp
+++ llvm/unittests/ADT/BumpPtrListTest.cpp
@@ -235,6 +235,8 @@
   // Resetting a non-empty list should crash.
   L.push_back(5);
 #if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(L.resetAlloc(), "Cannot reset allocator if not empty");
 #endif
 }
Index: llvm/unittests/ADT/AnyTest.cpp
===================================================================
--- llvm/unittests/ADT/AnyTest.cpp
+++ llvm/unittests/ADT/AnyTest.cpp
@@ -160,6 +160,8 @@
   llvm::Any D{'x'};
 
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(llvm::any_cast<int>(A), "");
 
   EXPECT_DEATH(llvm::any_cast<float>(B), "");
Index: llvm/unittests/ADT/APSIntTest.cpp
===================================================================
--- llvm/unittests/ADT/APSIntTest.cpp
+++ llvm/unittests/ADT/APSIntTest.cpp
@@ -193,6 +193,8 @@
 #if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
 
 TEST(APSIntTest, StringDeath) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH((void)APSInt(""), "Invalid string length");
   EXPECT_DEATH((void)APSInt("1a"), "Invalid character in digit string");
 }
Index: llvm/unittests/ADT/APIntTest.cpp
===================================================================
--- llvm/unittests/ADT/APIntTest.cpp
+++ llvm/unittests/ADT/APIntTest.cpp
@@ -1431,6 +1431,8 @@
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
 TEST(APIntTest, StringDeath) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH((void)APInt(32, "", 0), "Invalid string length");
   EXPECT_DEATH((void)APInt(32, "0", 0), "Radix should be 2, 8, 10, 16, or 36!");
   EXPECT_DEATH((void)APInt(32, "", 10), "Invalid string length");
Index: llvm/unittests/ADT/APFloatTest.cpp
===================================================================
--- llvm/unittests/ADT/APFloatTest.cpp
+++ llvm/unittests/ADT/APFloatTest.cpp
@@ -1361,6 +1361,8 @@
 #ifdef GTEST_HAS_DEATH_TEST
 #ifndef NDEBUG
 TEST(APFloatTest, SemanticsDeath) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(APFloat(APFloat::IEEEquad(), 0).convertToDouble(),
                "Float semantics is not representable by IEEEdouble");
   EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), 0).convertToFloat(),
Index: clang/unittests/Tooling/TransformerTest.cpp
===================================================================
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -1593,6 +1593,8 @@
 // Verifies that `Type` and `QualType` are not allowed as top-level matchers in
 // rules.
 TEST(TransformerDeathTest, OrderedRuleTypes) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   RewriteRule QualTypeRule = makeRule(qualType(), changeTo(cat("Q")));
   EXPECT_DEATH(transformer::detail::buildMatchers(QualTypeRule),
                "Matcher must be.*node matcher");
Index: clang/unittests/Serialization/InMemoryModuleCacheTest.cpp
===================================================================
--- clang/unittests/Serialization/InMemoryModuleCacheTest.cpp
+++ clang/unittests/Serialization/InMemoryModuleCacheTest.cpp
@@ -29,6 +29,8 @@
   EXPECT_FALSE(Cache.shouldBuildPCM("B"));
 
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(Cache.tryToDropPCM("B"), "PCM to remove is unknown");
   EXPECT_DEATH(Cache.finalizePCM("B"), "PCM to finalize is unknown");
 #endif
@@ -46,6 +48,8 @@
   EXPECT_FALSE(Cache.shouldBuildPCM("B"));
 
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(Cache.addPCM("B", getBuffer(2)), "Already has a PCM");
   EXPECT_DEATH(Cache.addBuiltPCM("B", getBuffer(2)),
                "Trying to override tentative PCM");
@@ -64,6 +68,8 @@
   EXPECT_FALSE(Cache.shouldBuildPCM("B"));
 
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(Cache.addPCM("B", getBuffer(2)), "Already has a PCM");
   EXPECT_DEATH(Cache.addBuiltPCM("B", getBuffer(2)),
                "Trying to override finalized PCM");
@@ -87,6 +93,8 @@
   EXPECT_TRUE(Cache.shouldBuildPCM("B"));
 
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(Cache.addPCM("B", getBuffer(2)), "Already has a PCM");
   EXPECT_DEATH(Cache.tryToDropPCM("B"),
                "PCM to remove is scheduled to be built");
Index: clang/unittests/Lex/LexerTest.cpp
===================================================================
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -485,6 +485,8 @@
   EXPECT_EQ(tok::string_literal, Result.getKind());
   EXPECT_STREQ("\"'C'\"", Result.getLiteralData());
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH(StringifyArg(3), "Invalid arg #");
 #endif
 }
Index: clang/unittests/Basic/SarifTest.cpp
===================================================================
--- clang/unittests/Basic/SarifTest.cpp
+++ clang/unittests/Basic/SarifTest.cpp
@@ -129,6 +129,8 @@
 #if defined(NDEBUG) || !GTEST_HAS_DEATH_TEST
   GTEST_SKIP() << "This death test is only available for debug builds.";
 #endif
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // GIVEN:
   SarifDocumentWriter Writer{SourceMgr};
 
@@ -150,6 +152,8 @@
 #if defined(NDEBUG) || !GTEST_HAS_DEATH_TEST
   GTEST_SKIP() << "This death test is only available for debug builds.";
 #endif
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // GIVEN:
   SarifDocumentWriter Writer{SourceMgr};
 
@@ -169,6 +173,7 @@
 #if defined(NDEBUG) || !GTEST_HAS_DEATH_TEST
   GTEST_SKIP() << "This death test is only available for debug builds.";
 #endif
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
 
   // GIVEN:
   SarifDocumentWriter Writer{SourceMgr};
Index: clang/unittests/Basic/LineOffsetMappingTest.cpp
===================================================================
--- clang/unittests/Basic/LineOffsetMappingTest.cpp
+++ clang/unittests/Basic/LineOffsetMappingTest.cpp
@@ -20,6 +20,8 @@
   EXPECT_FALSE(Mapping);
 
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH((void)Mapping.getLines(), "Storage");
 #endif
 }
@@ -34,6 +36,8 @@
   EXPECT_EQ(20u, Mapping[2]);
 
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH((void)Mapping[3], "Invalid index");
 #endif
 }
Index: clang/unittests/Basic/FileManagerTest.cpp
===================================================================
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -291,6 +291,8 @@
   EXPECT_EQ(&F1->getFileEntry(), &F1Alias2->getFileEntry());
 
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   EXPECT_DEATH((void)manager.getFileRef("dir/f1-alias-alias.cpp"),
                "filename redirected to a non-canonical filename?");
 #endif
Index: clang/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
===================================================================
--- clang/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/VariantValueTest.cpp
@@ -164,6 +164,8 @@
                    .getMatcher()
                    .hasTypedMatcher<Stmt>());
 #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   // Trying to get the wrong matcher fails an assertion in Matcher<T>.  We don't
   // do this test when building with MSVC because its debug C runtime prints the
   // assertion failure message as a wide string, which gtest doesn't understand.
Index: clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
===================================================================
--- clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
@@ -22,6 +22,8 @@
 
 #if GTEST_HAS_DEATH_TEST
 TEST(HasNameDeathTest, DiesOnEmptyName) {
+  testing::GTEST_FLAG(death_test_style) = "threadsafe";
+
   ASSERT_DEBUG_DEATH({
     DeclarationMatcher HasEmptyName = recordDecl(hasName(""));
     EXPECT_TRUE(notMatches("class X {};", HasEmptyName));
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to