revert r101568, which miscompiles this testcase, distilled from ldecod:
void exit_picture()
{
char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
foo(yuv_types);
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101623 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 6612070..82156f7 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -615,16 +615,17 @@
}
llvm::Constant *EmitArrayInitialization(InitListExpr *ILE) {
- unsigned NumInitElements = ILE->getNumInits();
- // FIXME: Check for NumInitElements exactly equal to 1??
- if (NumInitElements > 0 &&
- (isa<StringLiteral>(ILE->getInit(0)) ||
- isa<ObjCEncodeExpr>(ILE->getInit(0))))
- return Visit(ILE->getInit(0));
-
std::vector<llvm::Constant*> Elts;
const llvm::ArrayType *AType =
cast<llvm::ArrayType>(ConvertType(ILE->getType()));
+ unsigned NumInitElements = ILE->getNumInits();
+ // FIXME: Check for wide strings
+ // FIXME: Check for NumInitElements exactly equal to 1??
+ if (NumInitElements > 0 &&
+ (isa<StringLiteral>(ILE->getInit(0)) ||
+ isa<ObjCEncodeExpr>(ILE->getInit(0))) &&
+ ILE->getType()->getArrayElementTypeNoTypeQual()->isCharType())
+ return Visit(ILE->getInit(0));
const llvm::Type *ElemTy = AType->getElementType();
unsigned NumElements = AType->getNumElements();