diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-12-14 12:16:43 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-12-14 12:16:43 +0000 |
| commit | 17e2633cd65d43ec0a14d247c7be83e2b793ef86 (patch) | |
| tree | 5271c453ac6943f7f2a4bcd663699d090e03e14e /clang/lib/CodeGen/CGExprConstant.cpp | |
| parent | 3fcafa2cdb0d128507308a05555049d3424da2a5 (diff) | |
| download | bcm5719-llvm-17e2633cd65d43ec0a14d247c7be83e2b793ef86.tar.gz bcm5719-llvm-17e2633cd65d43ec0a14d247c7be83e2b793ef86.zip | |
CodeGen: Compound literals with funny types shouldn't crash
CodeGen assumed that a compound literal with array type should have a
corresponding LLVM IR array type.
We had two bugs in this area:
- Zero sized arrays in compound literals would lead to the creation of
an opaque type. This is unnecessary, we should just create an array
type with a bound of zero.
- Funny record types (like unions) lead to exotic IR types for compound
literals. In this case, CodeGen must be prepared to deal with the
possibility that it might not have an array IR type.
This fixes PR21912.
llvm-svn: 224219
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index ddfea03bebe..ac58d624e6f 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -1217,7 +1217,8 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value, CAT->getElementType(), CGF); // Emit initializer elements. - llvm::Type *CommonElementType = nullptr; + llvm::Type *CommonElementType = + getTypes().ConvertType(CAT->getElementType()); for (unsigned I = 0; I < NumElements; ++I) { llvm::Constant *C = Filler; if (I < NumInitElts) |

