[cfe-commits] r152370 - in /cfe/trunk: lib/CodeGen/CGExprConstant.cpp test/CodeGenCXX/static-init.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Mar 8 19:06:56 PST 2012
Author: efriedma
Date: Thu Mar 8 21:06:56 2012
New Revision: 152370
URL: http://llvm.org/viewvc/llvm-project?rev=152370&view=rev
Log:
Make sure constant emission handles initializer lists with strings correctly. Part of <rdar://problem/10957867>.
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/test/CodeGenCXX/static-init.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=152370&r1=152369&r2=152370&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Mar 8 21:06:56 2012
@@ -763,7 +763,9 @@
llvm::Constant *EmitArrayInitialization(InitListExpr *ILE) {
unsigned NumInitElements = ILE->getNumInits();
- if (NumInitElements == 1 && ILE->getType() == ILE->getInit(0)->getType() &&
+ if (NumInitElements == 1 &&
+ CGM.getContext().hasSameUnqualifiedType(ILE->getType(),
+ ILE->getInit(0)->getType()) &&
(isa<StringLiteral>(ILE->getInit(0)) ||
isa<ObjCEncodeExpr>(ILE->getInit(0))))
return Visit(ILE->getInit(0));
Modified: cfe/trunk/test/CodeGenCXX/static-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-init.cpp?rev=152370&r1=152369&r2=152370&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/static-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/static-init.cpp Thu Mar 8 21:06:56 2012
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
// CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
+// CHECK: @base_req = global [4 x i8] c"foo\00", align 1
// CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16
// CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0
@@ -59,3 +60,6 @@
void test() { (void) getvar(2); }
}
+
+// Make sure we emit the initializer correctly for the following:
+char base_req[] = { "foo" };
More information about the cfe-commits
mailing list