================
@@ -13273,6 +13273,23 @@ enum {
   ConstUnknown,  // Keep as last element
 };
 
+static void MaybeSuggestDerefFixIt(Sema &S, const Expr *E, SourceLocation Loc) 
{
+  ExprResult Deref;
+  Expr *TE = const_cast<Expr *>(E);
+  {
+    Sema::TentativeAnalysisScope Trap(S);
+    Deref = S.ActOnUnaryOp(S.getCurScope(), Loc, tok::star, TE);
+  }
----------------
zygoloid wrote:

It's not really feasible to use a `TentativeAnalysisScope` for this. Here are 
three reasons:

1) If `ActOnUnaryOp` produces an "immediate context" diagnostic (the common 
case), such as a warning, then the note you produce below will be attached to 
that diagnostic instead of to the original diagnostic, so your note will be 
suppressed.
2) If `ActOnUnaryOp` triggers template instantiation, then 
`TentativeAnalysisScope` will not suppress diagnostics outside of the immediate 
context, potentially leading to additional spurious diagnostics being produced.
3) If this function is used to attach a note to a warning / extension 
diagnostic rather than an error (which doesn't appear to be the case right now, 
but it seems plausible that someone would make such a change to 
`CheckForModifiableLValue` in the future), then the diagnostics produced by (2) 
would lead to rejecting a valid program.

Checking for an overloaded `operator*` seems overly complicated here, so I 
think the right thing to test here is just whether the expression has pointer 
type, and the pointee type is an object type (not void or a function type).

https://github.com/llvm/llvm-project/pull/94159
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to