Skip to content

Commit eee0c1c

Browse files
committed
[clang][bytecode] Compile most recent function decl
We used to always do this because all calls went through the code path that calls getMostRecentDecl(). Do it now, too.
1 parent eef5ea0 commit eee0c1c

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5676,6 +5676,8 @@ bool Compiler<Emitter>::checkLiteralType(const Expr *E) {
56765676

56775677
template <class Emitter>
56785678
bool Compiler<Emitter>::compileConstructor(const CXXConstructorDecl *Ctor) {
5679+
llvm::errs() << __PRETTY_FUNCTION__ << '\n';
5680+
Ctor->dump();
56795681
assert(!ReturnType);
56805682

56815683
auto emitFieldInitializer = [&](const Record::Field *F, unsigned FieldOffset,

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ bool Context::evaluate(State &Parent, const Expr *E, APValue &Result,
104104

105105
bool Context::evaluateAsInitializer(State &Parent, const VarDecl *VD,
106106
APValue &Result) {
107+
VD->dump();
107108
++EvalID;
108109
bool Recursing = !Stk.empty();
109110
size_t StackSizeBefore = Stk.size();

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,8 @@ static bool checkConstructor(InterpState &S, CodePtr OpPC, const Function *Func,
13601360

13611361
static void compileFunction(InterpState &S, const Function *Func) {
13621362
Compiler<ByteCodeEmitter>(S.getContext(), S.P)
1363-
.compileFunc(Func->getDecl(), const_cast<Function *>(Func));
1363+
.compileFunc(Func->getDecl()->getMostRecentDecl(),
1364+
const_cast<Function *>(Func));
13641365
}
13651366

13661367
bool CallVar(InterpState &S, CodePtr OpPC, const Function *Func,

clang/test/AST/ByteCode/records.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,3 +1759,15 @@ namespace IncompleteTypes {
17591759
}
17601760
static_assert(foo(), "");
17611761
}
1762+
1763+
namespace RedeclaredCtor {
1764+
1765+
struct __sp_mut {
1766+
void *__lx_;
1767+
constexpr __sp_mut(void *) noexcept;
1768+
};
1769+
int mut_back[1];
1770+
1771+
constexpr __sp_mut::__sp_mut(void *p) noexcept : __lx_(p) {}
1772+
constexpr __sp_mut muts = &mut_back[0];
1773+
}

0 commit comments

Comments
 (0)