[PATCH] D134699: [clang][Interp] Implement This pointer passing to methods

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 6 08:08:14 PDT 2022


tbaeder marked an inline comment as done.
tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:638
   if (const auto CtorExpr = dyn_cast<CXXConstructExpr>(Initializer)) {
-    const CXXConstructorDecl *Ctor = CtorExpr->getConstructor();
-    const RecordDecl *RD = Ctor->getParent();
-    const Record *R = getRecord(RD);
-
-    for (const auto *Init : Ctor->inits()) {
-      const FieldDecl *Member = Init->getMember();
-      const Expr *InitExpr = Init->getInit();
-
-      if (Optional<PrimType> T = classify(InitExpr->getType())) {
-        const Record::Field *F = R->getField(Member);
-
-        if (!this->emitDupPtr(Initializer))
-          return false;
+    const Function *Func = getFunction(CtorExpr->getConstructor());
 
----------------
aaron.ballman wrote:
> What happens if `Func` is null?
We need to bail out!


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:668
     const Decl *Callee = CE->getCalleeDecl();
-    const Function *Func = P.getFunction(dyn_cast<FunctionDecl>(Callee));
+    const Function *Func = getFunction(dyn_cast<FunctionDecl>(Callee));
+
----------------
aaron.ballman wrote:
> Any reason not to use `cast` here instead, given that `getFunction()` expects a nonnull pointer anyway?
Not particularly, I guess the generated assertion output is a little nicer if it reaches the one in `getFunction()`.


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

https://reviews.llvm.org/D134699



More information about the cfe-commits mailing list