[cfe-dev] Getting preprocessed text between two source location.

Paolo Bolzoni bolzoni at cs.unipr.it
Mon Feb 16 12:51:30 PST 2009


dear cfe list,

I need to get the preprocessed text between two source locations in order to
Lex again and check for code proprieties (e.g., in a const int declaration see
if it was actually `int const' or `const int')


This was my idea:

1- using the source manager I get the spelling location from the begin
source location and end source location.

2- I get the character data from both spelling locations.

3- Being begin and end the two pointers, I have the text in the [begin,
end[ range.

But it does not work. While in presence of macro the result seems
unpredictable, sometimes I even get segfaults.


Thanks,
pb



More information about the cfe-dev mailing list