Skip to content

Commit 483b793

Browse files
committed
[CIR][CodeGen][NFC] Sync emitDeclInit to CodeGen
1 parent 21e8647 commit 483b793

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

clang/lib/CIR/CodeGen/CIRGenCXX.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,33 +176,39 @@ bool CIRGenModule::tryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
176176
return false;
177177
}
178178

179-
static void emitDeclInit(CIRGenFunction &CGF, const VarDecl *D,
180-
Address DeclPtr) {
181-
assert((D->hasGlobalStorage() ||
182-
(D->hasLocalStorage() &&
183-
CGF.getContext().getLangOpts().OpenCLCPlusPlus)) &&
179+
static void emitDeclInit(CIRGenFunction &cgf, const VarDecl *varDecl,
180+
Address declPtr) {
181+
assert((varDecl->hasGlobalStorage() ||
182+
(varDecl->hasLocalStorage() &&
183+
cgf.getContext().getLangOpts().OpenCLCPlusPlus)) &&
184184
"VarDecl must have global or local (in the case of OpenCL) storage!");
185-
assert(!D->getType()->isReferenceType() &&
185+
assert(!varDecl->getType()->isReferenceType() &&
186186
"Should not call emitDeclInit on a reference!");
187187

188-
QualType type = D->getType();
189-
LValue lv = CGF.makeAddrLValue(DeclPtr, type);
188+
QualType type = varDecl->getType();
189+
LValue lv = cgf.makeAddrLValue(declPtr, type);
190190

191-
const Expr *Init = D->getInit();
191+
const Expr *init = varDecl->getInit();
192192
switch (CIRGenFunction::getEvaluationKind(type)) {
193+
case cir::TEK_Scalar:
194+
if (lv.isObjCStrong())
195+
llvm_unreachable("NYI");
196+
else if (lv.isObjCWeak())
197+
llvm_unreachable("NYI");
198+
else
199+
cgf.emitScalarInit(init, cgf.getLoc(varDecl->getLocation()), lv, false);
200+
return;
201+
case cir::TEK_Complex:
202+
llvm_unreachable("complext evaluation NYI");
193203
case cir::TEK_Aggregate:
194-
CGF.emitAggExpr(Init,
204+
cgf.emitAggExpr(init,
195205
AggValueSlot::forLValue(lv, AggValueSlot::IsDestructed,
196206
AggValueSlot::DoesNotNeedGCBarriers,
197207
AggValueSlot::IsNotAliased,
198208
AggValueSlot::DoesNotOverlap));
199209
return;
200-
case cir::TEK_Scalar:
201-
CGF.emitScalarInit(Init, CGF.getLoc(D->getLocation()), lv, false);
202-
return;
203-
case cir::TEK_Complex:
204-
llvm_unreachable("complext evaluation NYI");
205210
}
211+
llvm_unreachable("bad evaluation kind");
206212
}
207213

208214
static void emitDeclDestroy(CIRGenFunction &CGF, const VarDecl *D) {
@@ -336,7 +342,7 @@ void CIRGenModule::emitCXXGlobalVarDeclInit(const VarDecl *varDecl,
336342

337343
assert(varDecl && " Expected a global declaration!");
338344
CIRGenFunction cgf{*this, builder, true};
339-
llvm::SaveAndRestore<CIRGenFunction*> savedCGF(CurCGF, &cgf);
345+
llvm::SaveAndRestore<CIRGenFunction *> savedCGF(CurCGF, &cgf);
340346
CurCGF->CurFn = addr;
341347

342348
CIRGenFunction::SourceLocRAIIObject fnLoc{cgf,

0 commit comments

Comments
 (0)