diff options
| author | Nathan Sidwell <nathan@acm.org> | 2021-05-20 13:31:31 -0700 |
|---|---|---|
| committer | Nathan Sidwell <nathan@acm.org> | 2021-10-12 07:35:20 -0700 |
| commit | dcd74716f9d18444a17de852a760cc85bd16f825 (patch) | |
| tree | 535b416e09ddd7e001bc5df0f260e7649246ffd5 /clang/lib/CodeGen/CGExprScalar.cpp | |
| parent | a76cfc2e840ff373b80e3a5f84fc48c5f1f90d8a (diff) | |
[clang] p0388 conversion to incomplete array
This implements the new implicit conversion sequence to an incomplete
(unbounded) array type. It is mostly Richard Smith's work, updated to
trunk, testcases added and a few bugs fixed found in such testing.
It is not a complete implementation of p0388.
Differential Revision: https://reviews.llvm.org/D102645
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index ed485ed6f5d1..866da292819f 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -2154,10 +2154,22 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { } case CK_AtomicToNonAtomic: case CK_NonAtomicToAtomic: - case CK_NoOp: case CK_UserDefinedConversion: return Visit(const_cast<Expr*>(E)); + case CK_NoOp: { + llvm::Value *V = Visit(const_cast<Expr *>(E)); + if (V) { + // CK_NoOp can model a pointer qualification conversion, which can remove + // an array bound and change the IR type. + // FIXME: Once pointee types are removed from IR, remove this. + llvm::Type *T = ConvertType(DestTy); + if (T != V->getType()) + V = Builder.CreateBitCast(V, T); + } + return V; + } + case CK_BaseToDerived: { const CXXRecordDecl *DerivedClassDecl = DestTy->getPointeeCXXRecordDecl(); assert(DerivedClassDecl && "BaseToDerived arg isn't a C++ object pointer!"); |
