]> granicus.if.org Git - clang/commitdiff
Objective-C encoding. Fixes up encodeing for
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 4 Jun 2013 16:04:37 +0000 (16:04 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 4 Jun 2013 16:04:37 +0000 (16:04 +0000)
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

lib/AST/ASTContext.cpp
test/CodeGenObjC/encode-test.m

index 333e80be3067c2cf828d50cb335de9095b9eb423..1f89e3f1f69a8545c43d53acce6f433019afe2cc 100644 (file)
@@ -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!");
index e8d65413740dcbe0406b637942197b6ff1c070d7..d6e7b6dfccad40ab7a1a7d9b77aa430cd99fd94d 100644 (file)
@@ -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