r259224 - Class Property: parse @dynamic (class).
Manman Ren via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 29 11:05:57 PST 2016
Author: mren
Date: Fri Jan 29 13:05:57 2016
New Revision: 259224
URL: http://llvm.org/viewvc/llvm-project?rev=259224&view=rev
Log:
Class Property: parse @dynamic (class).
rdar://23891898
Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/test/SemaObjC/objc-class-property.m
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=259224&r1=259223&r2=259224&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Fri Jan 29 13:05:57 2016
@@ -2353,6 +2353,31 @@ Decl *Parser::ParseObjCPropertyDynamic(S
assert(Tok.isObjCAtKeyword(tok::objc_dynamic) &&
"ParseObjCPropertyDynamic(): Expected '@dynamic'");
ConsumeToken(); // consume dynamic
+
+ bool isClassProperty = false;
+ if (Tok.is(tok::l_paren)) {
+ ConsumeParen();
+ const IdentifierInfo *II = Tok.getIdentifierInfo();
+
+ if (!II) {
+ Diag(Tok, diag::err_objc_expected_property_attr) << II;
+ SkipUntil(tok::r_paren, StopAtSemi);
+ } else {
+ SourceLocation AttrName = ConsumeToken(); // consume attribute name
+ if (II->isStr("class")) {
+ isClassProperty = true;
+ if (Tok.isNot(tok::r_paren)) {
+ Diag(Tok, diag::err_expected) << tok::r_paren;
+ SkipUntil(tok::r_paren, StopAtSemi);
+ } else
+ ConsumeParen();
+ } else {
+ Diag(AttrName, diag::err_objc_expected_property_attr) << II;
+ SkipUntil(tok::r_paren, StopAtSemi);
+ }
+ }
+ }
+
while (true) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCPropertyDefinition(getCurScope());
@@ -2371,6 +2396,7 @@ Decl *Parser::ParseObjCPropertyDynamic(S
Actions.ActOnPropertyImplDecl(
getCurScope(), atLoc, propertyLoc, false,
propertyId, nullptr, SourceLocation(),
+ isClassProperty ? ObjCPropertyQueryKind::OBJC_PR_query_class :
ObjCPropertyQueryKind::OBJC_PR_query_unknown);
if (Tok.isNot(tok::comma))
Modified: cfe/trunk/test/SemaObjC/objc-class-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc-class-property.m?rev=259224&r1=259223&r2=259224&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objc-class-property.m (original)
+++ cfe/trunk/test/SemaObjC/objc-class-property.m Fri Jan 29 13:05:57 2016
@@ -20,9 +20,10 @@
@end
@implementation A
- at dynamic x;
+ at dynamic x; // refers to the instance property
+ at dynamic (class) x; // refers to the class property
@synthesize z;
- at dynamic c;
+ at dynamic c; // refers to the class property
@end
int test() {
More information about the cfe-commits
mailing list