[clang] [Clang] Preserve coroutine parameter referenced state (PR #70973)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 1 15:48:12 PDT 2023


================
@@ -1965,9 +1965,15 @@ bool Sema::buildCoroutineParameterMoves(SourceLocation Loc) {
     if (PD->getType()->isDependentType())
       continue;
 
+    // Preserve the referenced state for unused parameter diagnostics.
+    bool DeclReferenced = PD->isReferenced();
+
     ExprResult PDRefExpr =
         BuildDeclRefExpr(PD, PD->getType().getNonReferenceType(),
                          ExprValueKind::VK_LValue, Loc); // FIXME: scope?
+
+    PD->setReferenced(DeclReferenced);
----------------
bcardosolopes wrote:

What happens in `BuildDeclRefExpr` such that `PD` loses track of whether it is referenced? If something is changing `PD` in a bad way, perhaps at that point might be better to set the appropriated method instead. 

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


More information about the cfe-commits mailing list