[cfe-dev] Debug Info and Multi-Line statements (particularly "do" statements)

Richard Smith richard at metafoo.co.uk
Fri Jan 25 15:42:13 PST 2013


On Fri, Jan 11, 2013 at 9:25 AM, Peter Ohmann <ohmann at cs.wisc.edu> wrote:
> Hello all,
>
> While I understand that debug data is best-effort, I am running into some
> trouble with an analysis tool I'm building partially using an LLVM pass.
> There are two (seemingly directly related) cases where debug data is not
> missing (which wouldn't be a problem for me) but very misleading.
>
> First, in the case of multi-line statements, clang will assign the debug
> data for each expression to be the first line of the statement but continue
> incrementing the column number past the number of columns on the line.  The
> following code gives an example:
> [1] int foo(){
> [2]   int x, y, z;
> [3]   if(x < y ||
> [4]      y < z){
> [5]     x++;
> [6]   }
> [7] }
> In this example, when my LLVM pass gets the bitcode both the (x<y) and (y<z)
> expressions are assigned DebugLocs which have line number 3 (but with
> increasing column numbers).

When I try this, in the IR produced by 'clang -g', they both have line
3 column 0. If I use 'clang -g -gcolumn-info', they both have line 3
column 3 (the location of the 'if' token). That seems to make somewhat
more sense, but is still probably not what we want.



More information about the cfe-dev mailing list