<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Makslane Araújo Rodrigues wrote:
<blockquote cite="mid:COL106-W245A16F36DCB7858AFB583DD070@phx.gbl"
 type="cite">
  <style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.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="Apple-tab-span" style="white-space: pre;"> </span></div>
  <div>  SourceLocation loc;</div>
  <div><span class="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="Apple-tab-span" style="white-space: pre;"> </span>{</div>
  <div><span class="Apple-tab-span" style="white-space: pre;"> </span>loc
= (*I)->getLocation();</div>
  <div><span class="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>
</body>
</html>