diff options
author | Andy Kaylor <akaylor@nvidia.com> | 2025-05-20 10:52:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-20 10:52:15 -0700 |
commit | cbcfe667bbda2ba2862d873350309e29b4368880 (patch) | |
tree | 862e518ab2e73f148e536450c25f9f5603e0ffcb /clang/lib/CIR/CodeGen/CIRGenFunction.cpp | |
parent | 0931874b219cfdae38fcf24d33c8efa001697d5a (diff) | |
download | llvm-cbcfe667bbda2ba2862d873350309e29b4368880.zip llvm-cbcfe667bbda2ba2862d873350309e29b4368880.tar.gz llvm-cbcfe667bbda2ba2862d873350309e29b4368880.tar.bz2 |
[CIR] Upstream support for iterator-based range for loops (#140636)
This change adds handling for C++ member operator calls, implicit no-op
casts, and l-value call expressions. Together, these changes enable
handling of range for loops based on iterators.
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenFunction.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenFunction.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp index 6bfad71..c3798de 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp @@ -476,6 +476,18 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn, return fn; } +/// Given a value of type T* that may not be to a complete object, construct +/// an l-vlaue withi the natural pointee alignment of T. +LValue CIRGenFunction::makeNaturalAlignPointeeAddrLValue(mlir::Value val, + QualType ty) { + // FIXME(cir): is it safe to assume Op->getResult(0) is valid? Perhaps + // assert on the result type first. + LValueBaseInfo baseInfo; + assert(!cir::MissingFeatures::opTBAA()); + CharUnits align = cgm.getNaturalTypeAlignment(ty, &baseInfo); + return makeAddrLValue(Address(val, align), ty, baseInfo); +} + clang::QualType CIRGenFunction::buildFunctionArgList(clang::GlobalDecl gd, FunctionArgList &args) { const auto *fd = cast<FunctionDecl>(gd.getDecl()); @@ -536,10 +548,20 @@ LValue CIRGenFunction::emitLValue(const Expr *e) { "CompoundAssignOperator with ComplexType"); return LValue(); } + case Expr::CallExprClass: + case Expr::CXXMemberCallExprClass: + case Expr::CXXOperatorCallExprClass: + case Expr::UserDefinedLiteralClass: + return emitCallExprLValue(cast<CallExpr>(e)); case Expr::ParenExprClass: return emitLValue(cast<ParenExpr>(e)->getSubExpr()); case Expr::DeclRefExprClass: return emitDeclRefLValue(cast<DeclRefExpr>(e)); + case Expr::CStyleCastExprClass: + case Expr::CXXStaticCastExprClass: + case Expr::CXXDynamicCastExprClass: + case Expr::ImplicitCastExprClass: + return emitCastLValue(cast<CastExpr>(e)); } } |