summaryrefslogtreecommitdiffstats
path: root/clang/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
commiteb90e830850eca0c71886ad64ff2a7d0ff492ddb (patch)
treeeec40f4aa6b52114a60361f4342d5af3a6f6a61b /clang/lib/Frontend/CompilerInstance.cpp
parentf7168395806ba2b676150c4a025830ca47adb1c6 (diff)
downloadbcm5719-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/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 498f6fbfc09..1f0d87c0626 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/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;
}
}
OpenPOWER on IntegriCloud