diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-04 23:32:19 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-04 23:32:19 +0000 |
commit | eb90e830850eca0c71886ad64ff2a7d0ff492ddb (patch) | |
tree | eec40f4aa6b52114a60361f4342d5af3a6f6a61b /clang/lib/Serialization/ASTWriter.cpp | |
parent | f7168395806ba2b676150c4a025830ca47adb1c6 (diff) | |
download | bcm5719-llvm-eb90e830850eca0c71886ad64ff2a7d0ff492ddb.tar.gz bcm5719-llvm-eb90e830850eca0c71886ad64ff2a7d0ff492ddb.zip |
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.
llvm-svn: 147564
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 9ed2a6c6d95..1317525c27d 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/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(); |