[PATCH] D140179: [WIP][-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 16 10:40:43 PST 2022


jkorous added inline comments.


================
Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2379
+    for (auto UnsafeUse : UnsafeUses)
+      if (!DE.isSafeBufferOptOut(SM, UnsafeUse->getBeginLoc()))
+        UnsafeUsesToReport.push_back(UnsafeUse);
----------------
NoQ wrote:
> I believe this check should be performed *much earlier*. It's not about how we display unsafe usages to the user; we can exclude variables from analysis entirely when all their unsafe uses are guarded by the pragma. I suspect that we can drop these gadgets as early as in `findGadgets()` phase (assuming that D140062 causes us to never rely on unsafe gadgets for fixits).
Let's addres this in a follow-up patch.


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

https://reviews.llvm.org/D140179



More information about the cfe-commits mailing list