aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-04 23:32:19 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-04 23:32:19 +0000
commitb7a7819473709c01ea024a2dc15e99d38f0f8760 (patch)
tree5fbbadeec73aba8aed448bfaf2f67401042d1b0d /lib/Serialization
parente5e42ae2694f2c4709dac3d84e3e6e5fac86c244 (diff)
Store the submodules of a module in source order, as they are stored
in the module map. This provides a bit more predictability for the user, as well as eliminating the need to sort the submodules when serializing them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147564 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r--lib/Serialization/ASTReader.cpp8
-rw-r--r--lib/Serialization/ASTWriter.cpp21
2 files changed, 10 insertions, 19 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 9c9e8b3ca9..c29033e833 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -2541,11 +2541,11 @@ void ASTReader::makeModuleVisible(Module *Mod,
// Push any non-explicit submodules onto the stack to be marked as
// visible.
- for (llvm::StringMap<Module *>::iterator Sub = Mod->SubModules.begin(),
- SubEnd = Mod->SubModules.end();
+ for (Module::submodule_iterator Sub = Mod->submodule_begin(),
+ SubEnd = Mod->submodule_end();
Sub != SubEnd; ++Sub) {
- if (!Sub->getValue()->IsExplicit && Visited.insert(Sub->getValue()))
- Stack.push_back(Sub->getValue());
+ if (!(*Sub)->IsExplicit && Visited.insert(*Sub))
+ Stack.push_back(*Sub);
}
// Push any exported modules onto the stack to be marked as visible.
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 9ed2a6c6d9..1317525c27 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -1859,10 +1859,10 @@ unsigned ASTWriter::getSubmoduleID(Module *Mod) {
/// given module).
static unsigned getNumberOfModules(Module *Mod) {
unsigned ChildModules = 0;
- for (llvm::StringMap<Module *>::iterator Sub = Mod->SubModules.begin(),
- SubEnd = Mod->SubModules.end();
+ for (Module::submodule_iterator Sub = Mod->submodule_begin(),
+ SubEnd = Mod->submodule_end();
Sub != SubEnd; ++Sub)
- ChildModules += getNumberOfModules(Sub->getValue());
+ ChildModules += getNumberOfModules(*Sub);
return ChildModules + 1;
}
@@ -2010,19 +2010,10 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
}
// Queue up the submodules of this module.
- llvm::SmallVector<StringRef, 2> SubModules;
-
- // Sort the submodules first, so we get a predictable ordering in the AST
- // file.
- for (llvm::StringMap<Module *>::iterator
- Sub = Mod->SubModules.begin(),
- SubEnd = Mod->SubModules.end();
+ for (Module::submodule_iterator Sub = Mod->submodule_begin(),
+ SubEnd = Mod->submodule_end();
Sub != SubEnd; ++Sub)
- SubModules.push_back(Sub->getKey());
- llvm::array_pod_sort(SubModules.begin(), SubModules.end());
-
- for (unsigned I = 0, N = SubModules.size(); I != N; ++I)
- Q.push(Mod->SubModules[SubModules[I]]);
+ Q.push(*Sub);
}
Stream.ExitBlock();