Skip to content

Commit ff8534b

Browse files
committedMar 14, 2017
[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
1 parent b9d9ac4 commit ff8534b

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
 

‎clang/lib/CodeGen/CGObjCGNU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2207,7 +2207,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
22072207
IvarNames.push_back(MakeConstantString(IVD->getNameAsString()));
22082208
// Get the type encoding for this ivar
22092209
std::string TypeStr;
2210-
Context.getObjCEncodingForType(IVD->getType(), TypeStr);
2210+
Context.getObjCEncodingForType(IVD->getType(), TypeStr, IVD);
22112211
IvarTypes.push_back(MakeConstantString(TypeStr));
22122212
// Get the offset
22132213
uint64_t BaseOffset = ComputeIvarBaseOffset(CGM, OID, IVD);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %clang_cc1 -S -emit-llvm -fobjc-runtime=gcc -o - %s | FileCheck %s
2+
3+
@protocol NSCopying
4+
@end
5+
6+
@interface NSObject {
7+
struct objc_object *isa;
8+
}
9+
+ (id) new;
10+
- (id) init;
11+
@end
12+
13+
@interface NSString : NSObject <NSCopying>
14+
+ (NSString *)foo;
15+
@end
16+
17+
@interface TestClass : NSObject {
18+
@public
19+
NSString *_stringIvar;
20+
int _intIvar;
21+
}
22+
@end
23+
@implementation TestClass
24+
25+
@end
26+
27+
int main() {
28+
TestClass *c = [TestClass new];
29+
return 0;
30+
}
31+
32+
// CHECK: @0 = private unnamed_addr constant [12 x i8] c"_stringIvar\00"
33+
// CHECK: @1 = private unnamed_addr constant [12 x i8] c"@\22NSString\22\00"
34+
// CHECK: @2 = private unnamed_addr constant [9 x i8] c"_intIvar\00"
35+
// CHECK: @3 = private unnamed_addr constant [2 x i8] c"i\00"

0 commit comments

Comments
 (0)
Please sign in to comment.