diff options
author | Nick Desaulniers <nickdesaulniers@users.noreply.github.com> | 2023-10-30 08:48:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 08:48:31 -0700 |
commit | d9b15b068d19089f72fc0d7dc59ed1d6d77125dc (patch) | |
tree | 29e14a64ad8f321a4508a314a7dcff49dd5471f6 /clang/lib/CodeGen/CGExprConstant.cpp | |
parent | fecd11ba87557997b2765cd88e5c058df4eb50ce (diff) | |
download | llvm-d9b15b068d19089f72fc0d7dc59ed1d6d77125dc.zip llvm-d9b15b068d19089f72fc0d7dc59ed1d6d77125dc.tar.gz llvm-d9b15b068d19089f72fc0d7dc59ed1d6d77125dc.tar.bz2 |
[CGExprConstant] stop calling into ConstExprEmitter for Reference type destinations (#70366)
Fixes a bug introduced by
commit b54294e2c959 ("[clang][ConstantEmitter] have
tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first")
In the added test case, the QualType is a LValueReferenceType.
LValueReferenceType 0x558412998d90 'const char (&)[41]'
`-ParenType 0x558412998d30 'const char[41]' sugar
`-ConstantArrayType 0x558412998cf0 'const char[41]' 41
`-QualType 0x55841294c271 'const char' const
`-BuiltinType 0x55841294c270 'char'
Fixes: #69979
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 9b67a8b3..3f50803 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -1775,9 +1775,10 @@ llvm::Constant *ConstantEmitter::tryEmitPrivate(const Expr *E, QualType destType) { assert(!destType->isVoidType() && "can't emit a void constant"); - if (llvm::Constant *C = - ConstExprEmitter(*this).Visit(const_cast<Expr *>(E), destType)) - return C; + if (!destType->isReferenceType()) + if (llvm::Constant *C = + ConstExprEmitter(*this).Visit(const_cast<Expr *>(E), destType)) + return C; Expr::EvalResult Result; |