Diagnose modules with circular dependencies (#16075)

This can't arise from a clean build, but it can happen if you have
products lingering in a search path and then either rebuild one of
the modules in the cycle, or change the search paths.

The way this is implemented is for each module to track whether its
imports have all been resolved. If, when loading a module, one of its
dependencies hasn't resolved all of its imports yet, then we know
there's a cycle.

This doesn't produce the best diagnostics, but it's hard to get into
this state in the first place, so that's probably okay.

https://bugs.swift.org/browse/SR-7483
This commit is contained in:
Jordan Rose
2018-05-02 15:01:09 -07:00
committed by GitHub
parent 99861785ca
commit df2e63d07d
17 changed files with 98 additions and 124 deletions

View File

@@ -206,6 +206,7 @@ private:
unsigned TestingEnabled : 1;
unsigned FailedToLoad : 1;
unsigned ResilienceStrategy : 1;
unsigned HasResolvedImports : 1;
} Flags;
ModuleDecl(Identifier name, ASTContext &ctx);
@@ -257,6 +258,13 @@ public:
Flags.FailedToLoad = failed;
}
bool hasResolvedImports() const {
return Flags.HasResolvedImports;
}
void setHasResolvedImports() {
Flags.HasResolvedImports = true;
}
ResilienceStrategy getResilienceStrategy() const {
return ResilienceStrategy(Flags.ResilienceStrategy);
}