[clang] [clang][bytecode] Fix crash in void functions returning non-void expr… (PR #176550)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 20 04:28:35 PST 2026


================
@@ -5678,11 +5678,10 @@ bool Compiler<Emitter>::visitReturnStmt(const ReturnStmt *RS) {
       return this->emitRet(*ReturnType, RS);
     }
 
-    if (RE->getType()->isVoidType()) {
-      if (!this->visit(RE))
+    if (RE->containsErrors() || RE->getType()->isVoidType()) {
+      if (!this->discard(RE))
         return false;
     } else {
-      InitLinkScope<Emitter> ILS(this, InitLink::RVO());
       // RVO - construct the value in the return location.
----------------
Serosh-commits wrote:

@tbaederr 
 Updated the patch to just the minimal fix you asked for is it ok ?

https://github.com/llvm/llvm-project/pull/176550


More information about the cfe-commits mailing list