[Lldb-commits] [lldb] 297354b - [lldb] Create mock type systems in array for deterministic order (#218009)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 24 01:21:15 PDT 2026
Author: Nerixyz
Date: 2026-08-24T09:21:10+01:00
New Revision: 297354b40f012fc508c92b88d7ecdf2dd048af28
URL: https://github.com/llvm/llvm-project/commit/297354b40f012fc508c92b88d7ecdf2dd048af28
DIFF: https://github.com/llvm/llvm-project/commit/297354b40f012fc508c92b88d7ecdf2dd048af28.diff
LOG: [lldb] Create mock type systems in array for deterministic order (#218009)
To fix the occasional test failure from #217789: Instead of using two
random heap allocations for the type systems, allocate them in an array
once and create aliases to the elements (similar to what David suggested
in
https://github.com/llvm/llvm-project/pull/217789#issuecomment-5372708193).
The array allocation is destroyed when the last (aliased) shared pointer
is destroyed.
Added:
Modified:
lldb/unittests/Target/ScratchTypeSystemTest.cpp
Removed:
################################################################################
diff --git a/lldb/unittests/Target/ScratchTypeSystemTest.cpp b/lldb/unittests/Target/ScratchTypeSystemTest.cpp
index 85dccf06a30c0..90795bf049595 100644
--- a/lldb/unittests/Target/ScratchTypeSystemTest.cpp
+++ b/lldb/unittests/Target/ScratchTypeSystemTest.cpp
@@ -110,10 +110,12 @@ TEST_F(TestTypeSystemMap, GetScratchTypeSystemsIsOrderedByLanguage) {
// order in memory is then the reverse of the order of the languages, and an
// implementation that deduplicates by sorting on pointer identity returns the
// two the wrong way round.
- g_fortran90_type_system =
- std::make_shared<MockTypeSystem>(lldb::eLanguageTypeFortran90);
- g_fortran77_type_system =
- std::make_shared<MockTypeSystem>(lldb::eLanguageTypeFortran77);
+ std::shared_ptr<MockTypeSystem[]> mocks(new MockTypeSystem[2]{
+ MockTypeSystem(lldb::eLanguageTypeFortran90),
+ MockTypeSystem(lldb::eLanguageTypeFortran77),
+ });
+ g_fortran90_type_system = std::shared_ptr<MockTypeSystem>(mocks, &mocks[0]);
+ g_fortran77_type_system = std::shared_ptr<MockTypeSystem>(mocks, &mocks[1]);
ASSERT_LT(g_fortran90_type_system.get(), g_fortran77_type_system.get());
LanguageSet fortran77;
More information about the lldb-commits
mailing list