Re: r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-06-26 Thread Akira Hatanaka via cfe-commits
This should be fixed in r306364.

> On Jun 22, 2017, at 1:26 PM, Akira Hatanaka  wrote:
> 
> According to the documentation, the starting position of the field has to be 
> encoded too:
> 
> https://gcc.gnu.org/onlinedocs/gcc/Type-encoding.html 
> 
> 
> I’m not sure whether we need the same information for bitfield ivars though.
> 
>> On Jun 22, 2017, at 12:03 PM, Joerg Sonnenberger > > wrote:
>> 
>> On Thu, Jun 22, 2017 at 11:09:48AM -0700, Akira Hatanaka wrote:
>>> Do you want the same encoding for the bitfield “int : 1” you saw before 
>>> r297792, which is just “i"?
>>> 
>>> The encoding for bitfield is normally bN where N is the number of bits,
>>> but the comment in function EncodeBitField says GNU runtime encodes it 
>>> differently.
>> 
>> Sorry, can't answer that. I primarily care about a new clang crash that
>> didn't exist before, cut I can't answer what the correct behavior should
>> be.
>> 
>> Joerg
> 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-06-22 Thread Akira Hatanaka via cfe-commits
According to the documentation, the starting position of the field has to be 
encoded too:

https://gcc.gnu.org/onlinedocs/gcc/Type-encoding.html 


I’m not sure whether we need the same information for bitfield ivars though.

> On Jun 22, 2017, at 12:03 PM, Joerg Sonnenberger  wrote:
> 
> On Thu, Jun 22, 2017 at 11:09:48AM -0700, Akira Hatanaka wrote:
>> Do you want the same encoding for the bitfield “int : 1” you saw before 
>> r297792, which is just “i"?
>> 
>> The encoding for bitfield is normally bN where N is the number of bits,
>> but the comment in function EncodeBitField says GNU runtime encodes it 
>> differently.
> 
> Sorry, can't answer that. I primarily care about a new clang crash that
> didn't exist before, cut I can't answer what the correct behavior should
> be.
> 
> Joerg

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-06-22 Thread Joerg Sonnenberger via cfe-commits
On Thu, Jun 22, 2017 at 11:09:48AM -0700, Akira Hatanaka wrote:
> Do you want the same encoding for the bitfield “int : 1” you saw before 
> r297792, which is just “i"?
> 
> The encoding for bitfield is normally bN where N is the number of bits,
> but the comment in function EncodeBitField says GNU runtime encodes it 
> differently.

Sorry, can't answer that. I primarily care about a new clang crash that
didn't exist before, cut I can't answer what the correct behavior should
be.

Joerg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-06-22 Thread Akira Hatanaka via cfe-commits
Do you want the same encoding for the bitfield “int : 1” you saw before 
r297792, which is just “i"?

The encoding for bitfield is normally bN where N is the number of bits, but the 
comment in function EncodeBitField says GNU runtime encodes it differently.

> On Jun 22, 2017, at 8:30 AM, Joerg Sonnenberger  wrote:
> 
> On Mon, Jun 12, 2017 at 09:03:10PM +0200, Joerg Sonnenberger wrote:
>> On Thu, Jun 01, 2017 at 05:58:41PM -0700, Akira Hatanaka wrote:
>>> It crashes when there is an anonymous ivar of a bitfield type.
>>> 
>>> @interface FormatScanner {
>>>  int : 1;
>>> }
>>> @end
>>> 
>>> @implementation FormatScanner
>>> @end
>>> 
>>> I'm not sure if the code above is valid or not, but out of curiosity,
>>> why would you want an anonymous bitfield variable?
>> 
>> It's a reduced test case. The original test case has a variable name in
>> it.
> 
> Ping?
> 
> Joerg

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-06-22 Thread Joerg Sonnenberger via cfe-commits
On Mon, Jun 12, 2017 at 09:03:10PM +0200, Joerg Sonnenberger wrote:
> On Thu, Jun 01, 2017 at 05:58:41PM -0700, Akira Hatanaka wrote:
> > It crashes when there is an anonymous ivar of a bitfield type.
> > 
> > @interface FormatScanner {
> >   int : 1;
> > }
> > @end
> > 
> > @implementation FormatScanner
> > @end
> > 
> > I'm not sure if the code above is valid or not, but out of curiosity,
> > why would you want an anonymous bitfield variable?
> 
> It's a reduced test case. The original test case has a variable name in
> it.

Ping?

Joerg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-06-12 Thread Joerg Sonnenberger via cfe-commits
On Thu, Jun 01, 2017 at 05:58:41PM -0700, Akira Hatanaka wrote:
> It crashes when there is an anonymous ivar of a bitfield type.
> 
> @interface FormatScanner {
>   int : 1;
> }
> @end
> 
> @implementation FormatScanner
> @end
> 
> I'm not sure if the code above is valid or not, but out of curiosity,
> why would you want an anonymous bitfield variable?

It's a reduced test case. The original test case has a variable name in
it.

Joerg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-06-01 Thread Joerg Sonnenberger via cfe-commits
On Tue, Mar 14, 2017 at 04:00:53AM -, Akira Hatanaka via cfe-commits wrote:
> Author: ahatanak
> Date: Mon Mar 13 23:00:52 2017
> New Revision: 297702
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=297702=rev
> Log:
> [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded
> correctly.

This results in asserts on the attached test case. Can you have a look,
please?

Joerg
typedef BOOL;
@interface FormatScanner {
  BOOL : 1;
}
@end
@implementation FormatScanner
@end
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r297702 - [CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded

2017-03-13 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Mar 13 23:00:52 2017
New Revision: 297702

URL: http://llvm.org/viewvc/llvm-project?rev=297702=rev
Log:
[CodeGen][ObjC] Fix a bug where the type of an ivar wasn't encoded
correctly.

This fixes PR30413.

Patch by David Lobron.

Added:
cfe/trunk/test/CodeGenObjC/ivar-type-encoding.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=297702=297701=297702=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Mon Mar 13 23:00:52 2017
@@ -2207,7 +2207,7 @@ void CGObjCGNU::GenerateClass(const ObjC
   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);

Added: cfe/trunk/test/CodeGenObjC/ivar-type-encoding.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/ivar-type-encoding.m?rev=297702=auto
==
--- cfe/trunk/test/CodeGenObjC/ivar-type-encoding.m (added)
+++ cfe/trunk/test/CodeGenObjC/ivar-type-encoding.m Mon Mar 13 23:00:52 2017
@@ -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 
++ (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"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits