[clang] 5bf56a5 - [clang][Interp][NFCI] Don't crash on void builtin functions

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 25 22:32:46 PST 2023


Author: Timm Bäder
Date: 2023-01-26T07:32:33+01:00
New Revision: 5bf56a58775cb235b7ed9e9fcc6895b797e9721b

URL: https://github.com/llvm/llvm-project/commit/5bf56a58775cb235b7ed9e9fcc6895b797e9721b
DIFF: https://github.com/llvm/llvm-project/commit/5bf56a58775cb235b7ed9e9fcc6895b797e9721b.diff

LOG: [clang][Interp][NFCI] Don't crash on void builtin functions

classifyPrim() runs into a llvm_unreachable() for those.

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index aaab980ac81b..316ba6356436 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1479,10 +1479,9 @@ bool ByteCodeExprGen<Emitter>::VisitBuiltinCallExpr(const CallExpr *E) {
   if (!this->emitCallBI(Func, E))
     return false;
 
-  if (DiscardResult) {
-    QualType ReturnType = E->getCallReturnType(Ctx.getASTContext());
+  QualType ReturnType = E->getCallReturnType(Ctx.getASTContext());
+  if (DiscardResult && !ReturnType->isVoidType()) {
     PrimType T = classifyPrim(ReturnType);
-
     return this->emitPop(T, E);
   }
 


        


More information about the cfe-commits mailing list