diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-06-04 16:04:37 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-06-04 16:04:37 +0000 |
commit | f0dc11ad7f5ca007636a3e6fdc69adf878768bc3 (patch) | |
tree | 3074f00dfb26ed2adaa5f9cc75ba2af074225809 /clang | |
parent | 6f0a5edb3f9fb635c7081c633ab0f433da836123 (diff) | |
download | bcm5719-llvm-f0dc11ad7f5ca007636a3e6fdc69adf878768bc3.tar.gz bcm5719-llvm-f0dc11ad7f5ca007636a3e6fdc69adf878768bc3.zip |
Objective-C encoding. Fixes up encodeing for
arrays of empty structs. // rdar://14053082
(also pr13062).
llvm-svn: 183234
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 9 | ||||
-rw-r--r-- | clang/test/CodeGenObjC/encode-test.m | 2 |
2 files changed, 4 insertions, 7 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 333e80be306..1f89e3f1f69 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -5242,12 +5242,9 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, } else { S += '['; - if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT)) { - if (getTypeSize(CAT->getElementType()) == 0) - S += '0'; - else - S += llvm::utostr(CAT->getSize().getZExtValue()); - } else { + if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT)) + S += llvm::utostr(CAT->getSize().getZExtValue()); + else { //Variable length arrays are encoded as a regular array with 0 elements. assert((isa<VariableArrayType>(AT) || isa<IncompleteArrayType>(AT)) && "Unknown array type!"); diff --git a/clang/test/CodeGenObjC/encode-test.m b/clang/test/CodeGenObjC/encode-test.m index e8d65413740..d6e7b6dfcca 100644 --- a/clang/test/CodeGenObjC/encode-test.m +++ b/clang/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 |