Changing column number in SourceLocation object

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing column number in SourceLocation object

Kristof Beyls via cfe-dev
Dear All,

Let suppose, I have a object "startLoc" of class "SourceLocation". The object contains line and column number information. How can I modify the line number in startLoc object? I was expecting "set()" kind of methods for class SourceLocation, but I could not find any. I would be thankful for your help.

Regards
Ijaz



_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Changing column number in SourceLocation object

Kristof Beyls via cfe-dev

Hi Ijaz,

a SourceLocation object points to a specific location inside a buffer. The line and column information is derived from that via the SourceManager. The locations are immutable, but you can create a modified copy with SourceLocation::getLocWithOffset.

I'm not familiar with a direct way to change the line number, but maybe you can figure out an appropriate method for your use-case with the helpers in the Preprocessor or Lexer classes (e.g. advance to next token).

-Rafael

On 27.10.19 06:07, Ijaz Ahmed via cfe-dev wrote:
Dear All,

Let suppose, I have a object "startLoc" of class "SourceLocation". The object contains line and column number information. How can I modify the line number in startLoc object? I was expecting "set()" kind of methods for class SourceLocation, but I could not find any. I would be thankful for your help.

Regards
Ijaz



_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev