aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/CompilerInstance.cpp
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/Frontend/CompilerInstance.cpp
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/Frontend/CompilerInstance.cpp')
-rw-r--r--lib/Frontend/CompilerInstance.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 498f6fbfc0..1f0d87c062 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -1222,25 +1222,26 @@ Module *CompilerInstance::loadModule(SourceLocation ImportLoc,
if (Path.size() > 1) {
for (unsigned I = 1, N = Path.size(); I != N; ++I) {
StringRef Name = Path[I].first->getName();
- llvm::StringMap<clang::Module *>::iterator Pos
- = Module->SubModules.find(Name);
+ clang::Module *Sub = Module->findSubmodule(Name);
- if (Pos == Module->SubModules.end()) {
+ if (!Sub) {
// Attempt to perform typo correction to find a module name that works.
llvm::SmallVector<StringRef, 2> Best;
unsigned BestEditDistance = (std::numeric_limits<unsigned>::max)();
- for (llvm::StringMap<clang::Module *>::iterator
- J = Module->SubModules.begin(),
- JEnd = Module->SubModules.end();
+ for (clang::Module::submodule_iterator J = Module->submodule_begin(),
+ JEnd = Module->submodule_end();
J != JEnd; ++J) {
- unsigned ED = Name.edit_distance(J->getValue()->Name,
+ unsigned ED = Name.edit_distance((*J)->Name,
/*AllowReplacements=*/true,
BestEditDistance);
if (ED <= BestEditDistance) {
- if (ED < BestEditDistance)
+ if (ED < BestEditDistance) {
Best.clear();
- Best.push_back(J->getValue()->Name);
+ BestEditDistance = ED;
+ }
+
+ Best.push_back((*J)->Name);
}
}
@@ -1252,11 +1253,12 @@ Module *CompilerInstance::loadModule(SourceLocation ImportLoc,
<< SourceRange(Path[0].second, Path[I-1].second)
<< FixItHint::CreateReplacement(SourceRange(Path[I].second),
Best[0]);
- Pos = Module->SubModules.find(Best[0]);
+
+ Sub = Module->findSubmodule(Best[0]);
}
}
- if (Pos == Module->SubModules.end()) {
+ if (!Sub) {
// No submodule by this name. Complain, and don't look for further
// submodules.
getDiagnostics().Report(Path[I].second, diag::err_no_submodule)
@@ -1265,7 +1267,7 @@ Module *CompilerInstance::loadModule(SourceLocation ImportLoc,
break;
}
- Module = Pos->getValue();
+ Module = Sub;
}
}