mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] Make IsNonUserModuleRequest consider SourceFile inputs as well.
We're using a small custom frontend tool to generate indexstore data for `.swiftinterface` files in the SDKs. We do this by treating the `.swiftinterface` file as the input of an interface compilation, but this exits early because it treats it as a `SourceFile` instead of an external `LoadedFile`. This happens even if we call `setIsSystemModule(true)` unless we skip setting the SDK path, but that causes other problems. It seems harmless to check for `SourceFile`s as well, so that a tool processing an SDK interface as a direct input still gets the right state.
This commit is contained in:
@@ -4039,11 +4039,15 @@ bool IsNonUserModuleRequest::evaluate(Evaluator &evaluator, ModuleDecl *mod) con
|
||||
if (!mod->hasName() || mod->getFiles().empty())
|
||||
return false;
|
||||
|
||||
auto *LF = dyn_cast_or_null<LoadedFile>(mod->getFiles().front());
|
||||
if (!LF)
|
||||
return false;
|
||||
|
||||
StringRef modulePath = LF->getSourceFilename();
|
||||
StringRef modulePath;
|
||||
auto fileUnit = mod->getFiles().front();
|
||||
if (auto *LF = dyn_cast_or_null<LoadedFile>(fileUnit)) {
|
||||
modulePath = LF->getSourceFilename();
|
||||
} else if (auto *SF = dyn_cast_or_null<SourceFile>(fileUnit)) {
|
||||
// Checking for SourceFiles lets custom tools get the correct is-system
|
||||
// state for index units when compiling a textual interface directly.
|
||||
modulePath = SF->getFilename();
|
||||
}
|
||||
if (modulePath.empty())
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user