[cfe-dev] implementing clone for ASTNodes
Aleksei Sidorin via cfe-dev
cfe-dev at lists.llvm.org
Wed Jan 18 09:16:44 PST 2017
Hello Gaetano,
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.
I was thinking about "clone" approach some time ago, but the question
how to handle complex dependencies is still open here.
18.01.2017 19:55, Gaetano Checinski via cfe-dev пишет:
> I was wondering if anybody spend some efforts in implementing a clone
> Method for all ASTNodes?
>
> It seems to me, that the current approach implemented in the
> ASTImporter is error-prone and hard to maintain.
>
> Currently it looks to me that Decls / Stmt's are being probed for
> their type and then downcasted, eg.:
>
> /* ASTNodeImporter::VisitExplicitCastExpr */
> /* ASTImporter.cpp:6060 */
> switch (E->getStmtClass()) {
> case Stmt::CStyleCastExprClass: {
> CStyleCastExpr *CCE = cast<CStyleCastExpr>(E);
> return CStyleCastExpr::Create(Importer.getToContext(), T,
> E->getValueKind(), E->getCastKind(),
> SubExpr, &BasePath, TInfo,
> Importer.Import(CCE->getLParenLoc()),
> Importer.Import(CCE->getRParenLoc()));
> }
> /* more cases*/
>
>
>
> As the AST contains circular references and many nodes require an
> ASTContext
> for construction, i'm wondering how feasible it would be to implement
> the following interface for each Decl?
>
> virtual Decl* clone(
> ASTContext* newContext,
> DenseMap<Decl*, Decl*> ImportedDeclsCache = {}
> );
>
>
>
>
>
>
>
> <https://mailtrack.io/trace/link/b910ce4d02f08facbacacd7152c370d845d81397?url=https%3A%2F%2Fmailtrack.io%2F&signature=e6da9dfa433d9e41>Sent
> with Mailtrack
> <https://mailtrack.io/install?source=signature&lang=en&referral=gaetano.checinski@gmail.com&idSignature=22>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
--
Best regards,
Aleksei Sidorin,
SRR, Samsung Electronics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170118/d99adf80/attachment.html>
More information about the cfe-dev
mailing list