aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 81da16e..759d5a6 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4574,22 +4574,23 @@ VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD,
template <class Emitter>
bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
bool ConstantContext) {
- std::optional<PrimType> VarT = classify(VD->getType());
// We only create variables if we're evaluating in a constant context.
// Otherwise, just evaluate the initializer and return it.
if (!ConstantContext) {
DeclScope<Emitter> LS(this, VD);
- if (!this->visit(VD->getAnyInitializer()))
+ const Expr *Init = VD->getInit();
+ if (!this->visit(Init))
return false;
- return this->emitRet(VarT.value_or(PT_Ptr), VD) && LS.destroyLocals() &&
- this->emitCheckAllocations(VD);
+ return this->emitRet(classify(Init).value_or(PT_Ptr), VD) &&
+ LS.destroyLocals() && this->emitCheckAllocations(VD);
}
LocalScope<Emitter> VDScope(this, VD);
if (!this->visitVarDecl(VD, /*Toplevel=*/true))
return false;
+ std::optional<PrimType> VarT = classify(VD->getType());
if (Context::shouldBeGloballyIndexed(VD)) {
auto GlobalIndex = P.getGlobal(VD);
assert(GlobalIndex); // visitVarDecl() didn't return false.