[modules] Fix a bug that would result in a build with P paths through a module
graph with M modules to take O(P) time, not just O(M) time, when using explicit
module builds.
llvm-svn: 230412
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 832aee2..fc97981 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1288,6 +1288,9 @@
bool needsImportVisitation() const override { return true; }
void visitImport(StringRef FileName) override {
+ if (!CI.ExplicitlyLoadedModuleFiles.insert(FileName).second)
+ return;
+
ModuleFileStack.push_back(FileName);
if (ASTReader::readASTFileControlBlock(FileName, CI.getFileManager(),
*this)) {