[PATCH] D154880: [-Wunsafe-buffer-usage][WIP] Add a facility for debugging low fixit coverage.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 10 12:54:05 PDT 2023
NoQ created this revision.
NoQ added reviewers: jkorous, t-rasmud, ziqingluo-90, malavikasamak.
Herald added subscribers: steakhal, martong.
Herald added a project: All.
NoQ requested review of this revision.
Herald added a subscriber: wangpc.
This patch adds extra notes to `-Wunsafe-buffer-usage` warnings, which explain why a fixit wasn't produced. When applied to a large body of real-world code, it'll help us gather statistics that will help us figure out which fixable gadgets (or other features of the fixit machine) to "invest" into.
This is a debugging facility intended for developer use only; it is activated by passing `-mllvm -debug-only=SafeBuffers` to clang, so it's carefully hidden and undiscoverable, and it's only available in builds with assertions.
Offline we've identified the following sources of false negatives which these notes can help us categorize:
1. unsafe operation not performed on a supported kind of variable (eg. member variable);
2. use site of the unsafe variable not claimed by any fixable gadgets (so we need to cover it with a new fixable);
3. one of the "implicated" variables has unclaimed uses (so we can't build the implication graph);
4. fixit generation for the declaration of the variable has failed (eg. declaration is in a macro);
5. fixit generation for one of the fixable gadgets has failed (eg. the use is in a macro).
Currently this patch covers #5; it probably makes sense to cover all of these except maybe #1 (this one's usually obvious).
Repository:
rC Clang
https://reviews.llvm.org/D154880
Files:
clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154880.538776.patch
Type: text/x-patch
Size: 7138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230710/abe539d1/attachment.bin>
More information about the cfe-commits
mailing list