Skip to content

Handle null macro references in the semantic annotator #62844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/IDE/SourceEntityWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,14 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
// The macro itself.
auto macroRef = ME->getMacroRef();
auto macroDecl = macroRef.getDecl();
auto macroRefType =
macroDecl->getInterfaceType().subst(macroRef.getSubstitutions());
if (!passReference(
macroDecl, macroRefType, ME->getMacroNameLoc(),
ReferenceMetaData(SemaReferenceKind::DeclRef, None)))
return Action::Stop();
if (macroDecl) {
auto macroRefType =
macroDecl->getInterfaceType().subst(macroRef.getSubstitutions());
if (!passReference(
macroDecl, macroRefType, ME->getMacroNameLoc(),
ReferenceMetaData(SemaReferenceKind::DeclRef, None)))
return Action::Stop();
}

// Walk the arguments, since they were written directly by the user.
if (auto argList = ME->getArgs()) {
Expand Down
3 changes: 3 additions & 0 deletions test/SourceKit/CursorInfo/crash-62840.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#if true
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):7 %s -- %s
#endifsomeGesture