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

via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 18 02:05:36 PST 2026


================
@@ -5678,8 +5678,9 @@ bool Compiler<Emitter>::visitReturnStmt(const ReturnStmt *RS) {
       return this->emitRet(*ReturnType, RS);
     }
 
-    if (RE->getType()->isVoidType()) {
-      if (!this->visit(RE))
+    if (RE->getType()->isVoidType() ||
+        (CompilingFunction && CompilingFunction->getReturnType()->isVoidType())) {
+      if (!this->discard(RE))
         return false;
     } else {
       InitLinkScope<Emitter> ILS(this, InitLink::RVO());
----------------
Serosh-commits wrote:

done it dude the logic in 
Compiler.cpp
 now explicitly checks RE->containsErrors() before deciding whether to use 
discard()
 or proceed with the RVO path.

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


More information about the cfe-commits mailing list