mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST] Fix AutoDiff crasher in optimized builds.
`getModuleScopeContext()` can produce a `ModuleDecl *` instead of a `FileUnit *`, which happens to be the case for generic-specialized derivative functions. Resolves rdar://71191415.
This commit is contained in:
@@ -654,7 +654,9 @@ static_assert(sizeof(checkSourceLocType(&ID##Decl::getLoc)) == 2, \
|
||||
// When the decl is context-free, we should get loc from source buffer.
|
||||
if (!getDeclContext())
|
||||
return getLocFromSource();
|
||||
auto *File = cast<FileUnit>(getDeclContext()->getModuleScopeContext());
|
||||
FileUnit *File = dyn_cast<FileUnit>(getDeclContext()->getModuleScopeContext());
|
||||
if (!File)
|
||||
return getLocFromSource();
|
||||
switch(File->getKind()) {
|
||||
case FileUnitKind::Source:
|
||||
return getLocFromSource();
|
||||
|
||||
Reference in New Issue
Block a user