[cfe-dev] Function Rewriting

Makslane Araújo Rodrigues makslane at hotmail.com
Tue Aug 11 05:44:53 PDT 2009


Ok, Thanks

To: 
Date: Mon, 10 Aug 2009 23:20:49 -0700
From: rjmccall at apple.com
CC: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] Function Rewriting






  
  


Makslane Araújo Rodrigues wrote:

  
  What I do is something like this:
  

  
  
  void AddParameter(FunctionDecl *FD) 
  { 
    SourceLocation loc;
   for
(FunctionDecl::param_iterator I=FD->param_begin(),
E=FD->param_end(); I!=E; ++I)
   {
   loc
= (*I)->getLocation();
   }
  

  
    Rewrite.InsertTextAfter(loc, ", int y", 7);
  }
  

  
  The problem is instead I get the void func(int x, int y), I
get func(int , int yx)
  

  
  Can someone tell me what is wrong?
  



"loc" is the location of the start of the identifier, not the location
of the end of the parameter declaration;  thus when you insert at that
point, it inserts before the variable name.  You want to insert after
the end of the variable declaration;  unfortunately, it looks like that
location just isn't preserved in the AST.  That's definitely worth
filing a bug about.



John.

_________________________________________________________________
Novo Internet Explorer 8. Baixe agora, é grátis!
http://brasil.microsoft.com.br/IE8/mergulhe/?utm_source=MSN%3BHotmail&utm_medium=Tagline&utm_campaign=IE8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090811/1b624a79/attachment.html>


More information about the cfe-dev mailing list