@@ -156,26 +156,35 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr *ce) {
156156mlir::Value ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr (
157157 const UnaryExprOrTypeTraitExpr *e) {
158158 const QualType typeToSize = e->getTypeOfArgument ();
159+ const mlir::Location loc = cgf.getLoc (e->getSourceRange ());
159160 if (auto kind = e->getKind ();
160161 kind == UETT_SizeOf || kind == UETT_DataSizeOf) {
161162 if (const VariableArrayType *variableArrTy =
162163 cgf.getContext ().getAsVariableArrayType (typeToSize)) {
163164 cgf.getCIRGenModule ().errorNYI (e->getSourceRange (),
164165 " sizeof operator for VariableArrayType" ,
165166 e->getStmtClassName ());
167+ return builder.getConstant (
168+ loc, builder.getAttr <cir::IntAttr>(
169+ cgf.cgm .UInt64Ty , llvm::APSInt (llvm::APInt (64 , 1 ), true )));
166170 }
167171 } else if (e->getKind () == UETT_OpenMPRequiredSimdAlign) {
168172 cgf.getCIRGenModule ().errorNYI (
169173 e->getSourceRange (), " sizeof operator for OpenMpRequiredSimdAlign" ,
170174 e->getStmtClassName ());
175+ return builder.getConstant (
176+ loc, builder.getAttr <cir::IntAttr>(
177+ cgf.cgm .UInt64Ty , llvm::APSInt (llvm::APInt (64 , 1 ), true )));
171178 } else if (e->getKind () == UETT_VectorElements) {
172179 cgf.getCIRGenModule ().errorNYI (e->getSourceRange (),
173180 " sizeof operator for VectorElements" ,
174181 e->getStmtClassName ());
182+ return builder.getConstant (
183+ loc, builder.getAttr <cir::IntAttr>(
184+ cgf.cgm .UInt64Ty , llvm::APSInt (llvm::APInt (64 , 1 ), true )));
175185 }
176186
177- return builder.create <cir::ConstantOp>(
178- cgf.getLoc (e->getSourceRange ()), cgf.cgm .UInt64Ty ,
179- builder.getAttr <cir::IntAttr>(
180- cgf.cgm .UInt64Ty , e->EvaluateKnownConstInt (cgf.getContext ())));
187+ return builder.getConstant (
188+ loc, builder.getAttr <cir::IntAttr>(
189+ cgf.cgm .UInt64Ty , e->EvaluateKnownConstInt (cgf.getContext ())));
181190}
0 commit comments