<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>This is a question relating clang-refactor i guess. Maybe ask on
cfe-dev since its development specific.<br>
</p>
<br>
<div class="moz-cite-prefix">Am 05.05.2018 um 02:22 schrieb ? ?? via
cfe-users:<br>
</div>
<blockquote type="cite"
cite="mid:SG2PR06MB12328AF903006F276FFEB95692850@SG2PR06MB1232.apcprd06.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style>body { line-height: 1.5; }body { font-size: 10.5pt; font-family: ????; color: rgb(0, 0, 0); line-height: 1.5; }</style>
<div><span></span>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
Dear Clang users: </div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
I have a class named classA in a.h and a.cpp file. it
have some methods, I want to add a new method definition to
a.h and add new method body after last method use clang . How
to do it ? </div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
I know the RecursiveASTVisitor::VisitCXXRecordDecl(...)
can visit CXXRecordDecl and CXXMethodDecl , Rewriter be used
to write code . but how to create new method definition and
body to a.h and a.cpp?</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
//a.h file</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
classA {</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
protected:</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
int filed;</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
public:</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
void method1();</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
void method2();</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
//insert a new method</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
<span style="font-size: 12pt;">}</span><br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
//a.cpp file</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
void classA::method1()</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
{</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
..........</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
}</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
void classA::method2()</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
{</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
...........</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
}</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
// inset new method body</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
Yours truly<br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
<div style="line-height: normal; font-family: Calibri,
Helvetica, sans-serif; font-size: 12pt;">
Robert</div>
</div>
<div><br>
</div>
<hr style="width: 210px; height: 1px;" color="#b5c4df" size="1"
align="left">
<div><span>
<div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE:
10pt">
<div><a class="moz-txt-link-abbreviated" href="mailto:licux6@hotmail.com">licux6@hotmail.com</a></div>
</div>
</span></div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
cfe-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-users@lists.llvm.org">cfe-users@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a>
</pre>
</blockquote>
<br>
</body>
</html>