Lines Matching +full:semi +full:- +full:static

1 //===--- ParseObjC.cpp - Objective C Parsing ------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the Objective-C portions of the Parser interface.
11 //===----------------------------------------------------------------------===//
30 /// Skips attributes after an Objective-C @ directive. Emits a diagnostic.
43 /// ParseObjCAtDirectives - Handle parts of the external-declaration production:
44 /// external-declaration: [C99 6.9]
45 /// [OBJC] objc-class-definition
46 /// [OBJC] objc-class-declaration
47 /// [OBJC] objc-alias-declaration
48 /// [OBJC] objc-protocol-definition
49 /// [OBJC] objc-method-definition
105 SkipUntil(tok::semi); in ParseObjCAtDirectives()
109 SkipUntil(tok::semi); in ParseObjCAtDirectives()
143 /// objc-class-declaration:
144 /// '@' 'class' objc-class-forward-decl (',' objc-class-forward-decl)* ';'
146 /// objc-class-forward-decl:
147 /// identifier objc-type-parameter-list[opt]
164 SkipUntil(tok::semi); in ParseObjCAtClassDeclaration()
171 // Parse the optional objc-type-parameter-list. in ParseObjCAtClassDeclaration()
181 if (ExpectAndConsume(tok::semi, diag::err_expected_after, "@class")) in ParseObjCAtClassDeclaration()
197 CurParsedObjCImpl->finish(AtLoc); in CheckNestedObjCContexts()
204 Diag(Decl->getBeginLoc(), diag::note_objc_container_start) << (int)ock; in CheckNestedObjCContexts()
208 /// objc-interface:
209 /// objc-class-interface-attributes[opt] objc-class-interface
210 /// objc-category-interface
212 /// objc-class-interface:
213 /// '@' 'interface' identifier objc-type-parameter-list[opt]
214 /// objc-superclass[opt] objc-protocol-refs[opt]
215 /// objc-class-instance-variables[opt]
216 /// objc-interface-decl-list
219 /// objc-category-interface:
220 /// '@' 'interface' identifier objc-type-parameter-list[opt]
221 /// '(' identifier[opt] ')' objc-protocol-refs[opt]
222 /// objc-interface-decl-list
225 /// objc-superclass:
226 /// ':' identifier objc-type-arguments[opt]
228 /// objc-class-interface-attributes:
233 /// __attribute__((objc_exception)) - used by NSException on 64-bit
255 // We have a class or category name - consume it. in ParseObjCAtInterfaceDeclaration()
259 // Parse the objc-type-parameter-list or objc-protocol-refs. For the latter in ParseObjCAtInterfaceDeclaration()
396 ClsType->mergeDuplicateDefinitionWithCommon(PreviousDef->getDefinition()); in ParseObjCAtInterfaceDeclaration()
401 ClsType->setInvalidDecl(); in ParseObjCAtInterfaceDeclaration()
408 /// Add an attribute for a context-sensitive type nullability to the given
410 static void addContextSensitiveTypeNullability(Parser &P, in addContextSensitiveTypeNullability()
416 auto getNullabilityAttr = [&](AttributePool &Pool) -> ParsedAttr * { in addContextSensitiveTypeNullability()
435 /// Parse an Objective-C type parameter list, if present, or capture
439 /// objc-type-parameter-list:
440 /// '<' objc-type-parameter (',' objc-type-parameter)* '>'
442 /// objc-type-parameter:
443 /// objc-type-parameter-variance? identifier objc-type-parameter-bound[opt]
445 /// objc-type-parameter-bound:
446 /// ':' type-name
448 /// objc-type-parameter-variance:
541 // type-name in parseObjCTypeParamListOrProtocolRefs()
570 tok::comma, tok::semi }, in parseObjCTypeParamListOrProtocolRefs()
579 // or extension). This disambiguates between an objc-type-parameter-list in parseObjCTypeParamListOrProtocolRefs()
580 // and a objc-protocol-refs. in parseObjCTypeParamListOrProtocolRefs()
605 /// Parse an objc-type-parameter-list.
617 static bool isTopLevelObjCKeyword(tok::ObjCKeywordKind DirectiveKind) { in isTopLevelObjCKeyword()
630 /// objc-interface-decl-list:
632 /// objc-interface-decl-list objc-property-decl [OBJC2]
633 /// objc-interface-decl-list objc-method-requirement [OBJC2]
634 /// objc-interface-decl-list objc-method-proto ';'
635 /// objc-interface-decl-list declaration
636 /// objc-interface-decl-list ';'
638 /// objc-method-requirement: [OBJC2]
656 // Consume the ';' here, since ParseObjCMethodPrototype() is re-used for in ParseObjCInterfaceDeclList()
659 // We didn't find a semi and we error'ed out. Skip until a ';' or '@'. in ParseObjCInterfaceDeclList()
661 if (Tok.is(tok::semi)) in ParseObjCInterfaceDeclList()
674 if (Tok.is(tok::semi)) { in ParseObjCInterfaceDeclList()
676 // to make -Wextra-semi diagnose them. in ParseObjCInterfaceDeclList()
685 // Code completion within an Objective-C interface. in ParseObjCInterfaceDeclList()
733 if (DirectiveKind == tok::objc_end) { // @end -> terminate list in ParseObjCInterfaceDeclList()
740 SkipUntil(tok::semi); in ParseObjCInterfaceDeclList()
783 auto ObjCPropertyCallback = [&](ParsingFieldDeclarator &FD) -> Decl * { in ParseObjCInterfaceDeclList()
795 // Map a nullability property attribute to a context-sensitive keyword in ParseObjCInterfaceDeclList()
828 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list); in ParseObjCInterfaceDeclList()
834 // top-level ObjC keyword or EOF. In the former case, eat the @end. In the in ParseObjCInterfaceDeclList()
841 Diag(CDecl->getBeginLoc(), diag::note_objc_container_start) in ParseObjCInterfaceDeclList()
853 static void diagnoseRedundantPropertyNullability(Parser &P, in diagnoseRedundantPropertyNullability()
872 /// property-attr-decl: '(' property-attrlist ')'
873 /// property-attrlist:
874 /// property-attribute
875 /// property-attrlist ',' property-attribute
876 /// property-attribute:
917 if (II->isStr("readonly")) in ParseObjCPropertyAttribute()
919 else if (II->isStr("assign")) in ParseObjCPropertyAttribute()
921 else if (II->isStr("unsafe_unretained")) in ParseObjCPropertyAttribute()
923 else if (II->isStr("readwrite")) in ParseObjCPropertyAttribute()
925 else if (II->isStr("retain")) in ParseObjCPropertyAttribute()
927 else if (II->isStr("strong")) in ParseObjCPropertyAttribute()
929 else if (II->isStr("copy")) in ParseObjCPropertyAttribute()
931 else if (II->isStr("nonatomic")) in ParseObjCPropertyAttribute()
933 else if (II->isStr("atomic")) in ParseObjCPropertyAttribute()
935 else if (II->isStr("weak")) in ParseObjCPropertyAttribute()
937 else if (II->isStr("getter") || II->isStr("setter")) { in ParseObjCPropertyAttribute()
938 bool IsSetter = II->getNameStart()[0] == 's'; in ParseObjCPropertyAttribute()
983 } else if (II->isStr("nonnull")) { in ParseObjCPropertyAttribute()
990 } else if (II->isStr("nullable")) { in ParseObjCPropertyAttribute()
997 } else if (II->isStr("null_unspecified")) { in ParseObjCPropertyAttribute()
1004 } else if (II->isStr("null_resettable")) { in ParseObjCPropertyAttribute()
1014 } else if (II->isStr("class")) { in ParseObjCPropertyAttribute()
1016 } else if (II->isStr("direct")) { in ParseObjCPropertyAttribute()
1033 /// objc-method-proto:
1034 /// objc-instance-method objc-method-decl objc-method-attributes[opt]
1035 /// objc-class-method objc-method-decl objc-method-attributes[opt]
1037 /// objc-instance-method: '-'
1038 /// objc-class-method: '+'
1040 /// objc-method-attributes: [OBJC2]
1045 assert(Tok.isOneOf(tok::minus, tok::plus) && "expected +/-"); in ParseObjCMethodPrototype()
1056 /// objc-selector:
1170 /// objc-for-collection-in: 'in'
1173 // FIXME: May have to do additional look-ahead to only allow for in isTokIdentifier_in()
1180 /// ParseObjCTypeQualifierList - This routine parses the objective-c's type
1184 /// objc-type-qualifiers:
1185 /// objc-type-qualifier
1186 /// objc-type-qualifiers objc-type-qualifier
1188 /// objc-type-qualifier:
1266 static void takeDeclAttributes(ParsedAttributesView &attrs, in takeDeclAttributes()
1276 /// takeDeclAttributes - Take all the decl attributes from the given
1278 static void takeDeclAttributes(ParsedAttributes &attrs, in takeDeclAttributes()
1295 /// objc-type-name:
1296 /// '(' objc-type-qualifiers[opt] type-name ')'
1297 /// '(' objc-type-qualifiers[opt] ')'
1332 // Map a nullability specifier to a context-sensitive keyword attribute. in ParseObjCTypeName()
1365 /// objc-method-decl:
1366 /// objc-selector
1367 /// objc-keyword-selector objc-parmlist[opt]
1368 /// objc-type-name objc-selector
1369 /// objc-type-name objc-keyword-selector objc-parmlist[opt]
1371 /// objc-keyword-selector:
1372 /// objc-keyword-decl
1373 /// objc-keyword-selector objc-keyword-decl
1375 /// objc-keyword-decl:
1376 /// objc-selector ':' objc-type-name objc-keyword-attributes[opt] identifier
1377 /// objc-selector ':' objc-keyword-attributes[opt] identifier
1378 /// ':' objc-type-name objc-keyword-attributes[opt] identifier
1379 /// ':' objc-keyword-attributes[opt] identifier
1381 /// objc-parmlist:
1382 /// objc-parms objc-ellipsis[opt]
1384 /// objc-parms:
1385 /// objc-parms , parameter-declaration
1387 /// objc-ellipsis:
1390 /// objc-keyword-attributes: [OBJC2]
1576 /// objc-protocol-refs:
1577 /// '<' identifier-list '>'
1625 assert(getLangOpts().ObjC && "Protocol qualifiers only exist in Objective-C"); in parseObjCProtocolQualifierType()
1644 /// Parse Objective-C type arguments or protocol qualifiers.
1646 /// objc-type-arguments:
1647 /// '<' type-name '...'[opt] (',' type-name '...'[opt])* '>'
1669 // Parse a list of comma-separated identifiers, bailing out if we in parseObjCTypeArgsOrProtocolQualifiers()
1692 if (!BaseT.isNull() && BaseT->acceptsObjCTypeParams()) { in parseObjCTypeArgsOrProtocolQualifiers()
1772 // Continue parsing type-names. in parseObjCTypeArgsOrProtocolQualifiers()
1835 // Parse the first angle-bracket-delimited clause. in parseObjCTypeArgsAndProtocolQualifiers()
1849 // An Objective-C object pointer followed by type arguments in parseObjCTypeArgsAndProtocolQualifiers()
1927 /// objc-class-instance-variables:
1928 /// '{' objc-instance-variable-decl-list[opt] '}'
1930 /// objc-instance-variable-decl-list:
1931 /// objc-visibility-spec
1932 /// objc-instance-variable-decl ';'
1934 /// objc-instance-variable-decl-list objc-visibility-spec
1935 /// objc-instance-variable-decl-list objc-instance-variable-decl ';'
1936 /// objc-instance-variable-decl-list static_assert-declaration
1937 /// objc-instance-variable-decl-list ';'
1939 /// objc-visibility-spec:
1945 /// objc-instance-variable-decl:
1946 /// struct-declaration
1960 // Each iteration of this loop reads one objc-instance-variable-decl. in ParseObjCClassInstanceVariables()
1962 // Check for extraneous top-level semicolon. in ParseObjCClassInstanceVariables()
1963 if (Tok.is(tok::semi)) { in ParseObjCClassInstanceVariables()
1969 if (TryConsumeToken(tok::at)) { // parse objc-visibility-spec in ParseObjCClassInstanceVariables()
1987 Tok.setLocation(Tok.getLocation().getLocWithOffset(-1)); in ParseObjCClassInstanceVariables()
2010 // C struct and in Objective-C class instance variables. in ParseObjCClassInstanceVariables()
2017 auto ObjCIvarCallback = [&](ParsingFieldDeclarator &FD) -> Decl * { in ParseObjCClassInstanceVariables()
2035 if (Tok.is(tok::semi)) { in ParseObjCClassInstanceVariables()
2047 /// objc-protocol-declaration:
2048 /// objc-protocol-definition
2049 /// objc-protocol-forward-reference
2051 /// objc-protocol-definition:
2053 /// objc-protocol-refs[opt]
2054 /// objc-interface-decl-list
2057 /// objc-protocol-forward-reference:
2058 /// \@protocol identifier-list ';'
2061 /// identifier-list ;": objc-interface-decl-list may not start with a
2062 /// semicolon in the first alternative if objc-protocol-refs are omitted.
2084 if (TryConsumeToken(tok::semi)) { // forward declaration of one protocol. in ParseObjCAtProtocolDeclaration()
2100 SkipUntil(tok::semi); in ParseObjCAtProtocolDeclaration()
2111 if (ExpectAndConsume(tok::semi, diag::err_expected_after, "@protocol")) in ParseObjCAtProtocolDeclaration()
2138 ProtoType->mergeDuplicateDefinitionWithCommon( in ParseObjCAtProtocolDeclaration()
2139 PreviousDef->getDefinition()); in ParseObjCAtProtocolDeclaration()
2149 /// objc-implementation:
2150 /// objc-class-implementation-prologue
2151 /// objc-category-implementation-prologue
2153 /// objc-class-implementation-prologue:
2154 /// @implementation identifier objc-superclass[opt]
2155 /// objc-class-instance-variables[opt]
2157 /// objc-category-implementation-prologue:
2178 // We have a class or category name - consume it. in ParseObjCAtImplementationDeclaration()
2298 CurParsedObjCImpl->finish(atEnd); in ParseObjCAtEndDeclaration()
2311 P.Diag(Dcl->getBeginLoc(), diag::note_objc_container_start) in ~ObjCImplParsingDataRAII()
2332 false/*c-functions*/); in finish()
2344 /// compatibility-alias-decl:
2345 /// @compatibility_alias alias-name class-name ';'
2354 SourceLocation aliasLoc = ConsumeToken(); // consume alias-name in ParseObjCAtAliasDeclaration()
2358 SourceLocation classLoc = ConsumeToken(); // consume class-name; in ParseObjCAtAliasDeclaration()
2359 ExpectAndConsume(tok::semi, diag::err_expected_after, "@compatibility_alias"); in ParseObjCAtAliasDeclaration()
2364 /// property-synthesis:
2365 /// @synthesize property-ivar-list ';'
2367 /// property-ivar-list:
2368 /// property-ivar
2369 /// property-ivar-list ',' property-ivar
2371 /// property-ivar:
2390 SkipUntil(tok::semi); in ParseObjCPropertySynthesize()
2399 // property '=' ivar-name in ParseObjCPropertySynthesize()
2410 propertyIvarLoc = ConsumeToken(); // consume ivar-name in ParseObjCPropertySynthesize()
2419 ExpectAndConsume(tok::semi, diag::err_expected_after, "@synthesize"); in ParseObjCPropertySynthesize()
2423 /// property-dynamic:
2424 /// @dynamic property-list
2426 /// property-list:
2428 /// property-list ',' identifier
2445 if (II->isStr("class")) { in ParseObjCPropertyDynamic()
2468 SkipUntil(tok::semi); in ParseObjCPropertyDynamic()
2484 ExpectAndConsume(tok::semi, diag::err_expected_after, "@dynamic"); in ParseObjCPropertyDynamic()
2488 /// objc-throw-statement:
2494 if (Tok.isNot(tok::semi)) { in ParseObjCThrowStmt()
2497 SkipUntil(tok::semi); in ParseObjCThrowStmt()
2502 ExpectAndConsume(tok::semi, diag::err_expected_after, "@throw"); in ParseObjCThrowStmt()
2506 /// objc-synchronized-statement:
2507 /// @synchronized '(' expression ')' compound-statement
2560 /// objc-try-catch-statement:
2561 /// @try compound-statement objc-catch-list[opt]
2562 /// @try compound-statement objc-catch-list[opt] @finally compound-statement
2564 /// objc-catch-list:
2565 /// @catch ( parameter-declaration ) compound-statement
2566 /// objc-catch-list @catch ( catch-parameter-declaration ) compound-statement
2567 /// catch-parameter-declaration:
2568 /// parameter-declaration
2687 /// objc-autoreleasepool-statement:
2688 /// @autoreleasepool compound-statement
2710 /// StashAwayMethodOrFunctionBodyTokens - Consume the tokens and store them
2720 CurParsedObjCImpl->LateParsedObjCMethods.push_back(LM); in StashAwayMethodOrFunctionBodyTokens()
2721 CachedTokens &Toks = LM->Toks; in StashAwayMethodOrFunctionBodyTokens()
2754 /// objc-method-def: objc-method-proto ';'[opt] '{' body '}'
2760 "parsing Objective-C method"); in ParseObjCMethodDefinition()
2763 if (Tok.is(tok::semi)) { in ParseObjCMethodDefinition()
2792 && "ParseObjCMethodDefinition - Method out of @implementation"); in ParseObjCMethodDefinition()
2820 SkipUntil(tok::semi); in ParseObjCAtStatement()
2830 SkipUntil(tok::semi); in ParseObjCAtStatement()
2854 case tok::minus: Symbol = "-"; break; in ParseObjCAtExpression()
2877 case tok::string_literal: // primary-expression: string-literal in ParseObjCAtExpression()
2887 case tok::kw_true: // Objective-C++, etc. in ParseObjCAtExpression()
2890 case tok::kw_false: // Objective-C++, etc. in ParseObjCAtExpression()
2895 // Objective-C array literal in ParseObjCAtExpression()
2899 // Objective-C dictionary literal in ParseObjCAtExpression()
2903 // Objective-C boxed expression in ParseObjCAtExpression()
2910 switch (Tok.getIdentifierInfo()->getObjCKeywordID()) { in ParseObjCAtExpression()
2926 char ch = Tok.getIdentifierInfo()->getNameStart()[0]; in ParseObjCAtExpression()
2944 /// Parse the receiver of an Objective-C++ message send.
2947 /// Objective-C++ either as a type or as an expression. Note that this
2961 /// objc-receiver: [C++]
2964 /// simple-type-specifier
2965 /// typename-specifier
2974 // objc-receiver: in ParseObjCXXMessageReceiver()
2988 // objc-receiver: in ParseObjCXXMessageReceiver()
2989 // typename-specifier in ParseObjCXXMessageReceiver()
2990 // simple-type-specifier in ParseObjCXXMessageReceiver()
2998 // function-style cast, e.g., in ParseObjCXXMessageReceiver()
3000 // postfix-expression: in ParseObjCXXMessageReceiver()
3001 // simple-type-specifier ( expression-list [opt] ) in ParseObjCXXMessageReceiver()
3002 // typename-specifier ( expression-list [opt] ) in ParseObjCXXMessageReceiver()
3005 // postfix-expression suffix, followed by the (optional) in ParseObjCXXMessageReceiver()
3006 // right-hand side of the binary expression. We have an in ParseObjCXXMessageReceiver()
3021 // We have a class message. Turn the simple-type-specifier or in ParseObjCXXMessageReceiver()
3022 // typename-specifier we parsed into a type and parse the in ParseObjCXXMessageReceiver()
3036 /// Objective-C message send, using a simplified heuristic to avoid overhead.
3038 /// This routine will only return true for a subset of valid message-send
3063 if (Type.isUsable() && Type.get().get()->isObjCObjectOrInterfaceType()) { in isStartOfObjCClassMessageMissingOpenBracket()
3076 /// objc-message-expr:
3077 /// '[' objc-receiver objc-message-args ']'
3079 /// objc-receiver: [C]
3082 /// class-name
3083 /// type-name
3102 // FIXME: This doesn't benefit from the same typo-correction we in ParseObjCMessageExpression()
3103 // get in Objective-C. in ParseObjCMessageExpression()
3105 NextToken().isNot(tok::period) && getCurScope()->isInObjcMethodScope()) in ParseObjCMessageExpression()
3180 /// Parse the remainder of an Objective-C message following the
3181 /// '[' objc-receiver.
3200 /// objc-message-args:
3201 /// objc-selector
3202 /// objc-keywordarg-list
3204 /// objc-keywordarg-list:
3205 /// objc-keywordarg
3206 /// objc-keywordarg-list objc-keywordarg
3208 /// objc-keywordarg:
3209 /// selector-name[opt] ':' objc-keywordexpr
3211 /// objc-keywordexpr:
3212 /// nonempty-expr-list
3214 /// nonempty-expr-list:
3215 /// assignment-expression
3216 /// nonempty-expr-list , assignment-expression
3239 // Parse objc-selector in ParseObjCMessageExpressionBody()
3415 /// ParseObjCBooleanLiteral -
3416 /// objc-scalar-literal : '@' boolean-keyword
3418 /// boolean-keyword: 'true' | 'false' | '__objc_yes' | '__objc_no'
3426 /// ParseObjCCharacterLiteral -
3427 /// objc-scalar-literal : '@' character-literal
3438 /// ParseObjCNumericLiteral -
3439 /// objc-scalar-literal : '@' scalar-literal
3441 /// scalar-literal : | numeric-constant /* any numeric constant. */
3452 /// ParseObjCBoxedExpr -
3453 /// objc-box-expression:
3454 /// @( assignment-expression )
3469 // Wrap the sub-expression in a parenthesized expression, to distinguish in ParseObjCBoxedExpr()
3586 /// objc-encode-expression:
3587 /// \@encode ( type-name )
3611 /// objc-protocol-expression
3612 /// \@protocol ( protocol-name )
3636 /// objc-selector-expression
3637 /// @selector '(' '('[opt] objc-keyword-selector ')'[opt] ')'
3704 // MCDecl might be null due to error in method or c-function prototype, etc. in ParseLexedObjCMethodDefs()
3715 assert(!LM.Toks.empty() && "ParseLexedObjCMethodDef - Empty body!"); in ParseLexedObjCMethodDefs()
3733 "Inline objective-c method not starting with '{' or 'try' or ':'"); in ParseLexedObjCMethodDefs()
3734 // Enter a scope for the method or c-function body. in ParseLexedObjCMethodDefs()
3740 // Tell the actions module that we have entered a method or c-function definition in ParseLexedObjCMethodDefs()
3768 // this might be code-completion token, which must be propagated to callers. in ParseLexedObjCMethodDefs()