[cfe-dev] A bug in PresumedLoc?
maxs
xtxwy.ustc at gmail.com
Mon Dec 2 23:58:12 PST 2013
sorry, the "44 1 45 4 => incorrect, should be 44 1 45 4 "
should be "44 1 45 4 => incorrect, should be 44 1
45 6"
> I use the following code to get source location:
> =================================
>
> 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 test case is:
>
> =================================
> (1)
>
> for(i = 0 ; i<100;i++)
> sum++;
>
> (2)
>
> for(i = 0 ; i<100;i++)
> {sum++;}
>
> =================================
>
> The result is:
>
> =================================
> (1)
>
> 44 1 45 4 => incorrect, should be 44 1 45 4
>
> (2)
>
> 44 1 45 8 => correct
>
> =================================
>
> So, is it a bug? or I misunderstand it?
>
> Thanks.
More information about the cfe-dev
mailing list