<div dir="ltr"><div><div>I'm seeing some strange results using a RecursiveASTVisitor on some C code. The following code compiles fine with clang:<br><br>static __inline unsigned int<br>__bswap_32 (unsigned int __bsx)<br>{<br>  return __builtin_bswap32 (__bsx);<br>}<br><br></div>But I get the following diagnostic when calling ParseAST:<br><br><span style="color:rgb(0,0,0)">C:/BUG/builtin.c:4:10: </span><span style="color:rgb(255,0,0)">error: </span><span style="color:rgb(0,0,0)">use of unknown builtin '__builtin_bswap32'</span>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(80,80,80)">  return __builtin_bswap32 (__bsx);</span></p><p style="margin:0px;text-indent:0px"><span style="color:rgb(80,80,80)">         ^<br></span></p><br></div><div>It seems odd that I should get this error, as __builtin_bswap32() is supported. Any idea why?<br><br></div>Another interesting thing - I get the following results for each of the getDiagnostics() calls:<br><span style="color:rgb(0,0,0)">hasUncompilableErrorOccurred() = True</span>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0)">hasUnrecoverableErrorOccurred() = False</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0)">hasFatalErrorOccurred() = False</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0)">hasErrorOccurred() = True</span></p>
<p style="margin:0px;text-indent:0px;color:rgb(0,0,0)"><br></p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)">As a point of comparison, for the following code:</p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)">int foo()<br>{<br>  retrun 42;  // Typo on return<br>}</p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)"><br></p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)">I get:</p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">C:/Src/cp.PP/BUG/bug.c:3:3: </span><span style="color:rgb(255,0,0)">error: </span><span style="color:rgb(0,0,0)">use of undeclared identifier 'retrun'</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(80,80,80)">    retrun 42;</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,128,0)">    ^</span></p><p style="margin:0px;text-indent:0px"><br><span style="color:rgb(0,0,0)">hasUncompilableErrorOccurred() = True</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0)">hasUnrecoverableErrorOccurred() = True</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0)">hasFatalErrorOccurred() = False</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0)">hasErrorOccurred() = True</span></p>
<p style="margin:0px;text-indent:0px;color:rgb(0,0,0)"><br></p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)">For code that generates only a warning, the above 4 calls all return False.</p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)">I guess I'm not sure what the difference is between <span style="color:rgb(0,0,0)">hasUncompilableErrorOccurred() and </span><br><span style="color:rgb(0,0,0)">hasErrorOccurred(), or what exactly the other 2 functions do. Any enlightenment there?</span></p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)"><br></p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)">This is with:</p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)">clang version 3.7.0 (trunk 230884)<br>Target: i686-pc-windows-gnu<br>Thread model: posix</p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)"><br></p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0)"></span></p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">Thanks,</span></p><p style="margin:0px;text-indent:0px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">Robert<br></span></p><br></div>