Skip to content

Commit c419260

Browse files
committed
[Serialization] Avoid iterating Dense{Map,Set} to break determinism
in ASTWriter It is bad to iterate Dense{Map,Set} in ASTWriter. Since the order in Dense{Map, Set} is not stable. It may cause the produced BMI differ even if we run the compiler twice without modifying any other thing.
1 parent 3b2b918 commit c419260

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ class ASTWriter : public ASTDeserializationListener,
370370
///
371371
/// Only meaningful for standard C++ named modules. See the comments in
372372
/// createSignatureForNamedModule() for details.
373-
llvm::DenseSet<Module *> TouchedTopLevelModules;
373+
llvm::SetVector<Module *> TouchedTopLevelModules;
374374

375375
/// An update to a Decl.
376376
class DeclUpdate {

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4438,7 +4438,7 @@ void ASTWriter::GenerateSpecializationInfoLookupTable(
44384438
Generator;
44394439
LazySpecializationInfoLookupTrait Trait(*this);
44404440

4441-
llvm::DenseMap<unsigned, llvm::SmallVector<const NamedDecl *, 4>>
4441+
llvm::MapVector<unsigned, llvm::SmallVector<const NamedDecl *, 4>>
44424442
SpecializationMaps;
44434443

44444444
for (auto *Specialization : Specializations) {

0 commit comments

Comments
 (0)