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

Eric Christopher echristo at gmail.com
Thu Jan 24 01:48:33 PST 2013


Hi Peter,

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).
>
>
This...


> Second, in the case of a do-while statement where the closing } and the
> while condition are not on the same line, all expressions in the while
> condition are assigned the line number of the }.  The following code gives
> an example:
> [1] int foo(){
> [2]   int x;
> [3]   do
> [4]   {
> [5]     x++;
> [6]   }
> [7]   while(x < 10);
> [8] }
> In this case, the DebugLoc for the (x<10) expression lists line number 6.
>
>
and this are both really weird. The line (and column with -gcolumn-info)
are generally handled by the source ranges on the individual statements,
but looking in the IR those are the line's we're giving. If you file a bug
we'll probably get to it eventually, but source locations are set in the
debug info via setLocation from lib/CodeGen/CGDebugInfo.cpp. You'll
probably want to look for the particular AST nodes here and see where
they're setting locations. I think they're likely simple so you might want
to check on the SourceLocation for the individual nodes and see what the
begin and end are.

-eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130124/f66e8738/attachment.html>


More information about the cfe-dev mailing list