llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/158093.diff


4 Files Affected:

- (modified) clang/lib/AST/ByteCode/ByteCodeEmitter.cpp (+2-4) 
- (modified) clang/lib/AST/ByteCode/Function.h (+4-3) 
- (modified) clang/lib/AST/ByteCode/Interp.cpp (+5-2) 
- (modified) clang/test/Modules/lambda-merge.cpp (+1) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp 
b/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
index 1d71708799518..274efccac79dc 100644
--- a/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
@@ -24,15 +24,13 @@ void ByteCodeEmitter::compileFunc(const FunctionDecl 
*FuncDecl,
                                   Function *Func) {
   assert(FuncDecl);
   assert(Func);
+  assert(FuncDecl->isThisDeclarationADefinition());
 
   // Manually created functions that haven't been assigned proper
   // parameters yet.
   if (!FuncDecl->param_empty() && !FuncDecl->param_begin())
     return;
 
-  if (!FuncDecl->isDefined())
-    return;
-
   // Set up lambda captures.
   if (const auto *MD = dyn_cast<CXXMethodDecl>(FuncDecl);
       MD && isLambdaCallOperator(MD)) {
@@ -87,7 +85,7 @@ void ByteCodeEmitter::compileFunc(const FunctionDecl 
*FuncDecl,
   }
 
   // Set the function's code.
-  Func->setCode(NextLocalOffset, std::move(Code), std::move(SrcMap),
+  Func->setCode(FuncDecl, NextLocalOffset, std::move(Code), std::move(SrcMap),
                 std::move(Scopes), FuncDecl->hasBody());
   Func->setIsFullyCompiled(true);
 }
diff --git a/clang/lib/AST/ByteCode/Function.h 
b/clang/lib/AST/ByteCode/Function.h
index af429b7849e88..95add5809afcc 100644
--- a/clang/lib/AST/ByteCode/Function.h
+++ b/clang/lib/AST/ByteCode/Function.h
@@ -236,9 +236,10 @@ class Function final {
            bool HasRVO, bool IsLambdaStaticInvoker);
 
   /// Sets the code of a function.
-  void setCode(unsigned NewFrameSize, llvm::SmallVector<std::byte> &&NewCode,
-               SourceMap &&NewSrcMap, llvm::SmallVector<Scope, 2> &&NewScopes,
-               bool NewHasBody) {
+  void setCode(FunctionDeclTy Source, unsigned NewFrameSize,
+               llvm::SmallVector<std::byte> &&NewCode, SourceMap &&NewSrcMap,
+               llvm::SmallVector<Scope, 2> &&NewScopes, bool NewHasBody) {
+    this->Source = Source;
     FrameSize = NewFrameSize;
     Code = std::move(NewCode);
     SrcMap = std::move(NewSrcMap);
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index b961a413fbe78..d5e75a0c90469 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1493,9 +1493,12 @@ bool CheckDestructor(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
 }
 
 static void compileFunction(InterpState &S, const Function *Func) {
+  const FunctionDecl *Definition = Func->getDecl()->getDefinition();
+  if (!Definition)
+    return;
+
   Compiler<ByteCodeEmitter>(S.getContext(), S.P)
-      .compileFunc(Func->getDecl()->getMostRecentDecl(),
-                   const_cast<Function *>(Func));
+      .compileFunc(Definition, const_cast<Function *>(Func));
 }
 
 bool CallVar(InterpState &S, CodePtr OpPC, const Function *Func,
diff --git a/clang/test/Modules/lambda-merge.cpp 
b/clang/test/Modules/lambda-merge.cpp
index e996c9c0d5d1f..6b61d356ec581 100644
--- a/clang/test/Modules/lambda-merge.cpp
+++ b/clang/test/Modules/lambda-merge.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fmodules -std=c++17 -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -fmodules -std=c++17 -emit-llvm %s -o - -triple 
x86_64-linux-gnu -fexperimental-new-constant-interpreter | FileCheck %s
 
 #pragma clang module build A
 module A {}

``````````

</details>


https://github.com/llvm/llvm-project/pull/158093
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to