[PATCH] D27214: [ObjC] Encode type arguments in property information string constants
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 29 08:22:16 PST 2016
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@\\\\22NSString\\\\22" %t
+// RUN: FileCheck %s -input-file=%t
@interface NSString @end
typedef NSString StoreVersionID ;
@@ -11,3 +12,30 @@
@implementation Parent
@dynamic foo;
@end
+
+// rdar://22496485
+ at interface TypeParameters<__covariant ObjectType>
+
+ at end
+
+ at interface TypeParameters2<__covariant A, __covariant B>
+
+ at end
+
+ at protocol MyProtocol;
+ at class MyClass;
+
+ at interface Bar
+
+ at property(copy) TypeParameters<MyClass*> *p1;
+
+ at property(copy) TypeParameters2<MyClass*, MyClass*><MyProtocol> *p2;
+
+ at end
+
+ at implementation Bar
+
+ at 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><MyProtocol>\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<QualType> TypeArgs = OPT->getTypeArgs();
+ if (!TypeArgs.empty()) {
+ S += '<';
+ for (const auto &I : 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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27214.79575.patch
Type: text/x-patch
Size: 2247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161129/7c356ab0/attachment.bin>
More information about the cfe-commits
mailing list