Skip to content

Commit 497a8dc

Browse files
authored
Merge pull request #62844 from DougGregor/sema-annotator-crash-62840
2 parents d358ece + db801af commit 497a8dc

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/IDE/SourceEntityWalker.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,14 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
582582
// The macro itself.
583583
auto macroRef = ME->getMacroRef();
584584
auto macroDecl = macroRef.getDecl();
585-
auto macroRefType =
586-
macroDecl->getInterfaceType().subst(macroRef.getSubstitutions());
587-
if (!passReference(
588-
macroDecl, macroRefType, ME->getMacroNameLoc(),
589-
ReferenceMetaData(SemaReferenceKind::DeclRef, None)))
590-
return Action::Stop();
585+
if (macroDecl) {
586+
auto macroRefType =
587+
macroDecl->getInterfaceType().subst(macroRef.getSubstitutions());
588+
if (!passReference(
589+
macroDecl, macroRefType, ME->getMacroNameLoc(),
590+
ReferenceMetaData(SemaReferenceKind::DeclRef, None)))
591+
return Action::Stop();
592+
}
591593

592594
// Walk the arguments, since they were written directly by the user.
593595
if (auto argList = ME->getArgs()) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#if true
2+
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):7 %s -- %s
3+
#endifsomeGesture

0 commit comments

Comments
 (0)