Skip to content

Recovering pre-parsing line numbers of an SgLocatedNode #223

@jacksonvanover

Description

@jacksonvanover

I am using the OFP frontend. Can anyone recommend a means of recovering the pre-parsing line number of an SgLocatedNode? I have tried ->get_file_info()->get_line(), ->get_file_info()->get_raw_line(), and ->get_file_info()->get_physical_line(), though each of these gives the line number of the node in the resulting unparsed file which can be dramatically different. I am aware that it is expected behavior to have the unparsed file differ from the original.

What I am trying to accomplish is to automatically map execution counts for lines (from using gcov or some such on the original source) to the AST nodes from that line.

A potential workaround is to try running the profiler on a binary compiled using the unparsed files, though this is cumbersome since the unparsed files often do not compile without some manual massaging.

I have also tried adding a line before each line that containing a single comment with the original line number which I then access via ->getAttachedPreprocessingInfo(), though this admittedly hacky approach also fails since ROSE seems to arbitrarily move some comments around or remove them altogether. I can't help but feel like I'm missing something quite obvious?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions