[cfe-dev] Clang AST: how to get more precise debug information in certain cases?
Stanislav Pankevich via cfe-dev
cfe-dev at lists.llvm.org
Sat Jun 1 14:29:00 PDT 2019
Hi all,
I would like to obtain the correct source locations from the Clang AST
information but I am having some difficulties in doing that.
The attached screenshot example-1 demonstrates running clang -Xclang
-ast-dump foo.c on the following code:
int foo(int aaaaa, int bbbbb) {
if (aaaaa == bbbbb) {
return 1;
} else {
return 0;
}
}
The source locations for the BinaryOperator only cover the "aaaaa =="
part, not the full expression "aaaaa == bbbbb".
In other cases (see the example-2) only the part of the second operand
is covered but never the whole expression.
My questions are:
1) Is there a specific reason for this behavior?
2) Which API should I use to obtain more precise information about the
source locations? I have tried using getExpansionColumnNumber() and
getColumnNumber() functions of the SourceManager class but they both
give me the results similar to those of -ast-dump and I never get the
precise information.
Thanks in advance.
Stanislav Pankevich
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example-2-binary-operator-debug-info-other-examples.png
Type: image/png
Size: 32265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190601/d51d9f88/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example-1-binary-operator-debug-info.png
Type: image/png
Size: 441893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190601/d51d9f88/attachment-0001.png>
More information about the cfe-dev
mailing list