[AutoDiff] Add generated implicit declarations to SynthesizedFileUnit.

Add implicit declarations generated by the differentiation transform to a
`SynthesizedFileUnit` instead of an ad-hoc pre-existing `SourceFile`.

Resolves TF-1232: type reconstruction for AutoDiff-generated declarations.

Previously, type reconstruction failed because retroactively adding declarations
to a `SourceFile` did not update name lookup caches.
This commit is contained in:
Dan Zheng
2020-04-07 13:37:58 -07:00
parent c834696bfa
commit f7a9eed4de
8 changed files with 31 additions and 24 deletions

View File

@@ -1180,6 +1180,8 @@ lookupOperatorDeclForName(const FileUnit &File, SourceLoc Loc,
// The Builtin module declares no operators.
return nullptr;
case FileUnitKind::Synthesized:
// Synthesized files currently declare no operators.
return nullptr;
case FileUnitKind::Source:
break;
case FileUnitKind::SerializedAST:
@@ -1527,6 +1529,9 @@ StringRef ModuleDecl::getModuleFilename() const {
Result = LF->getFilename();
continue;
}
// Skip synthesized files.
if (auto *SFU = dyn_cast<SynthesizedFileUnit>(F))
continue;
return StringRef();
}
return Result;