[cfe-dev] Handling expansions

Pedro Delgado Perez pedro.delgadoperez at mail.uca.es
Fri Jan 10 05:07:03 PST 2014


Yesterday I tested my tool with a progam containing preprocessor directives. It was the first time I had this possibility into account and I had an stack dump when triying to obtain the file:

FullSourceLoc FullLocation = Context->getFullLoc(sourceLoc);
file = Context->getSourceManager().getFileEntryForID(FullLocation.getFileID())->getName();

Then, I added:

               FullLocation = FullLocation.getExpansionLoc();
               file= Context->getSourceManager()

And the result seemed ok. But when I tried to obtain again the file with:


I had another stack dump. How do you handle these directives? There are so many methods... that I'm not able to find a solution because I cannot understand very well whay is an expansion, an SEntryLoc...

My intention is to make a change in the directive. For instance, in this directive:
#define delete( a )   {        
when the calling to the method release is found, my tool should include an argument in the method. 

A doubt: when I make that change, it affects to every inkovation to the directive, isn't it? But, is there a way that the change only affects to a single directive invokation?

Thanks in advance,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140110/1c4b871f/attachment.html>

More information about the cfe-dev mailing list