Skip to content

Commit 8d2da14

Browse files
committed
[PreCheckExpr] Don't perform typo correction inside macro arguments.
(cherry picked from commit db23cf5)
1 parent dfc4c9a commit 8d2da14

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/Sema/PreCheckExpr.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,14 @@ Expr *TypeChecker::resolveDeclRefExpr(UnresolvedDeclRefExpr *UDRE,
602602
}
603603

604604
TypoCorrectionResults corrections(Name, nameLoc);
605-
TypeChecker::performTypoCorrection(DC, UDRE->getRefKind(), Type(),
606-
lookupOptions, corrections);
605+
606+
// FIXME: Don't perform typo correction inside macro arguments, because it
607+
// will invoke synthesizing declarations in this scope, which will attempt to
608+
// expand this macro which leads to circular reference errors.
609+
if (!ASTScope::isInMacroArgument(DC->getParentSourceFile(), UDRE->getLoc())) {
610+
TypeChecker::performTypoCorrection(DC, UDRE->getRefKind(), Type(),
611+
lookupOptions, corrections);
612+
}
607613

608614
if (auto typo = corrections.claimUniqueCorrection()) {
609615
auto diag = Context.Diags.diagnose(

0 commit comments

Comments
 (0)