[clang][Interp][NFC] Remove code duplication in VisitRecordInitializer
authorTimm Bäder <tbaeder@redhat.com>
Wed, 11 Jan 2023 11:12:05 +0000 (12:12 +0100)
committerTimm Bäder <tbaeder@redhat.com>
Wed, 11 Jan 2023 12:08:51 +0000 (13:08 +0100)
We can just use the regular VisitCallExpr logic here, since we have the
pointer to initialize already on the stack.

clang/lib/AST/Interp/ByteCodeExprGen.cpp

index 0c2eaac..0bbab0c 100644 (file)
@@ -1041,20 +1041,12 @@ bool ByteCodeExprGen<Emitter>::visitRecordInitializer(const Expr *Initializer) {
 
     return true;
   } else if (const CallExpr *CE = dyn_cast<CallExpr>(Initializer)) {
-    const Decl *Callee = CE->getCalleeDecl();
-    const Function *Func = getFunction(dyn_cast<FunctionDecl>(Callee));
-
-    if (!Func)
+    // RVO functions expect a pointer to initialize on the stack.
+    // Dup our existing pointer so it has its own copy to use.
+    if (!this->emitDupPtr(Initializer))
       return false;
 
-    if (Func->hasRVO()) {
-      // RVO functions expect a pointer to initialize on the stack.
-      // Dup our existing pointer so it has its own copy to use.
-      if (!this->emitDupPtr(Initializer))
-        return false;
-
-      return this->visit(CE);
-    }
+    return this->VisitCallExpr(CE);
   } else if (const auto *DIE = dyn_cast<CXXDefaultInitExpr>(Initializer)) {
     return this->visitInitializer(DIE->getExpr());
   }