[clang] [NFC][Clang Improve performance of `DoMarkVarDeclReferenced` (PR #161648)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 2 03:33:14 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Corentin Jabot (cor3ntin)

<details>
<summary>Changes</summary>

Address post commit feedback from #<!-- -->161231

---
Full diff: https://github.com/llvm/llvm-project/pull/161648.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaExpr.cpp (+4-3) 


``````````diff
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 06b2529011c74..4d3c7d611f370 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -20107,9 +20107,10 @@ static void DoMarkVarDeclReferenced(
   bool NeededForConstantEvaluation =
       isPotentiallyConstantEvaluatedContext(SemaRef) && UsableInConstantExpr;
 
-  bool NeedDefinition = OdrUse == OdrUseContext::Used ||
-                        NeededForConstantEvaluation ||
-                        Var->getType()->isUndeducedType();
+  bool NeedDefinition =
+      OdrUse == OdrUseContext::Used || NeededForConstantEvaluation ||
+      (TSK != clang::TSK_Undeclared && !UsableInConstantExpr &&
+       Var->getType()->isUndeducedType());
 
   assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
          "Can't instantiate a partial template specialization.");

``````````

</details>


https://github.com/llvm/llvm-project/pull/161648


More information about the cfe-commits mailing list