[PATCH] D94640: adds more checks to -Wfree-nonheap-object
Christopher Di Bella via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 11 16:56:06 PST 2021
cjdb added inline comments.
================
Comment at: clang/test/Analysis/free.c:84
+ // expected-warning at -1{{Argument to free() is a block, which is not memory allocated by malloc()}}
+ // expected-warning at -2{{attempt to call free on non-heap object : block expression}}
}
----------------
aaron.ballman wrote:
> cjdb wrote:
> > aaron.ballman wrote:
> > > The formatting for this diagnostic is somewhat unfortunate in that it has the leading space before the `:`. I think that changing the diagnostic to use a `%select` would be an improvement.
> > I'm having a *lot* of difficulty getting `%select` to work. Here's what I've tried, but the space in `%select{ %2` is being ignored :(
> >
> > ```
> > : Warning<"attempt to call %0 on non-heap object%select{ %2|: block expression}1">,
> > ```
> We could cheat a little bit. :-D
>
> `Warning<"attempt to call %0 on non-heap %select{object %2|object: block expression}1">`
>
> (The diagnostic should probably be updated to distinguish between block expressions and lambda expressions, which may add another layer of `%select` not shown here.)
That doesn't fix the issue, which is that everything before `%2` is deleted.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94640/new/
https://reviews.llvm.org/D94640
More information about the cfe-commits
mailing list