Lines Matching +full:semi +full:- +full:static
1 //===--- Parser.cpp - C Language Family Parser ----------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
77 return this->ParseTypeFromString(TypeStr, Context, IncludeLoc); in Parser()
110 static bool IsCommonTypo(tok::TokenKind ExpectedTok, const Token &Tok) { in IsCommonTypo()
112 case tok::semi: in IsCommonTypo()
125 // Detect common single-character typos and resume. in ExpectAndConsume()
165 if (TryConsumeToken(tok::semi)) in ExpectAndConsumeSemi()
174 NextToken().is(tok::semi)) { in ExpectAndConsumeSemi()
183 return ExpectAndConsume(tok::semi, DiagID , TokenUsed); in ExpectAndConsumeSemi()
187 if (!Tok.is(tok::semi)) return; in ConsumeExtraSemi()
194 while ((Tok.is(tok::semi) && !Tok.isAtStartOfLine())) { in ConsumeExtraSemi()
227 if (II->isCPlusPlusKeyword(getLangOpts())) { in expectIdentifier()
230 // Objective-C++: Recover by treating this keyword as a valid identifier. in expectIdentifier()
270 //===----------------------------------------------------------------------===//
272 //===----------------------------------------------------------------------===//
274 static bool HasFlagsSet(Parser::SkipUntilFlags L, Parser::SkipUntilFlags R) { in HasFlagsSet()
278 /// SkipUntil - Read tokens until we get to the specified token, then consume
349 // Recursively skip properly-nested parens. in SkipUntil()
357 // Recursively skip properly-nested square brackets. in SkipUntil()
365 // Recursively skip properly-nested braces. in SkipUntil()
402 case tok::semi: in SkipUntil()
415 //===----------------------------------------------------------------------===//
417 //===----------------------------------------------------------------------===//
419 /// EnterScope - Start a new scope.
422 Scope *N = ScopeCache[--NumCachedScopes]; in EnterScope()
423 N->Init(getCurScope(), ScopeFlags); in EnterScope()
430 /// ExitScope - Pop a scope off the scope stack.
439 Actions.CurScope = OldScope->getParent(); in ExitScope()
451 : CurScope(ManageFlags ? Self->getCurScope() : nullptr) { in ParseScopeFlags()
453 OldFlags = CurScope->getFlags(); in ParseScopeFlags()
454 CurScope->setFlags(ScopeFlags); in ParseScopeFlags()
462 CurScope->setFlags(OldFlags); in ~ParseScopeFlags()
466 //===----------------------------------------------------------------------===//
468 //===----------------------------------------------------------------------===//
488 /// Initialize - Warm up the parser.
496 // Initialization for Objective-C context sensitive keywords recognition. in Initialize()
581 // Prime the lexer look-ahead. in Initialize()
587 Id->Destroy(); in DestroyTemplateIds()
591 /// Parse the first top-level declaration in a translation unit.
593 /// translation-unit:
594 /// [C] external-declaration
595 /// [C] translation-unit external-declaration
596 /// [C++] top-level-declaration-seq[opt]
597 /// [C++20] global-module-fragment[opt] module-declaration
598 /// top-level-declaration-seq[opt] private-module-fragment[opt]
610 // C11 6.9p1 says translation units must have at least one top-level in ParseFirstTopLevelDecl()
622 /// ParseTopLevelDecl - Parse one top-level declaration, return whatever the
625 /// top-level-declaration:
627 /// [C++20] module-import-declaration
650 // an export-declaration containing an import-declaration. in ParseTopLevelDecl()
652 // Recognize context-sensitive C++20 'export module' and 'export import' in ParseTopLevelDecl()
688 if (!getLangOpts().CPlusPlusModules || !Mod->isHeaderUnit()) in ParseTopLevelDecl()
718 // Check whether -fmax-tokens= was reached. in ParseTopLevelDecl()
738 // is never interpreted as the declaration of a top-level-declaration. in ParseTopLevelDecl()
771 // Non-imports disallow further imports. in ParseTopLevelDecl()
775 // Non-imports disallow further imports. in ParseTopLevelDecl()
786 /// external-declaration: [C99 6.9], declaration: [C++ dcl.dcl]
787 /// function-definition
789 /// [GNU] asm-definition
790 /// [GNU] __extension__ external-declaration
791 /// [OBJC] objc-class-definition
792 /// [OBJC] objc-class-declaration
793 /// [OBJC] objc-alias-declaration
794 /// [OBJC] objc-protocol-definition
795 /// [OBJC] objc-method-definition
797 /// [C++] linkage-specification
798 /// [GNU] asm-definition:
799 /// simple-asm-expr ';'
800 /// [C++11] empty-declaration
801 /// [C++11] attribute-declaration
803 /// [C++11] empty-declaration:
808 /// [C++20] module-import-declaration
889 case tok::semi: in ParseExternalDeclaration()
890 // Either a C++11 empty-declaration or attribute-declaration. in ParseExternalDeclaration()
916 // Check if GNU-style InlineAsm is disabled. in ParseExternalDeclaration()
921 if (!SL->getString().trim().empty()) in ParseExternalDeclaration()
925 ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseExternalDeclaration()
926 "top-level asm block"); in ParseExternalDeclaration()
947 // Code-complete Objective-C methods even without leading '-'/'+' prefix. in ParseExternalDeclaration()
1004 // Parse (then ignore) 'static' prior to a template instantiation. This is in ParseExternalDeclaration()
1059 SkipUntil(tok::semi); in ParseExternalDeclaration()
1072 // We can't tell whether this is a function-definition or declaration yet. in ParseExternalDeclaration()
1092 return Tok.is(tok::equal) || // int X()= -> not a function def in isDeclarationAfterDeclarator()
1093 Tok.is(tok::comma) || // int X(), -> not a function def in isDeclarationAfterDeclarator()
1094 Tok.is(tok::semi) || // int X(); -> not a function def in isDeclarationAfterDeclarator()
1095 Tok.is(tok::kw_asm) || // int X() __asm__ -> not a function def in isDeclarationAfterDeclarator()
1096 Tok.is(tok::kw___attribute) || // int X() __attr__ -> not a function def in isDeclarationAfterDeclarator()
1098 Tok.is(tok::l_paren)); // int X(0) -> not a function def [C++] in isDeclarationAfterDeclarator()
1122 /// Parse either a function-definition or a declaration. We can't tell which
1123 /// we have until we read up to the compound-statement in function-definition.
1124 /// TemplateParams, if non-NULL, provides the template parameters when we're
1125 /// parsing a C++ template-declaration.
1127 /// function-definition: [C99 6.9.1]
1128 /// decl-specs declarator declaration-list[opt] compound-statement
1129 /// [C90] function-definition: [C99 6.7.1] - implicit int result
1130 /// [C90] decl-specs[opt] declarator declaration-list[opt] compound-statement
1133 /// declaration-specifiers init-declarator-list[opt] ';'
1134 /// [!C99] init-declarator-list ';' [TODO: warn in c99 mode]
1135 /// [OMP] threadprivate-directive
1136 /// [OMP] allocate-directive [TODO]
1152 // Parse the common declaration-specifiers piece. in ParseDeclOrFunctionDefInternal()
1156 // If we had a free-standing type definition with a missing semicolon, we in ParseDeclOrFunctionDefInternal()
1162 // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };" in ParseDeclOrFunctionDefInternal()
1163 // declaration-specifiers init-declarator-list[opt] ';' in ParseDeclOrFunctionDefInternal()
1164 if (Tok.is(tok::semi)) { in ParseDeclOrFunctionDefInternal()
1215 SkipUntil(tok::semi); in ParseDeclOrFunctionDefInternal()
1266 // Must temporarily exit the objective-c container scope for in ParseDeclarationOrFunctionDefinition()
1267 // parsing c constructs and re-enter objc container scope in ParseDeclarationOrFunctionDefinition()
1275 /// ParseFunctionDefinition - We parsed and verified that the specified
1276 /// Declarator is well formed. If this is a K&R-style function, read the
1277 /// parameters declaration-list, then start the compound-statement.
1279 /// function-definition: [C99 6.9.1]
1280 /// decl-specs declarator declaration-list[opt] compound-statement
1281 /// [C90] function-definition: [C99 6.7.1] - implicit int result
1282 /// [C90] decl-specs[opt] declarator declaration-list[opt] compound-statement
1283 /// [C++] function-definition: [C++ 8.4]
1284 /// decl-specifier-seq[opt] declarator ctor-initializer[opt]
1285 /// function-body
1286 /// [C++] function-definition: [C++ 8.4]
1287 /// decl-specifier-seq[opt] declarator function-try-block
1303 // declaration-specifiers are completely optional in the grammar. in ParseFunctionDefinition()
1317 // If this declaration was formed with a K&R-style identifier list for the in ParseFunctionDefinition()
1356 Scope *ParentScope = getCurScope()->getParent(); in ParseFunctionDefinition()
1374 FunctionDecl *FnD = DP->getAsFunction(); in ParseFunctionDefinition()
1384 Actions.CurContext->isTranslationUnit()) { in ParseFunctionDefinition()
1387 Scope *ParentScope = getCurScope()->getParent(); in ParseFunctionDefinition()
1397 CurParsedObjCImpl->HasCFunction = true; in ParseFunctionDefinition()
1435 SkipUntil(tok::semi); in ParseFunctionDefinition()
1436 } else if (ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseFunctionDefinition()
1440 SkipUntil(tok::semi); in ParseFunctionDefinition()
1483 Stmt *GeneratedBody = Res ? Res->getBody() : nullptr; in ParseFunctionDefinition()
1488 // With abbreviated function templates - we need to explicitly add depth to in ParseFunctionDefinition()
1491 Template && Template->isAbbreviated() && in ParseFunctionDefinition()
1492 Template->getTemplateParameters()->getParam(0)->isImplicit()) in ParseFunctionDefinition()
1493 // First template parameter is implicit - meaning no explicit template in ParseFunctionDefinition()
1508 // ctor-initializer. in ParseFunctionDefinition()
1530 SkipUntil(tok::semi); in SkipFunctionBody()
1550 /// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides
1551 /// types for a function with a K&R-style identifier list for arguments.
1553 // We know that the top-level of this declarator is a function. in ParseKNRParamDeclarations()
1556 // Enter function-declaration scope, limiting any declarators to the in ParseKNRParamDeclarations()
1565 // Parse the common declaration-specifiers piece. in ParseKNRParamDeclarations()
1572 // NOTE: GCC just makes this an ext-warn. It's not clear what it does with in ParseKNRParamDeclarations()
1575 if (TryConsumeToken(tok::semi)) { in ParseKNRParamDeclarations()
1580 // C99 6.9.1p6: Declarations shall contain no storage-class specifiers other in ParseKNRParamDeclarations()
1655 // Otherwise recover by skipping to next semi or mandatory function body. in ParseKNRParamDeclarations()
1658 TryConsumeToken(tok::semi); in ParseKNRParamDeclarations()
1666 /// ParseAsmStringLiteral - This is just a normal string-literal, but is not
1672 /// [GNU] asm-string-literal:
1673 /// string-literal
1685 if (!SL->isOrdinary()) { in ParseAsmStringLiteral()
1687 << SL->isWide() in ParseAsmStringLiteral()
1688 << SL->getSourceRange(); in ParseAsmStringLiteral()
1691 if (ForAsmLabel && SL->getString().empty()) { in ParseAsmStringLiteral()
1693 << 2 /* an empty */ << SL->getSourceRange(); in ParseAsmStringLiteral()
1702 /// [GNU] simple-asm-expr:
1703 /// 'asm' '(' asm-string-literal ')'
1745 assert(tok.is(tok::annot_template_id) && "Expected template-id token"); in takeTemplateIdAnnotation()
1771 /// with a typo-corrected keyword. This is only appropriate when the current
1774 /// \param CCC Indicates how to perform typo-correction for this name. If NULL,
1777 /// nested-name-specifier without typename is treated as a type (e.g.
1805 // typo-correct to tentatively-declared identifiers. in TryAnnotateName()
1817 // Look up and classify the identifier. We don't perform any typo-correction in TryAnnotateName()
1825 // double-check before committing to that interpretation. C++20 requires that in TryAnnotateName()
1826 // we interpret this as a template-id if it can be, but if it can't be, then in TryAnnotateName()
1830 // It's not a template-id; re-classify without the '<' as a hint. in TryAnnotateName()
1843 // The identifier was typo-corrected to a keyword. in TryAnnotateName()
1845 Tok.setKind(Name->getTokenID()); in TryAnnotateName()
1866 /// An Objective-C object type followed by '<' is a specialization of in TryAnnotateName()
1867 /// a parameterized class type or a protocol-qualified type. in TryAnnotateName()
1870 (Ty.get()->isObjCObjectType() || in TryAnnotateName()
1871 Ty.get()->isObjCObjectPointerType())) { in TryAnnotateName()
1904 // vector has been found as a non-type id when altivec is enabled but in TryAnnotateName()
1973 Tok.getIdentifierInfo()->revertTokenIDToIdentifier(); in TryKeywordIdentFallback()
1978 /// TryAnnotateTypeOrScopeToken - If the current token position is on a
1984 /// backtracking without the need to re-parse and resolve nested-names and
2027 // Parse a C++ typename-specifier, e.g., "typename T::type". in TryAnnotateTypeOrScopeToken()
2029 // typename-specifier: in TryAnnotateTypeOrScopeToken()
2030 // 'typename' '::' [opt] nested-name-specifier identifier in TryAnnotateTypeOrScopeToken()
2031 // 'typename' '::' [opt] nested-name-specifier template [opt] in TryAnnotateTypeOrScopeToken()
2032 // simple-template-id in TryAnnotateTypeOrScopeToken()
2081 if (!TemplateId->mightBeType()) { in TryAnnotateTypeOrScopeToken()
2087 ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(), in TryAnnotateTypeOrScopeToken()
2088 TemplateId->NumArgs); in TryAnnotateTypeOrScopeToken()
2090 Ty = TemplateId->isInvalid() in TryAnnotateTypeOrScopeToken()
2093 getCurScope(), TypenameLoc, SS, TemplateId->TemplateKWLoc, in TryAnnotateTypeOrScopeToken()
2094 TemplateId->Template, TemplateId->Name, in TryAnnotateTypeOrScopeToken()
2095 TemplateId->TemplateNameLoc, TemplateId->LAngleLoc, in TryAnnotateTypeOrScopeToken()
2096 TemplateArgsPtr, TemplateId->RAngleLoc); in TryAnnotateTypeOrScopeToken()
2144 /// An Objective-C object type followed by '<' is a specialization of in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2145 /// a parameterized class type or a protocol-qualified type. in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2147 (Ty.get()->isObjCObjectType() || in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2148 Ty.get()->isObjCObjectPointerType())) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2162 // This is a typename. Replace the current token in-place with an in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2182 // If this is a template-id, annotate with a template-id or type token. in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2183 // FIXME: This appears to be dead code. We already have formed template-id in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2195 // Only annotate an undeclared template name as a template-id if the in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2213 // template-id, is not part of the annotation. Fall through to in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2220 if (TemplateId->Kind == TNK_Type_template) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2221 // A template-id that refers to a type was parsed into a in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2222 // template-id annotation in a context where we weren't allowed in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2223 // to produce a type annotation token. Update the template-id in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2238 /// TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only
2239 /// annotates C++ scope specifiers and template-ids. This returns
2269 case tok::minusequal: // -= in isTokenEqualOrEqualTypo()
2293 for (Scope *S = getCurScope(); S; S = S->getParent()) { in handleUnexpectedCodeCompletionToken()
2294 if (S->isFunctionScope()) { in handleUnexpectedCodeCompletionToken()
2301 if (S->isClassScope()) { in handleUnexpectedCodeCompletionToken()
2315 // Code-completion pass-through functions
2362 // Parse nested-name-specifier. in ParseMicrosoftIfExistsCondition()
2368 // Check nested-name specifier. in ParseMicrosoftIfExistsCondition()
2374 // Parse the unqualified-id. in ParseMicrosoftIfExistsCondition()
2443 if (Result && !getCurScope()->getParent()) in ParseMicrosoftIfExistsExternalDeclaration()
2450 /// context-sensitive keyword (optionally preceded by 'export').
2452 /// module-declaration: [C++20]
2453 /// 'export'[opt] 'module' module-name attribute-specifier-seq[opt] ';'
2455 /// global-module-fragment: [C++2a]
2456 /// 'module' ';' top-level-declaration-seq[opt]
2457 /// module-declaration: [C++2a]
2458 /// 'export'[opt] 'module' module-name module-partition[opt]
2459 /// attribute-specifier-seq[opt] ';'
2460 /// private-module-fragment: [C++2a]
2461 /// 'module' ':' 'private' ';' top-level-declaration-seq[opt]
2480 // Parse a global-module-fragment, if present. in ParseModuleDecl()
2481 if (getLangOpts().CPlusPlusModules && Tok.is(tok::semi)) { in ParseModuleDecl()
2496 // Parse a private-module-fragment, if present. in ParseModuleDecl()
2517 // Parse the optional module-partition. in ParseModuleDecl()
2544 /// Objective-C and C++20 except for the leading '@' (in ObjC) and the
2548 /// '@' 'import' module-name ';'
2549 /// [ModTS] module-import-declaration:
2550 /// 'import' module-name attribute-specifier-seq[opt] ';'
2551 /// [C++20] module-import-declaration:
2552 /// 'export'[opt] 'import' module-name
2553 /// attribute-specifier-seq[opt] ';'
2554 /// 'export'[opt] 'import' module-partition
2555 /// attribute-specifier-seq[opt] ';'
2556 /// 'export'[opt] 'import' header-name
2557 /// attribute-specifier-seq[opt] ';'
2613 // Diagnose mis-imports. in ParseModuleImport()
2633 // We can only have pre-processor directives in the global module fragment in ParseModuleImport()
2634 // which allows pp-import, but not of a partition (since the global module in ParseModuleImport()
2637 // [module.private.frag]/1 disallows private module fragments in a multi- in ParseModuleImport()
2639 if (IsPartition || (HeaderUnit && HeaderUnit->Kind != in ParseModuleImport()
2676 if (FE && llvm::sys::path::parent_path(FE->getDir().getName()) in ParseModuleImport()
2684 /// Parse a C++ / Objective-C module name (both forms use the same
2687 /// module-name:
2688 /// module-name-qualifier[opt] identifier
2689 /// module-name-qualifier:
2690 /// module-name-qualifier[opt] identifier '.'
2705 SkipUntil(tok::semi); in ParseModuleName()
2732 --MisplacedModuleBeginCount; in parseMisplacedModuleImport()