Skip to content

Commit 1698884

Browse files
committed
AST: avoid looking up serialized locations when decl is context-free
1 parent fd280d7 commit 1698884

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/AST/Decl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ static_assert(sizeof(checkSourceLocType(&ID##Decl::getLoc)) == 2, \
512512
#include "swift/AST/DeclNodes.def"
513513
if (isa<ModuleDecl>(this))
514514
return SourceLoc();
515+
// When the decl is context-free, we should get loc from source buffer.
516+
if (!getDeclContext())
517+
return getLocFromSource();
515518
auto *File = cast<FileUnit>(getDeclContext()->getModuleScopeContext());
516519
switch(File->getKind()) {
517520
case FileUnitKind::Source:

0 commit comments

Comments
 (0)