[PATCH] D138426: Fix #58958 on github

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 21 14:15:04 PST 2022


dblaikie added inline comments.


================
Comment at: clang/lib/Sema/SemaFixItUtils.cpp:135-140
+    // Do no take address of const pointer to get void*
+    const PointerType *FromPtrTy = dyn_cast<PointerType>(FromQTy);
+    const PointerType *ToPtrTy = dyn_cast<PointerType>(ToQTy);
+    if (FromPtrTy && FromPtrTy->getPointeeType().isConstQualified() &&
+        ToPtrTy->isVoidPointerType())
+      return false;
----------------
krsch wrote:
> dblaikie wrote:
> > Do we need to check the constness here? What other cases does it come up? Like maybe if it's volatile we'd want to do the same thing?
> For volatile pointers the same bad suggestion appears. Maybe I should remove the isConstQualified check as IIRC all non-const non-volatile pointers can be implicitly converted to void* so the suggestion would not appear for them. Probably any suggestion to change T* to T** for casting to void* is unlikely to be correct.
yeah, that's what I was thinking - probably remove the const check and maybe add a test case showing the volatile case too


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138426/new/

https://reviews.llvm.org/D138426



More information about the cfe-commits mailing list