[clang] [Clang] Instantiate variables referenced in `decltype` with an undeduced type. (PR #161231)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 29 12:33:05 PDT 2025


================
@@ -20108,8 +20108,9 @@ static void DoMarkVarDeclReferenced(
   bool NeededForConstantEvaluation =
       isPotentiallyConstantEvaluatedContext(SemaRef) && UsableInConstantExpr;
 
-  bool NeedDefinition =
-      OdrUse == OdrUseContext::Used || NeededForConstantEvaluation;
+  bool NeedDefinition = OdrUse == OdrUseContext::Used ||
+                        NeededForConstantEvaluation ||
+                        Var->getType()->isUndeducedType();
----------------
zygoloid wrote:

Can we condition this check on `TSK != TSK_Undeclared`? As it stands, every time any variable is mentioned we'll walk its type looking for `auto`, which sounds quite expensive, given how common name references to variables are.

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


More information about the cfe-commits mailing list