[PATCH] D143680: [WIP][-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

Ziqing Luo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 16 16:07:59 PST 2023


ziqingluo-90 added inline comments.


================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1034-1035
+    assert(!InitFixIts.empty() &&
+           "Expected at least one fix-it for an initializer of an unsafe "
+           "variable declaration.");
     // The loc right before the initializer:
----------------
NoQ wrote:
> The old check was saying "`populateInitializerFixItWithSpan()` returns `{}` on error". So the new check is additionally saying "`populateInitializerFixItWithSpan()` isn't allowed to have errors anymore", which is arguably the more important message 🤔
yeah, I think we are being consistent on using `std::nullopt` to represent "something wrong, no fix" and using `{ }` to represent a no-op fix.  So the old code is incorrect.


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

https://reviews.llvm.org/D143680



More information about the cfe-commits mailing list