<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hello Ori,<br>
      <br>
      You can create different kinds of nodes directly. For example, to
      create a new namespace, you will need to use code like this:<br>
      <br>
      IdentifierInfo *IdInfo = Context.Idents.get("bar");<br>
      NamespaceDecl *NewNS = NamespaceDecl::Create(Context,
      Context.getTranslationUnitDecl(), false, StartLoc, IdLoc, IdInfo,
      OldDecl);<br>
      <br>
      You can take a look at constructors of different Decl kinds (and
      static ::Create() methods) in Decl.h and DeclCXX.h (and other
      Decl*.h) for more information.<br>
      To move a function to this namespace, you will need to set a new
      DeclContext for it:<br>
      <br>
      FD->setDeclContext(NewNS);<br>
      FD->setLexicalDeclContext(NewNS);<br>
      <br>
      <br>
      <br>
      09.01.2017 18:59, Ori Zaig via cfe-dev пишет:<br>
    </div>
    <blockquote
cite="mid:VI1PR0501MB26249792C2BF6FB53FD00E84AB640@VI1PR0501MB2624.eurprd05.prod.outlook.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p
style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;background:white"><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">I
            need to insert new nodes to AST. For instance, adding a
            namespace to a function: Turning this -<o:p></o:p></span></p>
        <pre style="background:#EFF0F1;max-height: 600px;word-wrap: normal;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;widows: 2;-webkit-text-stroke-width: 0px;overflow:auto;word-spacing:0px"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">void foo();<o:p></o:p></span></code></pre>
        <pre style="background:#EFF0F1"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1"><o:p> </o:p></span></code></pre>
        <p
style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;background:white;font-variant-ligatures:
          normal;font-variant-caps: normal;orphans: 2;widows:
          2;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">into
            this -<o:p></o:p></span></p>
        <pre style="background:#EFF0F1;max-height: 600px;word-wrap: normal;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;widows: 2;-webkit-text-stroke-width: 0px;overflow:auto;word-spacing:0px"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">namespace bar {<o:p></o:p></span></code></pre>
        <pre style="background:#EFF0F1"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">    void foo();<o:p></o:p></span></code></pre>
        <pre style="background:#EFF0F1"><code><span style="font-family:Consolas;color:#242729;border:none windowtext 1.0pt;padding:0in;background:#EFF0F1">}<o:p></o:p></span></code></pre>
        <p
style="margin:0in;margin-bottom:.0001pt;background:white;font-variant-ligatures:
          normal;font-variant-caps: normal;orphans: 2;widows:
          2;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729"><o:p> </o:p></span></p>
        <p style="margin:0in;margin-bottom:.0001pt;background:white"><span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">I
            want to edit the AST directly - I prefer not using
            source-to-source compilation<o:p></o:p></span></p>
        <p
style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;background:white;font-variant-ligatures:
          normal;font-variant-caps: normal;orphans: 2;widows:
          2;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span
style="font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729">Tnx<o:p></o:p></span></p>
        <p class="MsoNormal"><o:p> </o:p></p>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
    </blockquote>
    <br>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
Best regards,
Aleksei Sidorin
Software Engineer, 
IMSWL-IMCG, SRR, Samsung Electronics
</pre>
  </body>
</html>