summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2017-03-14 04:00:52 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2017-03-14 04:00:52 +0000
commitff8534b8964b74614dd5399ff1343061f1b8619f (patch)
tree20dc97d25711554ce8f8a44066c783f8089f223c
parentb9d9ac49eb56833870af8f2d18dbed5c187f2b46 (diff)
downloadbcm5719-llvm-ff8534b8964b74614dd5399ff1343061f1b8619f.tar.gz
bcm5719-llvm-ff8534b8964b74614dd5399ff1343061f1b8619f.zip
[CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded
correctly. This fixes PR30413. Patch by David Lobron. llvm-svn: 297702
-rw-r--r--clang/lib/CodeGen/CGObjCGNU.cpp2
-rw-r--r--clang/test/CodeGenObjC/ivar-type-encoding.m35
2 files changed, 36 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index ce39bd1c947..9f6ccb4b5d2 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -2207,7 +2207,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
IvarNames.push_back(MakeConstantString(IVD->getNameAsString()));
// Get the type encoding for this ivar
std::string TypeStr;
- Context.getObjCEncodingForType(IVD->getType(), TypeStr);
+ Context.getObjCEncodingForType(IVD->getType(), TypeStr, IVD);
IvarTypes.push_back(MakeConstantString(TypeStr));
// Get the offset
uint64_t BaseOffset = ComputeIvarBaseOffset(CGM, OID, IVD);
diff --git a/clang/test/CodeGenObjC/ivar-type-encoding.m b/clang/test/CodeGenObjC/ivar-type-encoding.m
new file mode 100644
index 00000000000..ffa5e0d7af0
--- /dev/null
+++ b/clang/test/CodeGenObjC/ivar-type-encoding.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -S -emit-llvm -fobjc-runtime=gcc -o - %s | FileCheck %s
+
+@protocol NSCopying
+@end
+
+@interface NSObject {
+ struct objc_object *isa;
+}
++ (id) new;
+- (id) init;
+@end
+
+@interface NSString : NSObject <NSCopying>
++ (NSString *)foo;
+@end
+
+@interface TestClass : NSObject {
+@public
+ NSString *_stringIvar;
+ int _intIvar;
+}
+@end
+@implementation TestClass
+
+@end
+
+int main() {
+ TestClass *c = [TestClass new];
+ return 0;
+}
+
+// CHECK: @0 = private unnamed_addr constant [12 x i8] c"_stringIvar\00"
+// CHECK: @1 = private unnamed_addr constant [12 x i8] c"@\22NSString\22\00"
+// CHECK: @2 = private unnamed_addr constant [9 x i8] c"_intIvar\00"
+// CHECK: @3 = private unnamed_addr constant [2 x i8] c"i\00"
OpenPOWER on IntegriCloud