<div dir="ltr">Looking at the code for tautological compares against zero, there already is an exception for macros and enum constants.  I think adding an exception for being defined in an #if block would be a good addition, however I am not sure if that information is propagated past the preprocessor.<br>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 6, 2014 at 9:18 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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" target="_blank">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" target="_blank">dblaikie@gmail.com</a>> 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" target="_blank">dvyukov@google.com</a>> 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: <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>
>>> --- 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 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" target="_blank">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>
</blockquote></div><br></div></div>