[PATCH] D156461: [clang][ASTImporter] Merge implicit ctors with definition

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 18 08:34:24 PDT 2023


balazske added a comment.

After import we get a new AST that looks like this:

  |-CXXConstructorDecl 0x556e6a172d58 <col:16> col:16 implicit used constexpr A 'void (A &&)' inline default trivial noexcept-unevaluated 0x556e6a172d58
  | `-ParmVarDecl 0x556e6a172e78 <col:16> col:16 'A &&'
  `-CXXConstructorDecl 0x556e6a1ac250 prev 0x556e6a172d58 <input.cc:2:16> col:16 implicit used constexpr A 'void (A &&) noexcept' inline default trivial
    |-ParmVarDecl 0x556e6a1730e0 <col:16> col:16 used 'A &&'
    |-CXXCtorInitializer Field 0x556e6a172850 'm' 'int'
    | `-ImplicitCastExpr 0x556e6a1ac3a0 <col:16> 'int' <LValueToRValue>
    |   `-MemberExpr 0x556e6a1ac370 <col:16> 'int' xvalue .m 0x556e6a172850
    |     `-CXXStaticCastExpr 0x556e6a1ac340 <col:16> 'A':'A' xvalue static_cast<A &&> <NoOp>
    |       `-DeclRefExpr 0x556e6a1ac308 <col:16> 'A':'A' lvalue ParmVar 0x556e6a1730e0 '' 'A &&'
    `-CompoundStmt 0x556e6a1ac3e0 <col:16>

It contains a re-declaration of the (implicit) move constructor, but I do not know if this AST causes problems practically. To avoid this situation we must change the existing To AST in the import process to add the definition of the move constructor (to the existing which has no definition). Theoretically this may be possible, but it is different from how the `ASTImporter` currently works, now every imported function declaration is created and linked to the existing ones. (But there are already some values that are updated in the To AST.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156461/new/

https://reviews.llvm.org/D156461



More information about the cfe-commits mailing list