<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">CC'ing cfe-dev again.<br>
<br>
There should be no infinite loops in ASTImporter as they are
broken by GetAlreadyImportedOrNull() method.<br>
It is also interesting for me what will be the difference between
clone() methods and methods of ASTImporter. Do you have any
example?<br>
<br>
<br>
18.01.2017 20:24, Gaetano Checinski пишет:<br>
</div>
<blockquote
cite="mid:CAN0NuG6r+V5-rwachTi=Y59R1EGA_HjXQ92RV8K1FvSo0U4QEg@mail.gmail.com"
type="cite">
<div dir="ltr">The ASTImporter creates a lookup table (
DenseMap<Decl*,Decl*> importedDecls), to keep track of the
imported Decls and not to end up in a infinite loop.
<div>This is why my proposed signature for the clone contains
not only an <font face="monospace, monospace">ASTContext</font>
to clone into but also a `<span
style="font-family:monospace,monospace;font-size:12.8px">DenseMap<Decl*,
Decl*>& ImportedDeclsCache` </span><span
style="font-size:12.8px"><font face="arial, helvetica,
sans-serif">to keep track of those already imported Decls.</font></span></div>
<div><br>
</div>
<img moz-do-not-send="true" class="mailtrack-img"
src="https://mailtrack.io/trace/mail/af4e178af473233e4396efd31cda65215dbd3490.png?u=931501"
height="0" width="0"></div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2017-01-18 17:16 GMT+00:00 Aleksei
Sidorin <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:a.sidorin@samsung.com" target="_blank">a.sidorin@samsung.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div class="m_5220777893620003423moz-cite-prefix">Hello
Gaetano,<br>
<br>
ASTImporter not just "imports" AST nodes. It also
searches if they already exist in the destination AST.
It is required to get a consistent AST.<br>
<br>
I was thinking about "clone" approach some time ago, but
the question how to handle complex dependencies is still
open here.<br>
<br>
<br>
<br>
18.01.2017 19:55, Gaetano Checinski via cfe-dev пишет:<br>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<div dir="ltr">I was wondering if anybody spend some
efforts in implementing a clone Method for all
ASTNodes?
<div><br>
</div>
<div>It seems to me, that the current approach
implemented in the ASTImporter is error-prone
and hard to maintain.</div>
<div><br>
</div>
<div>Currently it looks to me that Decls / Stmt's
are being probed for their type and then
downcasted, eg.:<br>
<br>
</div>
<blockquote style="margin:0 0 0
40px;border:none;padding:0px">
<div><font face="monospace, monospace">/* ASTNodeImporter::<wbr>VisitExplicitCastExpr
*/</font></div>
<div><font face="monospace, monospace">/*
ASTImporter.cpp:6060 */</font></div>
<div><font face="monospace, monospace">switch
(E->getStmtClass()) {</font></div>
<div><font face="monospace, monospace"> case
Stmt::CStyleCastExprClass: {</font></div>
<div><font face="monospace, monospace">
CStyleCastExpr *CCE =
cast<CStyleCastExpr>(E);</font></div>
<div><font face="monospace, monospace">
return CStyleCastExpr::Create(<wbr>Importer.getToContext(),
T,</font></div>
<div><font face="monospace, monospace">
E->getValueKind(), E->getCastKind(),</font></div>
<div><font face="monospace, monospace">
SubExpr, &BasePath, TInfo,</font></div>
<div><font face="monospace, monospace">
Importer.Import(CCE-><wbr>getLParenLoc()),</font></div>
<div><font face="monospace, monospace">
Importer.Import(CCE-><wbr>getRParenLoc()));</font></div>
<div><font face="monospace, monospace">}</font></div>
<div><font face="monospace, monospace">/* more
cases*/</font></div>
</blockquote>
<div><br>
</div>
<div><br>
</div>
<div>As the AST contains circular references and
many nodes require an ASTContext</div>
<div>for construction, i'm wondering how feasible
it would be to implement the following interface
for each Decl?</div>
<div><br>
</div>
<blockquote style="margin:0 0 0
40px;border:none;padding:0px">
<div><font face="monospace, monospace"> virtual
Decl* clone(</font></div>
<div><font face="monospace, monospace">
ASTContext* newContext, </font></div>
<div><font face="monospace, monospace">
DenseMap<Decl*, Decl*>
ImportedDeclsCache = {}</font></div>
<div><font face="monospace, monospace"> );</font></div>
</blockquote>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<br>
<br>
<div class="m_5220777893620003423mt-signature"><a
moz-do-not-send="true"
href="https://mailtrack.io/trace/link/b910ce4d02f08facbacacd7152c370d845d81397?url=https%3A%2F%2Fmailtrack.io%2F&signature=e6da9dfa433d9e41"
class="m_5220777893620003423gmail-mt-signature-logo"
style="text-decoration:none" target="_blank"><img
moz-do-not-send="true"
src="https://s3-eu-west-1.amazonaws.com/mailtrack-crx/icon-signature.png"
height="14" width="16"> </a><font
class="m_5220777893620003423mt-signature-text"
color="#999999">Sent with <a
moz-do-not-send="true"
href="https://mailtrack.io/install?source=signature&lang=en&referral=gaetano.checinski@gmail.com&idSignature=22"
class="m_5220777893620003423mt-install"
target="_blank">Mailtrack</a></font></div>
</div>
<img moz-do-not-send="true"
class="m_5220777893620003423mailtrack-img"
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
height="0" width="0"></div>
<br>
<fieldset
class="m_5220777893620003423mimeAttachmentHeader"></fieldset>
<br>
</div>
</div>
<pre>______________________________<wbr>_________________
cfe-dev mailing list
<a moz-do-not-send="true" class="m_5220777893620003423moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>
<a moz-do-not-send="true" class="m_5220777893620003423moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<p>
</p>
<pre class="m_5220777893620003423moz-signature" cols="72">--
Best regards,
Aleksei Sidorin,
SRR, Samsung Electronics
</pre>
</font></span></div>
</blockquote></div>
</div>
</blockquote>
<p>
</p><pre class="moz-signature" cols="72">--
Best regards,
Aleksei Sidorin,
SRR, Samsung Electronics
</pre></body></html>