[cfe-dev] Not able to print correct line numbers for then part of if statement,

Richard Smith richard at metafoo.co.uk
Wed Jul 10 16:53:51 PDT 2013


On Wed, Jul 10, 2013 at 4:32 PM, G Raghuram <contactraghu at gmail.com> wrote:
>
>
> Hi,
>
>  I am playing around a bit of with clang and have hit a problem. For a Clang
> input with if statement, I am trying to obtain line number of beginning of
> Then statement and then print it out. But I am not able to make sense of the
> output. Can you please help.  In a nutshell I am trying to get presumed loc
> from sourceloc of Then statement. For the following input, its printing 6
> and 12 instead of 4 and 8.
>
>
> Detailed description can be found at
>
> http://stackoverflow.com/questions/17582628/not-able-to-print-correct-line-numbers-for-then-part-of-if-statement-clang
>
> My code (250 lines, but important stuff is between lines 100 and 105) is at
> http://pastebin.com/txF9Bwa4
>
>
> My input is http://pastebin.com/hF5yMMAz
>
> 1 #include <stdio.h>
>
>
> 2 int func (int abc, int xyz) {
>
> 3     if (abc-1)
> 4     {
> 5         printf ("1\n");
> 6     }
>
>
> 7      if (abc-2)
> 8     {
> 9         printf ("2\n");
>
> 10 }
>
> 11
>
> 12 return 0;
>
> 13 }
>
>
>
> Please let me know if you need any additional information. Compilation
> instructions are in the stackoverflow link.

I've posted an answer on stackoverflow.



More information about the cfe-dev mailing list