[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()
Deep Majumder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 26 10:23:49 PST 2021
RedDocMD marked an inline comment as done.
RedDocMD added a comment.
In D97183#2589445 <https://reviews.llvm.org/D97183#2589445>, @NoQ wrote:
> Nice!
>
> I suspect you're adding too many notes. The note needs to not be there if the *raw* pointer is not tracked. Eg., I suspect that your patch would add a note in the following case in which it shouldn't be there because the raw pointer value doesn't participate in the report despite smart pointer region being interesting:
>
> std::unique_ptr<A> P;
> A *a = P.get(); // shound't emit a note here
> P->foo();
>
> It's important to not emit redundant notes because users typically take these checker-specific notes as an indication that this information is an essential piece of evidence of the bug in their program. In this example they'd believe that the analyzer has figured out that the smart pointer is null by looking at what happens to the raw pointer value. So they may become very confused if this isn't the case.
@NoQ, in the example you have given, isn't the smart-pointer `P` null? So shouldn't a warning be emitted for de-referencing it? Or is it that since `a` is not being used, a warning shouldn't be emitted? Sorry, I could not quite understand that point ...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97183/new/
https://reviews.llvm.org/D97183
More information about the cfe-commits
mailing list