[PATCH] D27214: [ObjC] Encode type arguments in property information string constants

2017-08-07 Thread Greg Parker via Phabricator via cfe-commits
gparker42 added a comment.

This won't work. The property attribute string consists of comma-separated 
fields. The encoding used here embeds commas into the type value, which will 
break parsing of the attribute string. You'll need to use a separator other 
than a comma.


Repository:
  rL LLVM

https://reviews.llvm.org/D27214



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


[PATCH] D27214: [ObjC] Encode type arguments in property information string constants

2016-11-30 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Do you know whether this patch would have any effect on the objective-c 
runtime? I suspect it wouldn't cause the runtime to crash, but I don't know how 
the runtime uses the encoded type information.

Other than that, the changes made in this patch look good to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D27214



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


[PATCH] D27214: [ObjC] Encode type arguments in property information string constants

2016-11-29 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: rjmccall, ahatanak.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch ensures that Objective-C type arguments are included in the string 
constants that have encoded information about `@property` declarations.


Repository:
  rL LLVM

https://reviews.llvm.org/D27214

Files:
  lib/AST/ASTContext.cpp
  test/CodeGenObjC/objc2-property-encode.m


Index: test/CodeGenObjC/objc2-property-encode.m
===
--- test/CodeGenObjC/objc2-property-encode.m
+++ test/CodeGenObjC/objc2-property-encode.m
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o %t %s
 // RUN: grep -e "T@22NSString22" %t
+// RUN: FileCheck %s -input-file=%t
 @interface NSString @end
 
 typedef NSString StoreVersionID ;
@@ -11,3 +12,30 @@
 @implementation Parent
 @dynamic foo;
 @end
+
+// rdar://22496485
+@interface TypeParameters<__covariant ObjectType>
+
+@end
+
+@interface TypeParameters2<__covariant A, __covariant B>
+
+@end
+
+@protocol MyProtocol;
+@class MyClass;
+
+@interface Bar
+
+@property(copy) TypeParameters *p1;
+
+@property(copy) TypeParameters2 *p2;
+
+@end
+
+@implementation Bar
+
+@end
+
+// CHECK: @OBJC_PROP_NAME_ATTR_{{.*}} = {{.*}} 
c"T@\22TypeParameters<@\22MyClass\22>\22,C,V_p1\00"
+// CHECK: @OBJC_PROP_NAME_ATTR_{{.*}} = {{.*}} 
c"T@\22TypeParameters2<@\22MyClass\22,@\22MyClass\22>\22,C,V_p2\00"
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -34,6 +34,7 @@
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Capacity.h"
@@ -6275,6 +6276,18 @@
 (FD || EncodingProperty || EncodeClassNames)) {
   S += '"';
   S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
+  ArrayRef TypeArgs = OPT->getTypeArgs();
+  if (!TypeArgs.empty()) {
+S += '<';
+for (const auto  : llvm::enumerate(TypeArgs)) {
+  if (I.Index)
+S += ',';
+  getObjCEncodingForTypeImpl(I.Value, S, ExpandPointedToStructures,
+ ExpandStructures, nullptr, false,
+ EncodingProperty);
+}
+S += '>';
+  }
   for (const auto *I : OPT->quals()) {
 S += '<';
 S += I->getObjCRuntimeNameAsString();


Index: test/CodeGenObjC/objc2-property-encode.m
===
--- test/CodeGenObjC/objc2-property-encode.m
+++ test/CodeGenObjC/objc2-property-encode.m
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o %t %s
 // RUN: grep -e "T@22NSString22" %t
+// RUN: FileCheck %s -input-file=%t
 @interface NSString @end
 
 typedef NSString StoreVersionID ;
@@ -11,3 +12,30 @@
 @implementation Parent
 @dynamic foo;
 @end
+
+// rdar://22496485
+@interface TypeParameters<__covariant ObjectType>
+
+@end
+
+@interface TypeParameters2<__covariant A, __covariant B>
+
+@end
+
+@protocol MyProtocol;
+@class MyClass;
+
+@interface Bar
+
+@property(copy) TypeParameters *p1;
+
+@property(copy) TypeParameters2 *p2;
+
+@end
+
+@implementation Bar
+
+@end
+
+// CHECK: @OBJC_PROP_NAME_ATTR_{{.*}} = {{.*}} c"T@\22TypeParameters<@\22MyClass\22>\22,C,V_p1\00"
+// CHECK: @OBJC_PROP_NAME_ATTR_{{.*}} = {{.*}} c"T@\22TypeParameters2<@\22MyClass\22,@\22MyClass\22>\22,C,V_p2\00"
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -34,6 +34,7 @@
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/Support/Capacity.h"
@@ -6275,6 +6276,18 @@
 (FD || EncodingProperty || EncodeClassNames)) {
   S += '"';
   S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
+  ArrayRef TypeArgs = OPT->getTypeArgs();
+  if (!TypeArgs.empty()) {
+S += '<';
+for (const auto  : llvm::enumerate(TypeArgs)) {
+  if (I.Index)
+S += ',';
+  getObjCEncodingForTypeImpl(I.Value, S, ExpandPointedToStructures,
+ ExpandStructures, nullptr, false,
+ EncodingProperty);
+}
+S += '>';
+  }
   for (const auto *I : OPT->quals()) {
 S += '<';
 S += I->getObjCRuntimeNameAsString();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org