diff options
| author | Mingming Liu <mingmingl@google.com> | 2025-09-10 15:25:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-10 15:25:31 -0700 |
| commit | 1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch) | |
| tree | 57f4b1f313c8cf74eed8819870f39c36ea263c68 /clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | |
| parent | 898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff) | |
| parent | b8cefcb601ddaa18482555c4ff363c01a270c2fe (diff) | |
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
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)); } |
