From: Fariborz Jahanian Date: Tue, 4 Jun 2013 16:04:37 +0000 (+0000) Subject: Objective-C encoding. Fixes up encodeing for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48eff6c3512fd6c768072b05ab4c287c7719072b;p=clang Objective-C encoding. Fixes up encodeing for arrays of empty structs. // rdar://14053082 (also pr13062). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183234 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 333e80be30..1f89e3f1f6 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -5242,12 +5242,9 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, } else { S += '['; - if (const ConstantArrayType *CAT = dyn_cast(AT)) { - if (getTypeSize(CAT->getElementType()) == 0) - S += '0'; - else - S += llvm::utostr(CAT->getSize().getZExtValue()); - } else { + if (const ConstantArrayType *CAT = dyn_cast(AT)) + S += llvm::utostr(CAT->getSize().getZExtValue()); + else { //Variable length arrays are encoded as a regular array with 0 elements. assert((isa(AT) || isa(AT)) && "Unknown array type!"); diff --git a/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m index e8d6541374..d6e7b6dfcc 100644 --- a/test/CodeGenObjC/encode-test.m +++ b/test/CodeGenObjC/encode-test.m @@ -159,7 +159,7 @@ struct f int tt; }; -// CHECK: @g10 = constant [14 x i8] c"{f=i[0{?=}]i}\00" +// CHECK: @g10 = constant [14 x i8] c"{f=i[4{?=}]i}\00" const char g10[] = @encode(struct f); // rdar://9622422