diff options
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp')
| -rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index 46934e7155ad..754ef7939291 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -92,6 +92,10 @@ public: mlir::Value value, CastKind kind, QualType destTy); + mlir::Value emitNullValue(QualType ty, mlir::Location loc) { + return cgf.cgm.emitNullConstant(ty, loc); + } + mlir::Value emitPromotedValue(mlir::Value result, QualType promotionType) { return builder.createFloatingCast(result, cgf.convertType(promotionType)); } @@ -182,6 +186,13 @@ public: return builder.getBool(e->getValue(), cgf.getLoc(e->getExprLoc())); } + mlir::Value VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *e) { + if (e->getType()->isVoidType()) + return {}; + + return emitNullValue(e->getType(), cgf.getLoc(e->getSourceRange())); + } + mlir::Value VisitCastExpr(CastExpr *e); mlir::Value VisitCallExpr(const CallExpr *e); @@ -650,6 +661,11 @@ public: mlir::Value VisitUnaryImag(const UnaryOperator *e); + mlir::Value VisitCXXDefaultInitExpr(CXXDefaultInitExpr *die) { + CIRGenFunction::CXXDefaultInitExprScope scope(cgf, die); + return Visit(die->getExpr()); + } + mlir::Value VisitCXXThisExpr(CXXThisExpr *te) { return cgf.loadCXXThis(); } mlir::Value VisitExprWithCleanups(ExprWithCleanups *e); @@ -657,6 +673,11 @@ public: return cgf.emitCXXNewExpr(e); } + mlir::Value VisitCXXThrowExpr(const CXXThrowExpr *e) { + cgf.emitCXXThrowExpr(e); + return {}; + } + /// Emit a conversion from the specified type to the specified destination /// type, both of which are CIR scalar types. /// TODO: do we need ScalarConversionOpts here? Should be done in another @@ -1966,11 +1987,9 @@ mlir::Value ScalarExprEmitter::VisitInitListExpr(InitListExpr *e) { cgf.getLoc(e->getSourceRange()), vectorType, elements); } - if (numInitElements == 0) { - cgf.cgm.errorNYI(e->getSourceRange(), - "InitListExpr Non VectorType with 0 init elements"); - return {}; - } + // C++11 value-initialization for the scalar. + if (numInitElements == 0) + return emitNullValue(e->getType(), cgf.getLoc(e->getExprLoc())); return Visit(e->getInit(0)); } |
