<div dir="ltr">Sorry, not yet. I'll talk with my TL to see if I can get some time allotted for this in the next few weeks.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 29 Apr 2021 at 16:13, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Ping on this - have you had a chance to look at this false positive?<br>
<br>
On Sat, Apr 3, 2021 at 4:29 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
><br>
> Looks like this has a false positive (that's firing on some mlir code,<br>
> committed a workaround in  499571ea835daf786626a0db1e12f890b6cd8f8d )<br>
> like this:<br>
><br>
> $ cat test.cpp<br>
> #include <stdlib.h><br>
> void f1(int & x) { free(&x); }<br>
> int main() { f1(*(int*)malloc(sizeof(int))); }<br>
><br>
> Could you fix that? (& then revert the workaround)<br>
><br>
> On Fri, Jan 15, 2021 at 1:44 PM Christopher Di Bella via cfe-commits<br>
> <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br>
> ><br>
> ><br>
> > Author: Christopher Di Bella<br>
> > Date: 2021-01-15T21:38:47Z<br>
> > New Revision: 4a47da2cf440c2f2006d9b04acfef4292de1e263<br>
> ><br>
> > URL: <a href="https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263</a><br>
> > DIFF: <a href="https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/4a47da2cf440c2f2006d9b04acfef4292de1e263.diff</a><br>
> ><br>
> > LOG: [Sema] turns -Wfree-nonheap-object on by default<br>
> ><br>
> > We'd discussed adding the warning to -Wall in D89988. This patch honours that.<br>
> ><br>
> > Added:<br>
> ><br>
> ><br>
> > Modified:<br>
> >     clang/include/clang/Basic/DiagnosticGroups.td<br>
> >     clang/include/clang/Basic/DiagnosticSemaKinds.td<br>
> >     clang/test/Analysis/NewDelete-<a href="http://intersections.mm" target="_blank">intersections.mm</a><br>
> >     clang/test/Analysis/free.c<br>
> ><br>
> > Removed:<br>
> ><br>
> ><br>
> ><br>
> > ################################################################################<br>
> > diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td<br>
> > index d500ab321058..04ba89aa457e 100644<br>
> > --- a/clang/include/clang/Basic/DiagnosticGroups.td<br>
> > +++ b/clang/include/clang/Basic/DiagnosticGroups.td<br>
> > @@ -110,6 +110,7 @@ def FloatConversion :<br>
> >                                   FloatZeroConversion]>;<br>
> ><br>
> >  def FrameAddress : DiagGroup<"frame-address">;<br>
> > +def FreeNonHeapObject : DiagGroup<"free-nonheap-object">;<br>
> >  def DoublePromotion : DiagGroup<"double-promotion">;<br>
> >  def EnumTooLarge : DiagGroup<"enum-too-large">;<br>
> >  def UnsupportedNan : DiagGroup<"unsupported-nan">;<br>
> ><br>
> > diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td<br>
> > index 7d36397a7993..e93657898f58 100644<br>
> > --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td<br>
> > +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td<br>
> > @@ -7609,7 +7609,7 @@ def err_no_typeid_with_fno_rtti : Error<<br>
> >  def err_no_dynamic_cast_with_fno_rtti : Error<<br>
> >    "use of dynamic_cast requires -frtti">;<br>
> >  def warn_no_dynamic_cast_with_rtti_disabled: Warning<<br>
> > -  "dynamic_cast will not work since RTTI data is disabled by "<br>
> > +  "dynamic_cast will not work since RTTI data is disabled by "<br>
> >    "%select{-fno-rtti-data|/GR-}0">, InGroup<RTTI>;<br>
> >  def warn_no_typeid_with_rtti_disabled: Warning<<br>
> >    "typeid will not work since RTTI data is disabled by "<br>
> > @@ -7625,8 +7625,7 @@ def warn_condition_is_assignment : Warning<"using the result of an "<br>
> >    InGroup<Parentheses>;<br>
> >  def warn_free_nonheap_object<br>
> >    : Warning<"attempt to call %0 on non-heap object %1">,<br>
> > -    InGroup<DiagGroup<"free-nonheap-object">>,<br>
> > -    DefaultIgnore; // FIXME: add to -Wall after sufficient testing<br>
> > +    InGroup<FreeNonHeapObject>;<br>
> ><br>
> >  // Completely identical except off by default.<br>
> >  def warn_condition_is_idiomatic_assignment : Warning<"using the result "<br>
> ><br>
> > diff  --git a/clang/test/Analysis/NewDelete-intersections.mm b/clang/test/Analysis/NewDelete-intersections.mm<br>
> > index f01d62f8d365..6f81034ee349 100644<br>
> > --- a/clang/test/Analysis/NewDelete-intersections.mm<br>
> > +++ b/clang/test/Analysis/NewDelete-intersections.mm<br>
> > @@ -24,9 +24,6 @@<br>
> >  extern "C" void free(void *);<br>
> ><br>
> >  void testMallocFreeNoWarn() {<br>
> > -  int i;<br>
> > -  free(&i); // no warn<br>
> > -<br>
> >    int *p1 = (int *)malloc(sizeof(int));<br>
> >    free(++p1); // no warn<br>
> ><br>
> > @@ -51,7 +48,7 @@ void testDeleteMalloced() {<br>
> ><br>
> >    int *p2 = (int *)__builtin_alloca(sizeof(int));<br>
> >    delete p2; // no warn<br>
> > -}<br>
> > +}<br>
> ><br>
> >  void testUseZeroAllocatedMalloced() {<br>
> >    int *p1 = (int *)malloc(0);<br>
> > @@ -79,13 +76,13 @@ void testObjcFreeNewed() {<br>
> >  }<br>
> ><br>
> >  void testFreeAfterDelete() {<br>
> > -  int *p = new int;<br>
> > +  int *p = new int;<br>
> >    delete p;<br>
> >    free(p); // newdelete-warning{{Use of memory after it is freed}}<br>
> >  }<br>
> ><br>
> >  void testStandardPlacementNewAfterDelete() {<br>
> > -  int *p = new int;<br>
> > +  int *p = new int;<br>
> >    delete p;<br>
> >    p = new (p) int; // newdelete-warning{{Use of memory after it is freed}}<br>
> >  }<br>
> ><br>
> > diff  --git a/clang/test/Analysis/free.c b/clang/test/Analysis/free.c<br>
> > index 0d29bacf274c..b50145713924 100644<br>
> > --- a/clang/test/Analysis/free.c<br>
> > +++ b/clang/test/Analysis/free.c<br>
> > @@ -12,17 +12,23 @@ void *alloca(size_t);<br>
> ><br>
> >  void t1 () {<br>
> >    int a[] = { 1 };<br>
> > -  free(a); // expected-warning {{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}<br>
> > +  free(a);<br>
> > +  // expected-warning@-1{{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}<br>
> > +  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}<br>
> >  }<br>
> ><br>
> >  void t2 () {<br>
> >    int a = 1;<br>
> > -  free(&a); // expected-warning {{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}<br>
> > +  free(&a);<br>
> > +  // expected-warning@-1{{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}<br>
> > +  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}<br>
> >  }<br>
> ><br>
> >  void t3 () {<br>
> >    static int a[] = { 1 };<br>
> > -  free(a); // expected-warning {{Argument to free() is the address of the static variable 'a', which is not memory allocated by malloc()}}<br>
> > +  free(a);<br>
> > +  // expected-warning@-1{{Argument to free() is the address of the static variable 'a', which is not memory allocated by malloc()}}<br>
> > +  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}<br>
> >  }<br>
> ><br>
> >  void t4 (char *x) {<br>
> > @@ -71,12 +77,16 @@ void t13 () {<br>
> >  }<br>
> ><br>
> >  void t14 (char a) {<br>
> > -  free(&a); // expected-warning {{Argument to free() is the address of the parameter 'a', which is not memory allocated by malloc()}}<br>
> > +  free(&a);<br>
> > +  // expected-warning@-1{{Argument to free() is the address of the parameter 'a', which is not memory allocated by malloc()}}<br>
> > +  // expected-warning@-2{{attempt to call free on non-heap object 'a'}}<br>
> >  }<br>
> ><br>
> >  static int someGlobal[2];<br>
> >  void t15 () {<br>
> > -  free(someGlobal); // expected-warning {{Argument to free() is the address of the global variable 'someGlobal', which is not memory allocated by malloc()}}<br>
> > +  free(someGlobal);<br>
> > +  // expected-warning@-1{{Argument to free() is the address of the global variable 'someGlobal', which is not memory allocated by malloc()}}<br>
> > +  // expected-warning@-2{{attempt to call free on non-heap object 'someGlobal'}}<br>
> >  }<br>
> ><br>
> >  void t16 (char **x, int offset) {<br>
> ><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > cfe-commits mailing list<br>
> > <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Kind regards,<br></div><div><br></div><div>Christopher Di Bella (he/him/his)</div></div></div>