<div dir="ltr"><div>Thanks for your help Alexey. </div><div><br></div><div>It made me realize that I forgot a very important step of my problem:<br></div><div><br></div><div>Before giving the file to be monitored to clang, we preprocess the source with gcc.</div><div><br></div><div>Which means that is if the original source file <font face="monospace, monospace">/tmp/test.c</font> is:</div><div><font face="monospace, monospace"><br></font></div><div><div><span style="background-color:rgb(255,255,255)"><font face="monospace, monospace">#include <stdlib.h></font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="monospace, monospace"><br></font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="monospace, monospace">int main()</font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="monospace, monospace">{</font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="monospace, monospace">  int* a = 0;</font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="monospace, monospace">  if (a != NULL)</font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="monospace, monospace">    return 1;</font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="monospace, monospace">  return 0;</font></span></div><div><span style="background-color:rgb(255,255,255)"><font face="monospace, monospace">} </font></span></div></div><div><br></div><div><br></div><div>Clang would receive (I only pasted the last 15 lines) :</div><div><font face="monospace, monospace"><br></font></div><div><div><font face="monospace, monospace"># 2 "/tmp/test.c" 2</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"># 3 "/tmp/test.c"</font></div><div><font face="monospace, monospace">int main()</font></div><div><font face="monospace, monospace">{</font></div><div><font face="monospace, monospace">  int* a = 0;</font></div><div><font face="monospace, monospace">  if (a != </font></div><div><font face="monospace, monospace"># 6 "/tmp/test.c" 3 4</font></div><div><font face="monospace, monospace">          ((void *)0)</font></div><div><font face="monospace, monospace"># 6 "/tmp/test.c"</font></div><div><font face="monospace, monospace">              )</font></div><div><font face="monospace, monospace">    return 1;</font></div><div><font face="monospace, monospace">  return 0;</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>In that case, I would like to get the location of the enclosing parenthesis for the 'IfStmt' (the one just before the 'return 1;'). I tried to toy with the lexer to get it but with no success.</div><div>Do you have any idea ?</div><div><br></div><div>Best regards</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-02-28 10:21 GMT+01:00 Alexey Knyshev <span dir="ltr"><<a href="mailto:alexey.knyshev@gmail.com" target="_blank">alexey.knyshev@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi Dorian,<br><br></div>Hope it would be helpful:<br><a href="https://stackoverflow.com/a/24223347" target="_blank">https://stackoverflow.com/a/<wbr>24223347</a><br><br></div>Regards, Alexey K<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2018-02-28 12:11 GMT+03:00 Dorian Haglund via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hello,<div><br></div><div>I'm using the clang library to monitor (among other things) the if statements in my program.</div><div><br></div><div>i need to get the location of the right parenthesis of the condition of the if (and while) statements.</div><div><br></div><div>I've tried things such as:</div><div><br></div><div><pre class="m_-3638010740196099213m_8192027457303161906gmail-lang-cpp m_-3638010740196099213m_8192027457303161906gmail-prettyprint m_-3638010740196099213m_8192027457303161906gmail-prettyprinted" style="margin:0px 0px 1em;padding:5px;border:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-weight:400;font-stretch:inherit;font-size:13px;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);display:block;color:rgb(57,51,24);word-wrap:normal;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:13px;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:rgb(239,240,241);white-space:inherit"><span class="m_-3638010740196099213m_8192027457303161906gmail-kwd" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(16,16,148)">auto</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)"> condLocEnd </span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">=</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)"> statement</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">-></span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">getCond</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">()-></span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">getLocEn<wbr>d</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">();</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">
</span><span class="m_-3638010740196099213m_8192027457303161906gmail-kwd" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(16,16,148)">auto</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)"> condLoc </span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">=</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)"> </span><span class="m_-3638010740196099213m_8192027457303161906gmail-typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(43,145,175)">Lexer</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">::</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">findLocationAfterToken</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">(</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)"><wbr>condLocEnd</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">,</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)"> tok</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">::</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">r_paren</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">,</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)"> sm</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">,</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)"> </span><span class="m_-3638010740196099213m_8192027457303161906gmail-typ" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(43,145,175)">LangOptions</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">(),</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pln" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)"> </span><span class="m_-3638010740196099213m_8192027457303161906gmail-kwd" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(16,16,148)">false</span><span class="m_-3638010740196099213m_8192027457303161906gmail-pun" style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;color:rgb(48,51,54)">);</span></code></pre><div class="m_-3638010740196099213m_8192027457303161906gmail-post-text" style="margin:0px 0px 5px;padding:0px;border:0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-weight:400;font-stretch:inherit;font-size:15px;line-height:1.3;font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;vertical-align:baseline;box-sizing:inherit;width:667.003px;word-wrap:break-word;color:rgb(36,39,41);letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;clear:both">Unfortunately<span> </span><code style="margin:0px;padding:1px 5px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:13px;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:rgb(239,240,241);white-space:pre-wrap">condLoc</code><span> </span>is invalid when the condition contains a macro. Eg:<span> </span><code style="margin:0px;padding:1px 5px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:13px;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:rgb(239,240,241);white-space:pre-wrap">if(p == NULL)</code>. I can't figure out how to get the location of the right parenthesis. </p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;box-sizing:inherit;clear:both">Do you know how to get it ? If it is not possible, could you explain why ?</p></div>Best regards,<span class="m_-3638010740196099213HOEnZb"><font color="#888888"><br class="m_-3638010740196099213m_8192027457303161906gmail-Apple-interchange-newline"><br></font></span></div><span class="m_-3638010740196099213HOEnZb"><font color="#888888"><div><div><div><br></div>-- <br><div class="m_-3638010740196099213m_8192027457303161906gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Dorian Haglund<br></div></div></div>
</div></div></font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div class="m_-3638010740196099213gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><a href="https://www.linkedin.com/profile/view?id=AAMAABn6oKQBDhBteiQnWsYm-S9yxT7wQkfWhSw" target="_blank">linkedin.com/profile</a><br><br><a href="http://github.com/alexeyknyshev" target="_blank">github.com/alexeyknyshev</a><span></span><a href="http:///" target="_blank"></a><span></span><br><a href="https://bitbucket.org/alexeyknyshev/" target="_blank">bitbucket.org/alexeyknyshev</a><br></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Dorian Haglund<br></div></div></div>
</div>