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:
- unsafe operation not performed on a supported kind of variable (eg. member variable);
- use site of the unsafe variable not claimed by any fixable gadgets (so we need to cover it with a new fixable);
- one of the "implicated" variables has unclaimed uses (so we can't build the implication graph);
- fixit generation for the declaration of the variable has failed (eg. declaration is in a macro);
- 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).
I changed this to make F->getBaseStmt() available more often, but ran into more problems of this kind that were much more strange than this one. I'll probably investigate more.