[clang] [-Wunsafe-buffer-usage] Add fixits for array to pointer assignment (PR #81343)

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 14 18:33:00 PST 2024


================
@@ -1490,6 +1548,26 @@ PointerAssignmentGadget::getFixits(const FixitStrategy &S) const {
   return std::nullopt;
 }
 
+/// \returns fixit that adds .data() call after \DRE.
+static inline std::optional<FixItList> createDataFixit(const ASTContext &Ctx,
+                                                       const DeclRefExpr *DRE);
+
+std::optional<FixItList>
+CArrayToPtrAssignmentGadget::getFixits(const FixitStrategy &S) const {
----------------
haoNoQ wrote:

I think there should be a comment explaining why the "both sides are fixed" case is tricky. Otherwise somebody may accidentally implement it 😅

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


More information about the cfe-commits mailing list