Skip to content

Commit f0dc11a

Browse files
author
Fariborz Jahanian
committed
Objective-C encoding. Fixes up encodeing for
arrays of empty structs. // rdar://14053082 (also pr13062). llvm-svn: 183234
1 parent 6f0a5ed commit f0dc11a

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5242,12 +5242,9 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
52425242
} else {
52435243
S += '[';
52445244

5245-
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT)) {
5246-
if (getTypeSize(CAT->getElementType()) == 0)
5247-
S += '0';
5248-
else
5249-
S += llvm::utostr(CAT->getSize().getZExtValue());
5250-
} else {
5245+
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT))
5246+
S += llvm::utostr(CAT->getSize().getZExtValue());
5247+
else {
52515248
//Variable length arrays are encoded as a regular array with 0 elements.
52525249
assert((isa<VariableArrayType>(AT) || isa<IncompleteArrayType>(AT)) &&
52535250
"Unknown array type!");

clang/test/CodeGenObjC/encode-test.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ @implementation Derived1X @end
159159
int tt;
160160
};
161161

162-
// CHECK: @g10 = constant [14 x i8] c"{f=i[0{?=}]i}\00"
162+
// CHECK: @g10 = constant [14 x i8] c"{f=i[4{?=}]i}\00"
163163
const char g10[] = @encode(struct f);
164164

165165
// rdar://9622422

0 commit comments

Comments
 (0)