<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 6, 2014 at 1:28 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">On Fri, Jun 6, 2014 at 1:21 PM, Richard Trieu <<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>> wrote:<br>

> Looking at the code for tautological compares against zero, there already is<br>
> an exception for macros and enum constants.<br>
<br>
</div>Any particular gut feeling/stats/logic behind excepting enum constants<br>
but not other constants? It doesn't seem to me like one would be more<br>
likely to be a cause of false positives as the other.<br></blockquote><div><br></div><div>I'm just stating what the code says.  The code for that actually predates me.  It was added in r114695 by Ted Kremenek and references the bug <span style="color:rgb(0,0,0);white-space:pre-wrap">rdar://problem/8414119</span></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5"><br>
> I think adding an exception for<br>
> being defined in an #if block would be a good addition, however I am not<br>
> sure if that information is propagated past the preprocessor.<br>
><br>
><br>
><br>
> On Fri, Jun 6, 2014 at 9:18 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
>><br>
>> Not sure - but I know we're going to have to figure some of these<br>
>> things out for -Wunreachable-code and similar things (I know some of<br>
>> these heuristics have already been implemented in -Wunreachable-code,<br>
>> perhaps we could reuse them for other things like this)<br>
>><br>
>> I'd wager that even just "the constant is not a literal" (either a<br>
>> global constant, or a macro, etc) might be enough signal in this case.<br>
>> Perhaps Richard (cc'd) has some idea about how many of the hits on<br>
>> this warning in google were with literals versus not.<br>
>><br>
>> On Fri, Jun 6, 2014 at 9:15 AM, Dmitry Vyukov <<a href="mailto:dvyukov@google.com">dvyukov@google.com</a>> wrote:<br>
>> > how would it figure out that something is implementation-defined?<br>
>> ><br>
>> ><br>
>> > On Fri, Jun 6, 2014 at 8:13 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>><br>
>> > wrote:<br>
>> >> Should we try to fix the Clang warning so it doesn't fire on<br>
>> >> possibly-implementation-defined constants like this?<br>
>> >><br>
>> >> On Fri, Jun 6, 2014 at 8:51 AM, Dmitry Vyukov <<a href="mailto:dvyukov@google.com">dvyukov@google.com</a>><br>
>> >> wrote:<br>
>> >>> Author: dvyukov<br>
>> >>> Date: Fri Jun  6 10:51:20 2014<br>
>> >>> New Revision: 210346<br>
>> >>><br>
>> >>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=210346&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=210346&view=rev</a><br>
>> >>> Log:<br>
>> >>> tsan: fix clang warning:<br>
>> >>> comparison of unsigned expression >= 0 is always true<br>
>> >>><br>
>> >>><br>
>> >>> Modified:<br>
>> >>>     compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h<br>
>> >>><br>
>> >>> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h<br>
>> >>> URL:<br>
>> >>> <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h?rev=210346&r1=210345&r2=210346&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h?rev=210346&r1=210345&r2=210346&view=diff</a><br>

>> >>><br>
>> >>> ==============================================================================<br>
>> >>> --- compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h (original)<br>
>> >>> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h Fri Jun  6 10:51:20<br>
>> >>> 2014<br>
>> >>> @@ -131,6 +131,8 @@ static inline bool IsAppMem(uptr mem) {<br>
>> >>>  #if defined(TSAN_COMPAT_SHADOW) && TSAN_COMPAT_SHADOW<br>
>> >>>    return (mem >= kLinuxAppMemBeg && mem < kAppMemGapBeg) ||<br>
>> >>>           (mem >= kAppMemGapEnd   && mem <= kLinuxAppMemEnd);<br>
>> >>> +#elif defined(TSAN_GO)<br>
>> >>> +  return mem <= kLinuxAppMemEnd;<br>
>> >>>  #else<br>
>> >>>    return mem >= kLinuxAppMemBeg && mem <= kLinuxAppMemEnd;<br>
>> >>>  #endif<br>
>> >>><br>
>> >>><br>
>> >>> _______________________________________________<br>
>> >>> llvm-commits mailing list<br>
>> >>> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> >>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
</div></div></blockquote></div><br></div></div>