Author: Timm Bäder
Date: 2024-07-18T09:05:48+02:00
New Revision: 7aabdb8776eb11b90d43162254db47df46806ec9

URL: 
https://github.com/llvm/llvm-project/commit/7aabdb8776eb11b90d43162254db47df46806ec9
DIFF: 
https://github.com/llvm/llvm-project/commit/7aabdb8776eb11b90d43162254db47df46806ec9.diff

LOG: [clang][Interp][NFC] Protect ByteCodeEmitter against unfinished fns

This is similar to a check in TextNodeDumper.cpp. Without this, we will
crash later when trying to iterate over FuncDecl->params().

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index 17da77bc63c9b..a3d4c7d7392da 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -31,6 +31,12 @@ static bool isUnevaluatedBuiltin(unsigned BuiltinID) {
 }
 
 Function *ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
+
+  // Manually created functions that haven't been assigned proper
+  // parameters yet.
+  if (!FuncDecl->param_empty() && !FuncDecl->param_begin())
+    return nullptr;
+
   bool IsLambdaStaticInvoker = false;
   if (const auto *MD = dyn_cast<CXXMethodDecl>(FuncDecl);
       MD && MD->isLambdaStaticInvoker()) {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to