mirror of
https://github.com/intel/llvm.git
synced 2026-01-21 12:19:23 +08:00
[modularize] Stabilize iteration order when processing module maps
Many diagnostics (e.g., ProblemsDuplicate.modularize, ProblemsDisplayLists.modularize) are dependent on the iteration order of StringMap, which is not guaranteed to be deterministic (https://llvm.org/docs/ProgrammersManual.html#llvm-adt-stringmap-h). clang::ModuleMap::Modules is a StringMap. For now, sort by name in modularize.
This commit is contained in:
@@ -322,12 +322,13 @@ std::error_code ModularizeUtilities::loadModuleMap(
|
||||
// Walks the modules and collects referenced headers into
|
||||
// HeaderFileNames.
|
||||
bool ModularizeUtilities::collectModuleMapHeaders(clang::ModuleMap *ModMap) {
|
||||
for (ModuleMap::module_iterator I = ModMap->module_begin(),
|
||||
E = ModMap->module_end();
|
||||
I != E; ++I) {
|
||||
if (!collectModuleHeaders(*I->second))
|
||||
SmallVector<std::pair<StringRef, const Module *>, 0> Vec;
|
||||
for (auto &M : ModMap->modules())
|
||||
Vec.emplace_back(M.first(), M.second);
|
||||
llvm::sort(Vec, llvm::less_first());
|
||||
for (auto &I : Vec)
|
||||
if (!collectModuleHeaders(*I.second))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,5 +12,5 @@
|
||||
|
||||
# CHECK: These are the combined files, with problem files preceded by #:
|
||||
|
||||
# CHECK: Inputs/CompileError/Level1A.h
|
||||
# CHECK: {{.*}}Inputs/CompileError/HasError.h
|
||||
# CHECK: Inputs/CompileError/HasError.h
|
||||
# CHECK-NEXT: Inputs/CompileError/Level1A.h
|
||||
|
||||
Reference in New Issue
Block a user