[LLVMdev] A problem about the location of ForStmt,

张其良 qiliangzh at gmail.com
Sun Dec 1 23:30:57 PST 2013


I get the location with :
    SourceManager &SM = context.getSourceManager();
    int lineStart = SM.getPresumedLoc(SR->getBegin()).getLine();
    int lineEnd = SM.getPresumedLoc(SR->getEnd()).getLine();
    int colStart = SM.getPresumedLoc(SR->getBegin()).getColumn();
    int colEnd = SM.getPresumedLoc(SR->getEnd()).getColumn();
    llvm::outs() << "For:" << lineStart << "  " << colStart << "  " <<
lineEnd << "  " << colEnd << " \n";

the testCase:

for(i = 0 ; i<100;i++)
sum++;

result is:

For:44  1  45  4

But when the testcase :

for(i = 0 ; i<100;i++)
{sum++;}

result is

For:44  1  45  8

I don't know  whether is a bug.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131202/9f7b17fd/attachment.html>


More information about the llvm-dev mailing list