<div dir="ltr">This problem is relevant to comments as well.<div><br></div><div>I'm not sure if there's an easy solution, but some hand-rolled options are available. One way is to re-lex the range and try to find preprocessor directives (and comments) by analyzing token sequences. Another approach would be to subscribe to PPCallbacks, gather all locations of #if/#else/... into a set and then look up any values in this set that fall between the bounds of your range.</div><div><br></div><div>-- Alex<br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 25, 2015 at 2:07 AM, Richard <span dir="ltr"><<a href="mailto:legalize@xmission.com" target="_blank">legalize@xmission.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm enhancing clang-tidy to replace:<br>
<br>
    if (expr)<br>
      return true;<br>
    return false;<br>
<br>
with<br>
<br>
    return expr;<br>
<br>
I am running the transformation on the LLVM/clang code as a test bed.<br>
In the course of examining the results it turned up this one in<br>
llvm/lib/Analysis/ConstantFolding.cpp:<br>
<br>
with<br>
<br>
 /// Test if a floating-point exception was raised.<br>
 static inline bool llvm_fenv_testexcept() {<br>
   int errno_val = errno;<br>
-  if (errno_val == ERANGE || errno_val == EDOM)<br>
-    return true;<br>
-#if defined(HAVE_FENV_H) && HAVE_DECL_FE_ALL_EXCEPT && HAVE_DECL_FE_INEXACT<br>
-  if (fetestexcept(FE_ALL_EXCEPT & ~FE_INEXACT))<br>
-    return true;<br>
-#endif<br>
-  return false;<br>
+  return errno_val == ERANGE || errno_val == EDOM;<br>
 }<br>
 } // End namespace<br>
<br>
Clearly, this is not behavior preserving.  According to the AST, the<br>
part that is #if'ed out doesn't exist.<br>
<br>
What's the best way to identify such things so that the tool's default<br>
behavior would be to leave these alone?<br>
<br>
PS: Mail filters are blocking my messages, so ignore this, its<br>
only for them.  Lorem ipsum dolor sit amet, consectetur adipiscing<br>
elit. Phasellus consequat ullamcorper mollis. Sed blandit semper tortor<br>
ultricies dictum. Proin hendrerit et quam in sagittis. Maecenas vel<br>
blandit ante, in auctor sem.  Phasellus condimentum leo vel finibus<br>
viverra. Duis fermentum sollicitudin est, ac iaculis lectus auctor vel.<br>
Nam condimentum nulla feugiat, venenatis nibh a, elementum nulla. Nulla<br>
vitae malesuada eros. Nulla cursus maximus ligula non hendrerit.<br>
<br>
Curabitur lobortis nulla vel sapien posuere, id aliquam orci<br>
bibendum. Vestibulum at vulputate risus. Proin in purus commodo,<br>
tempus lectus vitae, faucibus nunc. Aenean congue faucibus elit, sit<br>
amet facilisis nibh ultrices eget. Nam pulvinar leo ac nunc ultricies,<br>
nec tincidunt nulla tincidunt. Etiam placerat felis tellus, ut ultricies<br>
nunc ultricies quis. In placerat sapien nec ultricies mattis. Integer<br>
sed tempor orci, ac imperdiet orci. Integer ac augue et augue convallis<br>
faucibus.<br>
<span class="HOEnZb"><font color="#888888">--<br>
"The Direct3D Graphics Pipeline" free book <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__tinyurl.com_d3d-2Dpipeline&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=VMyr8LU1vdyM9bp64yHmFIvava7jzqC06UoK7T8ctbQ&s=04qA6VOMRUg1FRVDSkG1XzIkz0_dM_joA02pB-cJZWY&e=" target="_blank">http://tinyurl.com/d3d-pipeline</a>><br>
     The Computer Graphics Museum <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__ComputerGraphicsMuseum.org&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=VMyr8LU1vdyM9bp64yHmFIvava7jzqC06UoK7T8ctbQ&s=AbYqOtZnoTd8UVu4mbM5ZN-IB_RbUaWNf_xES2qLJTc&e=" target="_blank">http://ComputerGraphicsMuseum.org</a>><br>
         The Terminals Wiki <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__terminals.classiccmp.org&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=VMyr8LU1vdyM9bp64yHmFIvava7jzqC06UoK7T8ctbQ&s=lApKpDO40etG1p5D7IXe_pYAJVhvqDkr3H7TPQTHSms&e=" target="_blank">http://terminals.classiccmp.org</a>><br>
  Legalize Adulthood! (my blog) <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__LegalizeAdulthood.wordpress.com&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=VMyr8LU1vdyM9bp64yHmFIvava7jzqC06UoK7T8ctbQ&s=yGIM0ywGS5fWnu59ALzfYmWTNhm-6NRlpOy0tVmQEyY&e=" target="_blank">http://LegalizeAdulthood.wordpress.com</a>><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</font></span></blockquote></div><br><div><br></div>
</div></div></div>