From d8ec851c93f141b42b66d666bc71aace82dc6909 Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Tue, 12 Nov 2024 18:35:17 +0000 Subject: [PATCH] [Sema] NFC: Address review feedback on #77537 --- lib/Sema/CSApply.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index ece86886db077..70c5b8c5a2d99 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -426,13 +426,24 @@ namespace { solution(solution), target(target), SuppressDiagnostics(suppressDiagnostics) {} + ASTContext &getASTContext() const { return cs.getASTContext(); } ConstraintSystem &getConstraintSystem() const { return cs; } void addLocalDeclToTypeCheck(Decl *D) { + // If we're doing code completion, avoid doing any further type-checking, + // that should instead be handled by TypeCheckASTNodeAtLocRequest. + if (getASTContext().CompletionCallback) + return; + LocalDeclsToTypeCheck.push_back(D); } void addMacroToExpand(MacroExpansionExpr *E) { + // If we're doing code completion, avoid doing any further type-checking, + // that should instead be handled by TypeCheckASTNodeAtLocRequest. + if (getASTContext().CompletionCallback) + return; + MacrosToExpand.push_back(E); } @@ -5620,20 +5631,16 @@ namespace { .fixItInsert(coercion->getStartLoc(), "consume "); } - // If we're doing code completion, avoid doing any further type-checking, - // that should instead be handled by TypeCheckASTNodeAtLocRequest. - if (!ctx.CompletionCallback) { - // Type-check any local decls encountered. - for (auto *D : LocalDeclsToTypeCheck) - TypeChecker::typeCheckDecl(D); - - // Expand any macros encountered. - // FIXME: Expansion should be lazy. - auto &eval = cs.getASTContext().evaluator; - for (auto *E : MacrosToExpand) { - (void)evaluateOrDefault(eval, ExpandMacroExpansionExprRequest{E}, - std::nullopt); - } + // Type-check any local decls encountered. + for (auto *D : LocalDeclsToTypeCheck) + TypeChecker::typeCheckDecl(D); + + // Expand any macros encountered. + // FIXME: Expansion should be lazy. + auto &eval = cs.getASTContext().evaluator; + for (auto *E : MacrosToExpand) { + (void)evaluateOrDefault(eval, ExpandMacroExpansionExprRequest{E}, + std::nullopt); } }