<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Ok, Thanks<br><br><hr id="stopSpelling">To: <br>Date: Mon, 10 Aug 2009 23:20:49 -0700<br>From: rjmccall@apple.com<br>CC: cfe-dev@cs.uiuc.edu<br>Subject: Re: [cfe-dev] Function Rewriting<br><br>




  
  <title></title>


Makslane Araújo Rodrigues wrote:
<blockquote cite="mid:COL106-W245A16F36DCB7858AFB583DD070@phx.gbl">
  <style>
.ExternalClass .EC_hmmessage P
{padding:0px;}
.ExternalClass body.EC_hmmessage
{font-size:10pt;font-family:Verdana;}
</style>
  <div>What I do is something like this:</div>
  <div><br>
  </div>
  <div>
  <div>void AddParameter(FunctionDecl *FD) </div>
  <div>{<span class="EC_Apple-tab-span" style="white-space:pre"> </span></div>
  <div>  SourceLocation loc;</div>
  <div><span class="EC_Apple-tab-span" style="white-space:pre"> </span>for
(FunctionDecl::param_iterator I=FD->param_begin(),
E=FD->param_end(); I!=E; ++I)</div>
  <div><span class="EC_Apple-tab-span" style="white-space:pre"> </span>{</div>
  <div><span class="EC_Apple-tab-span" style="white-space:pre"> </span>loc
= (*I)->getLocation();</div>
  <div><span class="EC_Apple-tab-span" style="white-space:pre"> </span>}</div>
  <div><br>
  </div>
  <div>  Rewrite.InsertTextAfter(loc, ", int y", 7);</div>
  <div>}</div>
  <div><br>
  </div>
  <div>The problem is instead I get the void func(int x, int y), I
get func(int , int yx)</div>
  <div><br>
  </div>
  <div>Can someone tell me what is wrong?</div>
  </div>
</blockquote>
<br>
"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.<br>
<br>
John.<br><br /><hr />Instale o novo Internet Explorer 8 versão especial para o MSN.  <a href='http://ie8.msn.com/microsoft/internet-explorer-8/pt-br/ie8.aspx' target='_new'>Download aqui</a></body>
</html>