Eliminate non-deterministic behavior when removing duplicate declarations after module lookup.

Big thanks to JoeP for pointing this out! No specific test case here.

Swift SVN r19177
This commit is contained in:
Doug Gregor
2014-06-25 20:57:13 +00:00
parent 09bd502f68
commit e4331e4ba9

View File

@@ -234,9 +234,13 @@ static void lookupInModule(Module *module, Module::AccessPathTy accessPath,
}
}
std::sort(decls.begin() + initialCount, decls.end());
auto afterUnique = std::unique(decls.begin() + initialCount, decls.end());
decls.erase(afterUnique, decls.end());
// Remove duplicated declarations.
llvm::SmallPtrSet<ValueDecl *, 4> knownDecls;
decls.erase(std::remove_if(decls.begin() + initialCount, decls.end(),
[&](ValueDecl *d) -> bool {
return !knownDecls.insert(d);
}),
decls.end());
auto &cachedValues = cache[{accessPath, module}];
cachedValues.insert(cachedValues.end(),