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

G Raghuram contactraghu at gmail.com
Wed Jul 10 16:32:44 PDT 2013


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.
Thanks very much
--raghuram
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130710/3729aeb2/attachment.html>


More information about the cfe-dev mailing list