[clang] [clang][bytecode] Compile most recent function decl (PR #131730)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 17 21:57:02 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
We used to always do this because all calls went through the code path that calls getMostRecentDecl(). Do it now, too.
---
Full diff: https://github.com/llvm/llvm-project/pull/131730.diff
4 Files Affected:
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+2)
- (modified) clang/lib/AST/ByteCode/Context.cpp (+1)
- (modified) clang/lib/AST/ByteCode/Interp.cpp (+2-1)
- (modified) clang/test/AST/ByteCode/records.cpp (+12)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 3524ab5f86de8..4734ae8eaf52c 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5676,6 +5676,8 @@ bool Compiler<Emitter>::checkLiteralType(const Expr *E) {
template <class Emitter>
bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
+ llvm::errs() << __PRETTY_FUNCTION__ << '\n';
+ Ctor->dump();
assert(!ReturnType);
auto emitFieldInitializer = [&](const Record::Field *F, unsigned FieldOffset,
diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp
index 23f4c5a4fa4b7..be39ed444e30d 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -104,6 +104,7 @@ bool Context::evaluate(State &Parent, const Expr *E, APValue &Result,
bool Context::evaluateAsInitializer(State &Parent, const VarDecl *VD,
APValue &Result) {
+ VD->dump();
++EvalID;
bool Recursing = !Stk.empty();
size_t StackSizeBefore = Stk.size();
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index ffd2b31147d20..bdbce5f662c6d 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1360,7 +1360,8 @@ static bool checkConstructor(InterpState &S, CodePtr OpPC, const Function *Func,
static void compileFunction(InterpState &S, const Function *Func) {
Compiler<ByteCodeEmitter>(S.getContext(), S.P)
- .compileFunc(Func->getDecl(), const_cast<Function *>(Func));
+ .compileFunc(Func->getDecl()->getMostRecentDecl(),
+ const_cast<Function *>(Func));
}
bool CallVar(InterpState &S, CodePtr OpPC, const Function *Func,
diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp
index 42b6d82d7190b..5d9f1044f206b 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -1759,3 +1759,15 @@ namespace IncompleteTypes {
}
static_assert(foo(), "");
}
+
+namespace RedeclaredCtor {
+
+ struct __sp_mut {
+ void *__lx_;
+ constexpr __sp_mut(void *) noexcept;
+ };
+ int mut_back[1];
+
+ constexpr __sp_mut::__sp_mut(void *p) noexcept : __lx_(p) {}
+ constexpr __sp_mut muts = &mut_back[0];
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/131730
More information about the cfe-commits
mailing list