diff options
Diffstat (limited to 'clang/lib/Parse')
-rw-r--r-- | clang/lib/Parse/ParseAST.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Parse/ParseCXXInlineMethods.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 32 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 64 | ||||
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 128 | ||||
-rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 190 | ||||
-rw-r--r-- | clang/lib/Parse/ParseInit.cpp | 50 | ||||
-rw-r--r-- | clang/lib/Parse/ParseObjc.cpp | 224 | ||||
-rw-r--r-- | clang/lib/Parse/ParsePragma.cpp | 30 | ||||
-rw-r--r-- | clang/lib/Parse/ParseStmtAsm.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Parse/ParseTemplate.cpp | 74 | ||||
-rw-r--r-- | clang/lib/Parse/ParseTentative.cpp | 38 | ||||
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 68 |
13 files changed, 456 insertions, 456 deletions
diff --git a/clang/lib/Parse/ParseAST.cpp b/clang/lib/Parse/ParseAST.cpp index 696506099e5..e71b5a9d1e6 100644 --- a/clang/lib/Parse/ParseAST.cpp +++ b/clang/lib/Parse/ParseAST.cpp @@ -107,7 +107,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, // Recover resources if we crash before exiting this method. llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(S.get()); - + ParseAST(*S.get(), PrintStats, SkipFunctionBodies); } @@ -166,7 +166,7 @@ void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) { // Process any TopLevelDecls generated by #pragma weak. for (Decl *D : S.WeakTopLevelDecls()) Consumer->HandleTopLevelDecl(DeclGroupRef(D)); - + Consumer->HandleTranslationUnit(S.getASTContext()); // Finalize the template instantiation observer chain. diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp index 27d48be0e3e..5898120cab4 100644 --- a/clang/lib/Parse/ParseCXXInlineMethods.cpp +++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp @@ -590,9 +590,9 @@ void Parser::ParseLexedMemberInitializers(ParsingClass &Class) { if (!Class.LateParsedDeclarations.empty()) { // C++11 [expr.prim.general]p4: - // Otherwise, if a member-declarator declares a non-static data member + // Otherwise, if a member-declarator declares a non-static data member // (9.2) of a class X, the expression this is a prvalue of type "pointer - // to X" within the optional brace-or-equal-initializer. It shall not + // to X" within the optional brace-or-equal-initializer. It shall not // appear elsewhere in the member-declarator. Sema::CXXThisScopeRAII ThisScope(Actions, Class.TagOrTemplate, /*TypeQuals=*/(unsigned)0); @@ -601,7 +601,7 @@ void Parser::ParseLexedMemberInitializers(ParsingClass &Class) { Class.LateParsedDeclarations[i]->ParseLexedMemberInitializers(); } } - + if (!AlreadyHasClassScope) Actions.ActOnFinishDelayedMemberDeclarations(getCurScope(), Class.TagOrTemplate); @@ -627,7 +627,7 @@ void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) { Actions.ActOnStartCXXInClassMemberInitializer(); - ExprResult Init = ParseCXXMemberInitializer(MI.Field, /*IsFunction=*/false, + ExprResult Init = ParseCXXMemberInitializer(MI.Field, /*IsFunction=*/false, EqualLoc); Actions.ActOnFinishCXXInClassMemberInitializer(MI.Field, EqualLoc, diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 4f6bb08bdc6..6e57c7bbba9 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -757,7 +757,7 @@ void Parser::ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs) { if (!getLangOpts().ObjC1) Diag(AttrNameLoc, diag::ext_nullability) << AttrName; - attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, + attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, ParsedAttr::AS_Keyword); break; } @@ -867,7 +867,7 @@ VersionTuple Parser::ParseVersionTuple(SourceRange &Range) { StopAtSemi | StopBeforeMatch | StopAtCodeCompletion); return VersionTuple(); } - + // Warn if separators, be it '.' or '_', do not match. if (AfterMajorSeparator != AfterMinorSeparator) Diag(Tok, diag::warn_expected_consistent_version_separator); @@ -1047,7 +1047,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability, continue; } } - + SourceRange VersionRange; VersionTuple Version = ParseVersionTuple(VersionRange); @@ -1259,7 +1259,7 @@ void Parser::ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated, Diag(Tok, diag::err_expected) << tok::l_paren; return; } - + // Parse the related class name. if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_objcbridge_related_expected_related_class); @@ -1292,7 +1292,7 @@ void Parser::ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated, SkipUntil(tok::r_paren, StopAtSemi); return; } - + // Parse instance method name. Also non-optional but empty string is // permitted. IdentifierLoc *InstanceMethod = nullptr; @@ -1303,14 +1303,14 @@ void Parser::ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated, SkipUntil(tok::r_paren, StopAtSemi); return; } - + // Closing ')'. if (T.consumeClose()) return; - + if (endLoc) *endLoc = T.getCloseLocation(); - + // Record this attribute attrs.addNew(&ObjCBridgeRelated, SourceRange(ObjCBridgeRelatedLoc, T.getCloseLocation()), @@ -2032,7 +2032,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, DeclsInGroup.push_back(FirstDecl); bool ExpectSemi = Context != DeclaratorContext::ForContext; - + // If we don't have a comma, it is either the end of the list (a ';') or an // error, bail out. SourceLocation CommaLoc; @@ -3815,7 +3815,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, PrevSpec, DiagID, Type.get(), Actions.getASTContext().getPrintingPolicy())) Diag(StartLoc, DiagID) << PrevSpec; - + DS.SetRangeEnd(EndLoc); } else { DS.SetTypeSpecError(); @@ -5627,7 +5627,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { } else { AllowConstructorName = (D.getContext() == DeclaratorContext::MemberContext); - AllowDeductionGuide = + AllowDeductionGuide = (D.getContext() == DeclaratorContext::FileContext || D.getContext() == DeclaratorContext::MemberContext); } @@ -6082,13 +6082,13 @@ void Parser::ParseFunctionDeclarator(Declarator &D, LocalEndLoc = RParenLoc; EndLoc = RParenLoc; - // If there are attributes following the identifier list, parse them and + // If there are attributes following the identifier list, parse them and // prohibit them. MaybeParseCXX11Attributes(FnAttrs); ProhibitAttributes(FnAttrs); } else { if (Tok.isNot(tok::r_paren)) - ParseParameterDeclarationClause(D, FirstArgAttrs, ParamInfo, + ParseParameterDeclarationClause(D, FirstArgAttrs, ParamInfo, EllipsisLoc); else if (RequiresArg) Diag(Tok, diag::err_argument_required_after_attribute); @@ -6391,8 +6391,8 @@ void Parser::ParseParameterDeclarationClause( ParseDeclarationSpecifiers(DS); - // Parse the declarator. This is "PrototypeContext" or - // "LambdaExprParameterContext", because we must accept either + // Parse the declarator. This is "PrototypeContext" or + // "LambdaExprParameterContext", because we must accept either // 'declarator' or 'abstract-declarator' here. Declarator ParmDeclarator( DS, D.getContext() == DeclaratorContext::LambdaExprContext @@ -6484,7 +6484,7 @@ void Parser::ParseParameterDeclarationClause( } ParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII, - ParmDeclarator.getIdentifierLoc(), + ParmDeclarator.getIdentifierLoc(), Param, std::move(DefArgToks))); } diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 7c4c83d032b..9ba44d07aba 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -61,7 +61,7 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(DeclaratorContext Context, assert(Tok.is(tok::kw_namespace) && "Not a namespace!"); SourceLocation NamespaceLoc = ConsumeToken(); // eat the 'namespace'. ObjCDeclContextSwitch ObjCDC(*this); - + if (Tok.is(tok::code_completion)) { Actions.CodeCompleteNamespaceDecl(getCurScope()); cutOffParsing(); @@ -130,8 +130,8 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(DeclaratorContext Context, return nullptr; } - if (getCurScope()->isClassScope() || getCurScope()->isTemplateParamScope() || - getCurScope()->isInObjcMethodScope() || getCurScope()->getBlockParent() || + if (getCurScope()->isClassScope() || getCurScope()->isTemplateParamScope() || + getCurScope()->isInObjcMethodScope() || getCurScope()->getBlockParent() || getCurScope()->getFnParent()) { Diag(T.getOpenLocation(), diag::err_namespace_nonnamespace_scope); SkipUntil(tok::r_brace); @@ -190,7 +190,7 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(DeclaratorContext Context, PrettyDeclStackTraceEntry CrashInfo(Actions.Context, NamespcDecl, NamespaceLoc, "parsing namespace"); - // Parse the contents of the namespace. This includes parsing recovery on + // Parse the contents of the namespace. This includes parsing recovery on // any improperly nested namespaces. ParseInnerNamespace(ExtraIdentLoc, ExtraIdent, ExtraNamespaceLoc, 0, InlineLoc, attrs, T); @@ -200,8 +200,8 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(DeclaratorContext Context, DeclEnd = T.getCloseLocation(); Actions.ActOnFinishNamespaceDef(NamespcDecl, DeclEnd); - - return Actions.ConvertDeclToDeclGroup(NamespcDecl, + + return Actions.ConvertDeclToDeclGroup(NamespcDecl, ImplicitUsingDirectiveDecl); } @@ -236,7 +236,7 @@ void Parser::ParseInnerNamespace(std::vector<SourceLocation> &IdentLoc, getCurScope(), SourceLocation(), NamespaceLoc[index], IdentLoc[index], Ident[index], Tracker.getOpenLocation(), attrs, ImplicitUsingDirectiveDecl); - assert(!ImplicitUsingDirectiveDecl && + assert(!ImplicitUsingDirectiveDecl && "nested namespace definition cannot define anonymous namespace"); ParseInnerNamespace(IdentLoc, Ident, NamespaceLoc, ++index, InlineLoc, @@ -438,7 +438,7 @@ Parser::ParseUsingDirectiveOrDeclaration(DeclaratorContext Context, ParsedAttributesWithRange &attrs) { assert(Tok.is(tok::kw_using) && "Not using token"); ObjCDeclContextSwitch ObjCDC(*this); - + // Eat 'using'. SourceLocation UsingLoc = ConsumeToken(); @@ -896,7 +896,7 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){ SourceLocation Parser::ParseDecltypeSpecifier(DeclSpec &DS) { assert(Tok.isOneOf(tok::kw_decltype, tok::annot_decltype) && "Not a decltype specifier"); - + ExprResult Result; SourceLocation StartLoc = Tok.getLocation(); SourceLocation EndLoc; @@ -999,7 +999,7 @@ SourceLocation Parser::ParseDecltypeSpecifier(DeclSpec &DS) { return EndLoc; } -void Parser::AnnotateExistingDecltypeSpecifier(const DeclSpec& DS, +void Parser::AnnotateExistingDecltypeSpecifier(const DeclSpec& DS, SourceLocation StartLoc, SourceLocation EndLoc) { // make sure we have a token we can turn into an annotation token @@ -1050,9 +1050,9 @@ void Parser::ParseUnderlyingTypeSpecifier(DeclSpec &DS) { } /// ParseBaseTypeSpecifier - Parse a C++ base-type-specifier which is either a -/// class name or decltype-specifier. Note that we only check that the result -/// names a type; semantic analysis will need to verify that the type names a -/// class. The result is either a type or null, depending on whether a type +/// class name or decltype-specifier. Note that we only check that the result +/// names a type; semantic analysis will need to verify that the type names a +/// class. The result is either a type or null, depending on whether a type /// name was found. /// /// base-type-specifier: [C++11 class.derived] @@ -1083,7 +1083,7 @@ TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc, BaseLoc = Tok.getLocation(); // Parse decltype-specifier - // tok == kw_decltype is just error recovery, it can only happen when SS + // tok == kw_decltype is just error recovery, it can only happen when SS // isn't empty if (Tok.isOneOf(tok::kw_decltype, tok::annot_decltype)) { if (SS.isNotEmpty()) @@ -1348,8 +1348,8 @@ bool Parser::isValidAfterTypeSpecifier(bool CouldBeBitfield) { void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, SourceLocation StartLoc, DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo, - AccessSpecifier AS, - bool EnteringContext, DeclSpecContext DSC, + AccessSpecifier AS, + bool EnteringContext, DeclSpecContext DSC, ParsedAttributesWithRange &Attributes) { DeclSpec::TST TagType; if (TagTokKind == tok::kw_struct) @@ -2061,7 +2061,7 @@ BaseResult Parser::ParseBaseSpecifier(Decl *ClassDecl) { if (BaseType.isInvalid()) return true; - // Parse the optional ellipsis (for a pack expansion). The ellipsis is + // Parse the optional ellipsis (for a pack expansion). The ellipsis is // actually part of the base-specifier-list grammar productions, but we // parse it here for convenience. SourceLocation EllipsisLoc; @@ -2229,7 +2229,7 @@ void Parser::ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS, bool Parser::isCXX11FinalKeyword() const { VirtSpecifiers::Specifier Specifier = isCXX11VirtSpecifier(); return Specifier == VirtSpecifiers::VS_Final || - Specifier == VirtSpecifiers::VS_GNU_Final || + Specifier == VirtSpecifiers::VS_GNU_Final || Specifier == VirtSpecifiers::VS_Sealed; } @@ -2397,7 +2397,7 @@ void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq( /// override /// final /// [MS] sealed -/// +/// /// pure-specifier: /// '= 0' /// @@ -2648,9 +2648,9 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, } DeclaratorInfo.setFunctionDefinitionKind(DefinitionKind); - // C++11 [dcl.attr.grammar] p4: If an attribute-specifier-seq appertains + // C++11 [dcl.attr.grammar] p4: If an attribute-specifier-seq appertains // to a friend declaration, that declaration shall be a definition. - if (DeclaratorInfo.isFunctionDeclarator() && + if (DeclaratorInfo.isFunctionDeclarator() && DefinitionKind != FDK_Definition && DS.isFriendSpecified()) { // Diagnose attributes that appear before decl specifier: // [[]] friend int foo(); @@ -3142,7 +3142,7 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, if (getLangOpts().CPlusPlus && Tok.is(tok::identifier)) { VirtSpecifiers::Specifier Specifier = isCXX11VirtSpecifier(Tok); assert((Specifier == VirtSpecifiers::VS_Final || - Specifier == VirtSpecifiers::VS_GNU_Final || + Specifier == VirtSpecifiers::VS_GNU_Final || Specifier == VirtSpecifiers::VS_Sealed) && "not a class definition"); FinalLoc = ConsumeToken(); @@ -3457,7 +3457,7 @@ MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) { TryConsumeToken(tok::ellipsis, EllipsisLoc); return Actions.ActOnMemInitializer(ConstructorDecl, getCurScope(), SS, II, - TemplateTypeTy, DS, IdLoc, + TemplateTypeTy, DS, IdLoc, InitList.get(), EllipsisLoc); } else if(Tok.is(tok::l_paren)) { BalancedDelimiterTracker T(*this, tok::l_paren); @@ -3506,7 +3506,7 @@ Parser::tryParseExceptionSpecification(bool Delayed, CachedTokens *&ExceptionSpecTokens) { ExceptionSpecificationType Result = EST_None; ExceptionSpecTokens = nullptr; - + // Handle delayed parsing of exception-specifications. if (Delayed) { if (Tok.isNot(tok::kw_throw) && Tok.isNot(tok::kw_noexcept)) @@ -3525,11 +3525,11 @@ Parser::tryParseExceptionSpecification(bool Delayed, NoexceptExpr = nullptr; return EST_BasicNoexcept; } - + Diag(Tok, diag::err_expected_lparen_after) << "throw"; return EST_DynamicNone; } - + // Cache the tokens for the exception-specification. ExceptionSpecTokens = new CachedTokens; ExceptionSpecTokens->push_back(StartTok); // 'throw' or 'noexcept' @@ -3543,7 +3543,7 @@ Parser::tryParseExceptionSpecification(bool Delayed, return EST_Unparsed; } - + // See if there's a dynamic specification. if (Tok.is(tok::kw_throw)) { Result = ParseDynamicExceptionSpecification(SpecificationRange, @@ -3660,7 +3660,7 @@ ExceptionSpecificationType Parser::ParseDynamicExceptionSpecification( if (Tok.is(tok::ellipsis)) { // C++0x [temp.variadic]p5: - // - In a dynamic-exception-specification (15.4); the pattern is a + // - In a dynamic-exception-specification (15.4); the pattern is a // type-id. SourceLocation Ellipsis = ConsumeToken(); Range.setEnd(Ellipsis); @@ -4207,7 +4207,7 @@ void Parser::ParseMicrosoftIfExistsClassDeclaration( IfExistsCondition Result; if (ParseMicrosoftIfExistsCondition(Result)) return; - + BalancedDelimiterTracker Braces(*this, tok::l_brace); if (Braces.consumeOpen()) { Diag(Tok, diag::err_expected) << tok::l_brace; @@ -4218,13 +4218,13 @@ void Parser::ParseMicrosoftIfExistsClassDeclaration( case IEB_Parse: // Parse the declarations below. break; - + case IEB_Dependent: Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists) << Result.IsIfExists; // Fall through to skip. LLVM_FALLTHROUGH; - + case IEB_Skip: Braces.skipToEnd(); return; @@ -4262,6 +4262,6 @@ void Parser::ParseMicrosoftIfExistsClassDeclaration( // Parse all the comma separated declarators. ParseCXXClassMemberDeclaration(CurAS, AccessAttrs); } - + Braces.consumeClose(); } diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 5a70c9e2953..2a65eec8a0f 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -441,7 +441,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { // is okay, to bind exactly as tightly. For example, compile A=B=C=D as // A=(B=(C=D)), where each paren is a level of recursion here. // The function takes ownership of the RHS. - RHS = ParseRHSOfBinaryExpression(RHS, + RHS = ParseRHSOfBinaryExpression(RHS, static_cast<prec::Level>(ThisPrec + !isRightAssoc)); RHSIsInitList = false; @@ -656,14 +656,14 @@ class CastExpressionIdValidator : public CorrectionCandidateCallback { /// /// id-expression: [C++ 5.1] /// unqualified-id -/// qualified-id +/// qualified-id /// /// unqualified-id: [C++ 5.1] /// identifier /// operator-function-id /// conversion-function-id -/// '~' class-name -/// template-id +/// '~' class-name +/// template-id /// /// new-expression: [C++ 5.3.4] /// '::'[opt] 'new' new-placement[opt] new-type-id @@ -729,7 +729,7 @@ class CastExpressionIdValidator : public CorrectionCandidateCallback { /// '__trivially_copyable' /// /// binary-type-trait: -/// [GNU] '__is_base_of' +/// [GNU] '__is_base_of' /// [MS] '__is_convertible_to' /// '__is_convertible' /// '__is_same' @@ -811,7 +811,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, case tok::kw_false: Res = ParseCXXBoolLiteral(); break; - + case tok::kw___objc_yes: case tok::kw___objc_no: return ParseObjCBoolLiteral(); @@ -835,7 +835,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, return ExprError(); assert(Tok.isNot(tok::kw_decltype) && Tok.isNot(tok::kw___super)); return ParseCastExpression(isUnaryExpression, isAddressOfOperand); - + case tok::identifier: { // primary-expression: identifier // unqualified-id: identifier // constant: enumeration-constant @@ -957,14 +957,14 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, return ExprError(); } // Allow either an identifier or the keyword 'class' (in C++). - if (Tok.isNot(tok::identifier) && + if (Tok.isNot(tok::identifier) && !(getLangOpts().CPlusPlus && Tok.is(tok::kw_class))) { Diag(Tok, diag::err_expected_property_name); return ExprError(); } IdentifierInfo &PropertyName = *Tok.getIdentifierInfo(); SourceLocation PropertyLoc = ConsumeToken(); - + Res = Actions.ActOnClassPropertyRefExpr(II, PropertyName, ILoc, PropertyLoc); break; @@ -973,7 +973,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, // In an Objective-C method, if we have "super" followed by an identifier, // the token sequence is ill-formed. However, if there's a ':' or ']' after // that identifier, this is probably a message send with a missing open - // bracket. Treat it as such. + // bracket. Treat it as such. if (getLangOpts().ObjC1 && &II == Ident_super && !InMessageExpression && getCurScope()->isInObjcMethodScope() && ((Tok.is(tok::identifier) && @@ -983,17 +983,17 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, nullptr); break; } - + // If we have an Objective-C class name followed by an identifier // and either ':' or ']', this is an Objective-C class message // send that's missing the opening '['. Recovery // appropriately. Also take this path if we're performing code // completion after an Objective-C class name. - if (getLangOpts().ObjC1 && - ((Tok.is(tok::identifier) && !InMessageExpression) || + if (getLangOpts().ObjC1 && + ((Tok.is(tok::identifier) && !InMessageExpression) || Tok.is(tok::code_completion))) { const Token& Next = NextToken(); - if (Tok.is(tok::code_completion) || + if (Tok.is(tok::code_completion) || Next.is(tok::colon) || Next.is(tok::r_square)) if (ParsedType Typ = Actions.getTypeName(II, ILoc, getCurScope())) if (Typ.get()->isObjCObjectOrInterfaceType()) { @@ -1005,24 +1005,24 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, unsigned DiagID; DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ, Actions.getASTContext().getPrintingPolicy()); - + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); - TypeResult Ty = Actions.ActOnTypeName(getCurScope(), + TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); if (Ty.isInvalid()) break; - Res = ParseObjCMessageExpressionBody(SourceLocation(), - SourceLocation(), + Res = ParseObjCMessageExpressionBody(SourceLocation(), + SourceLocation(), Ty.get(), nullptr); break; } } - + // Make sure to pass down the right value for isAddressOfOperand. if (isAddressOfOperand && isPostfixExpressionSuffixStart()) isAddressOfOperand = false; - + // Function designators are allowed to be undeclared (C99 6.5.1p2), so we // need to know whether or not this identifier is a function designator or // not. @@ -1179,7 +1179,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, if (getCurScope()->getFnParent() == nullptr) return ExprError(Diag(Tok, diag::err_address_of_label_outside_fn)); - + Diag(AmpAmpLoc, diag::ext_gnu_address_of_label); LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(), Tok.getLocation()); @@ -1384,7 +1384,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, T.consumeClose(); if (!Result.isInvalid()) - Result = Actions.ActOnNoexceptExpr(KeyLoc, T.getOpenLocation(), + Result = Actions.ActOnNoexceptExpr(KeyLoc, T.getOpenLocation(), Result.get(), T.getCloseLocation()); return Result; } @@ -1393,7 +1393,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, case tok::kw_##Spelling: #include "clang/Basic/TokenKinds.def" return ParseTypeTrait(); - + case tok::kw___array_rank: case tok::kw___array_extent: return ParseArrayTypeTrait(); @@ -1401,7 +1401,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, case tok::kw___is_lvalue_expr: case tok::kw___is_rvalue_expr: return ParseExpressionTrait(); - + case tok::at: { SourceLocation AtLoc = ConsumeToken(); return ParseObjCAtExpression(AtLoc); @@ -1489,16 +1489,16 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { case tok::code_completion: if (InMessageExpression) return LHS; - + Actions.CodeCompletePostfixExpression(getCurScope(), LHS); cutOffParsing(); return ExprError(); - + case tok::identifier: // If we see identifier: after an expression, and we're not already in a // message send, then this is probably a message send with a missing // opening bracket '['. - if (getLangOpts().ObjC1 && !InMessageExpression && + if (getLangOpts().ObjC1 && !InMessageExpression && (NextToken().is(tok::colon) || NextToken().is(tok::r_square))) { LHS = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(), nullptr, LHS.get()); @@ -1620,8 +1620,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { if (!LHS.isInvalid()) { ExprResult ECResult = Actions.ActOnCUDAExecConfigExpr(getCurScope(), - OpenLoc, - ExecConfigExprs, + OpenLoc, + ExecConfigExprs, CloseLoc); if (ECResult.isInvalid()) LHS = ExprError(); @@ -1635,7 +1635,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { ExprVector ArgExprs; CommaLocsTy CommaLocs; - + if (Tok.is(tok::code_completion)) { Actions.CodeCompleteCall(getCurScope(), LHS.get(), None); cutOffParsing(); @@ -1675,7 +1675,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { PT.consumeClose(); LHS = ExprError(); } else { - assert((ArgExprs.size() == 0 || + assert((ArgExprs.size() == 0 || ArgExprs.size()-1 == CommaLocs.size())&& "Unexpected number of commas!"); LHS = Actions.ActOnCallExpr(getCurScope(), LHS.get(), Loc, @@ -1716,7 +1716,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { if (LHS.isInvalid()) break; - ParseOptionalCXXScopeSpecifier(SS, ObjectType, + ParseOptionalCXXScopeSpecifier(SS, ObjectType, /*EnteringContext=*/false, &MayBePseudoDestructor); if (SS.isNotEmpty()) @@ -1749,7 +1749,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { } if (MayBePseudoDestructor && !LHS.isInvalid()) { - LHS = ParseCXXPseudoDestructor(LHS.get(), OpLoc, OpKind, SS, + LHS = ParseCXXPseudoDestructor(LHS.get(), OpLoc, OpKind, SS, ObjectType); break; } @@ -1770,24 +1770,24 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { // 'class' as if it were an identifier. // // This hack allows property access to the 'class' method because it is - // such a common method name. For other C++ keywords that are + // such a common method name. For other C++ keywords that are // Objective-C method names, one must use the message send syntax. IdentifierInfo *Id = Tok.getIdentifierInfo(); SourceLocation Loc = ConsumeToken(); Name.setIdentifier(Id, Loc); - } else if (ParseUnqualifiedId(SS, - /*EnteringContext=*/false, + } else if (ParseUnqualifiedId(SS, + /*EnteringContext=*/false, /*AllowDestructorName=*/true, /*AllowConstructorName=*/ - getLangOpts().MicrosoftExt, + getLangOpts().MicrosoftExt, /*AllowDeductionGuide=*/false, ObjectType, &TemplateKWLoc, Name)) { (void)Actions.CorrectDelayedTyposInExpr(LHS); LHS = ExprError(); } - + if (!LHS.isInvalid()) - LHS = Actions.ActOnMemberAccessExpr(getCurScope(), LHS.get(), OpLoc, + LHS = Actions.ActOnMemberAccessExpr(getCurScope(), LHS.get(), OpLoc, OpKind, SS, TemplateKWLoc, Name, CurParsedObjCImpl ? CurParsedObjCImpl->Dcl : nullptr); @@ -1882,7 +1882,7 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok, ParenParseOption ExprType = CastExpr; SourceLocation LParenLoc = Tok.getLocation(), RParenLoc; - Operand = ParseParenExpression(ExprType, true/*stopIfCastExpr*/, + Operand = ParseParenExpression(ExprType, true/*stopIfCastExpr*/, false, CastTy, RParenLoc); CastRange = SourceRange(LParenLoc, RParenLoc); @@ -1896,7 +1896,7 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok, if (getLangOpts().CPlusPlus || OpTok.isNot(tok::kw_typeof)) { // GNU typeof in C requires the expression to be parenthesized. Not so for // sizeof/alignof or in C++. Therefore, the parenthesized expression is - // the start of a unary-expression, but doesn't include any postfix + // the start of a unary-expression, but doesn't include any postfix // pieces. Parse these now if present. if (!Operand.isInvalid()) Operand = ParsePostfixExpressionSuffix(Operand.get()); @@ -1962,7 +1962,7 @@ ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() { } else { Diag(Tok, diag::err_sizeof_parameter_pack); } - + if (!Name) return ExprError(); @@ -1971,7 +1971,7 @@ ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() { Sema::ReuseLambdaContextDecl); return Actions.ActOnSizeofParameterPackExpr(getCurScope(), - OpTok.getLocation(), + OpTok.getLocation(), *Name, NameLoc, RParenLoc); } @@ -2206,15 +2206,15 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() { TypeResult DestTy = ParseTypeName(); if (DestTy.isInvalid()) return ExprError(); - + // Attempt to consume the r-paren. if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_expected) << tok::r_paren; SkipUntil(tok::r_paren, StopAtSemi); return ExprError(); } - - Res = Actions.ActOnAsTypeExpr(Expr.get(), DestTy.get(), StartLoc, + + Res = Actions.ActOnAsTypeExpr(Expr.get(), DestTy.get(), StartLoc, ConsumeParen()); break; } @@ -2235,15 +2235,15 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() { TypeResult DestTy = ParseTypeName(); if (DestTy.isInvalid()) return ExprError(); - + // Attempt to consume the r-paren. if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_expected) << tok::r_paren; SkipUntil(tok::r_paren, StopAtSemi); return ExprError(); } - - Res = Actions.ActOnConvertVectorExpr(Expr.get(), DestTy.get(), StartLoc, + + Res = Actions.ActOnConvertVectorExpr(Expr.get(), DestTy.get(), StartLoc, ConsumeParen()); break; } @@ -2298,7 +2298,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, CastTy = nullptr; if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteOrdinaryName(getCurScope(), + Actions.CodeCompleteOrdinaryName(getCurScope(), ExprType >= CompoundLiteral? Sema::PCC_ParenthesizedExpression : Sema::PCC_Expression); cutOffParsing(); @@ -2322,7 +2322,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, } BridgeCast = false; } - + // None of these cases should fall through with an invalid Result // unless they've already reported an error. if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) { @@ -2376,16 +2376,16 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, << FixItHint::CreateReplacement(BridgeKeywordLoc, "__bridge_retained"); } - + TypeResult Ty = ParseTypeName(); T.consumeClose(); ColonProtection.restore(); RParenLoc = T.getCloseLocation(); ExprResult SubExpr = ParseCastExpression(/*isUnaryExpression=*/false); - + if (Ty.isInvalid() || SubExpr.isInvalid()) return ExprError(); - + return Actions.ActOnObjCBridgedCast(getCurScope(), OpenLoc, Kind, BridgeKeywordLoc, Ty.get(), RParenLoc, SubExpr.get()); @@ -2411,8 +2411,8 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, ParseSpecifierQualifierList(DS); Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); ParseDeclarator(DeclaratorInfo); - - // If our type is followed by an identifier and either ':' or ']', then + + // If our type is followed by an identifier and either ':' or ']', then // this is probably an Objective-C message send where the leading '[' is // missing. Recover as if that were the case. if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) && @@ -2423,10 +2423,10 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, InMessageExpressionRAIIObject InMessage(*this, false); Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); } - Result = ParseObjCMessageExpressionBody(SourceLocation(), - SourceLocation(), + Result = ParseObjCMessageExpressionBody(SourceLocation(), + SourceLocation(), Ty.get(), nullptr); - } else { + } else { // Match the ')'. T.consumeClose(); ColonProtection.restore(); @@ -2503,7 +2503,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, // Reject the cast of super idiom in ObjC. if (Tok.is(tok::identifier) && getLangOpts().ObjC1 && - Tok.getIdentifierInfo() == Ident_super && + Tok.getIdentifierInfo() == Ident_super && getCurScope()->isInObjcMethodScope() && GetLookAheadToken(1).isNot(tok::period)) { Diag(Tok.getLocation(), diag::err_illegal_super_cast) @@ -2518,7 +2518,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, /*isTypeCast=*/IsTypeCast); if (!Result.isInvalid()) { Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc, - DeclaratorInfo, CastTy, + DeclaratorInfo, CastTy, RParenLoc, Result.get()); } return Result; @@ -2722,7 +2722,7 @@ ExprResult Parser::ParseGenericSelectionExpression() { if (T.getCloseLocation().isInvalid()) return ExprError(); - return Actions.ActOnGenericSelectionExpr(KeyLoc, DefaultLoc, + return Actions.ActOnGenericSelectionExpr(KeyLoc, DefaultLoc, T.getCloseLocation(), ControllingExpr.get(), Types, Exprs); @@ -2825,7 +2825,7 @@ bool Parser::ParseExpressionList(SmallVectorImpl<Expr *> &Exprs, Expr = ParseAssignmentExpression(); if (Tok.is(tok::ellipsis)) - Expr = Actions.ActOnPackExpansion(Expr.get(), ConsumeToken()); + Expr = Actions.ActOnPackExpansion(Expr.get(), ConsumeToken()); if (Expr.isInvalid()) { SkipUntil(tok::comma, tok::r_paren, StopBeforeMatch); SawError = true; @@ -2892,7 +2892,7 @@ void Parser::ParseBlockId(SourceLocation CaretLoc) { Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Type); return cutOffParsing(); } - + // Parse the specifier-qualifier-list piece. DeclSpec DS(AttrFactory); ParseSpecifierQualifierList(DS); diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 26e75999518..663c397ee04 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -306,13 +306,13 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, } // If the next token is not '<', we have a qualified-id that refers - // to a template name, such as T::template apply, but is not a + // to a template name, such as T::template apply, but is not a // template-id. if (Tok.isNot(tok::less)) { TPA.Revert(); break; - } - + } + // Commit to parsing the template-id. TPA.Commit(); TemplateTy Template; @@ -366,7 +366,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, TemplateId->RAngleLoc, CCLoc, EnteringContext)) { - SourceLocation StartLoc + SourceLocation StartLoc = SS.getBeginLoc().isValid()? SS.getBeginLoc() : TemplateId->TemplateNameLoc; SS.SetInvalid(SourceRange(StartLoc, CCLoc)); @@ -480,7 +480,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, UnqualifiedId TemplateName; TemplateName.setIdentifier(&II, Tok.getLocation()); bool MemberOfUnknownSpecialization; - if (TemplateNameKind TNK = Actions.isTemplateName(getCurScope(), SS, + if (TemplateNameKind TNK = Actions.isTemplateName(getCurScope(), SS, /*hasTemplateKeyword=*/false, TemplateName, ObjectType, @@ -500,16 +500,16 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, continue; } - if (MemberOfUnknownSpecialization && (ObjectType || SS.isSet()) && + if (MemberOfUnknownSpecialization && (ObjectType || SS.isSet()) && (IsTypename || IsTemplateArgumentList(1))) { - // We have something like t::getAs<T>, where getAs is a + // We have something like t::getAs<T>, where getAs is a // member of an unknown specialization. However, this will only // parse correctly as a template, so suggest the keyword 'template' // before 'getAs' and treat this as a dependent template name. unsigned DiagID = diag::err_missing_dependent_template_keyword; if (getLangOpts().MicrosoftExt) DiagID = diag::warn_missing_dependent_template_keyword; - + Diag(Tok.getLocation(), DiagID) << II.getName() << FixItHint::CreateInsertion(Tok.getLocation(), "template "); @@ -524,9 +524,9 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, return true; } else - return true; - - continue; + return true; + + continue; } } @@ -719,7 +719,7 @@ ExprResult Parser::TryParseLambdaExpression() { if (Next.is(tok::identifier) && After.is(tok::identifier)) { return ExprEmpty(); } - + // Here, we're stuck: lambda introducers and Objective-C message sends are // unambiguous, but it requires arbitrary lookhead. [a,b,c,d,e,f,g] is a // lambda, and [a,b,c,d,e,f,g h] is a Objective-C message send. Instead of @@ -776,7 +776,7 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, if (Tok.is(tok::code_completion) && !(getLangOpts().ObjC1 && Intro.Default == LCD_None && !Intro.Captures.empty())) { - Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, + Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, /*AfterAmpersand=*/false); cutOffParsing(); break; @@ -793,14 +793,14 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, if (getLangOpts().ObjC1 && first) Actions.CodeCompleteObjCMessageReceiver(getCurScope()); else - Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, + Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, /*AfterAmpersand=*/false); cutOffParsing(); break; } first = false; - + // Parse capture. LambdaCaptureKind Kind = LCK_ByCopy; LambdaCaptureInitKind InitKind = LambdaCaptureInitKind::NoInit; @@ -811,10 +811,10 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, SourceLocation LocStart = Tok.getLocation(); if (Tok.is(tok::star)) { - Loc = ConsumeToken(); + Loc = ConsumeToken(); if (Tok.is(tok::kw_this)) { - ConsumeToken(); - Kind = LCK_StarThis; + ConsumeToken(); + Kind = LCK_StarThis; } else { return DiagResult(diag::err_expected_star_this_capture); } @@ -827,7 +827,7 @@ Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro, ConsumeToken(); if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, + Actions.CodeCompleteLambdaIntroducer(getCurScope(), Intro, /*AfterAmpersand=*/true); cutOffParsing(); break; @@ -1090,7 +1090,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), LambdaBeginLoc, "lambda expression parsing"); - + // FIXME: Call into Actions to add any init-capture declarations to the // scope while parsing the lambda-declarator and compound-statement. @@ -1135,13 +1135,13 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( // Parse parameter-declaration-clause. SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo; SourceLocation EllipsisLoc; - + if (Tok.isNot(tok::r_paren)) { Actions.RecordParsingTemplateParameterDepth(TemplateParameterDepth); ParseParameterDeclarationClause(D, Attr, ParamInfo, EllipsisLoc); - // For a generic lambda, each 'auto' within the parameter declaration + // For a generic lambda, each 'auto' within the parameter declaration // clause creates a template type parameter, so increment the depth. - if (Actions.getCurGenericLambda()) + if (Actions.getCurGenericLambda()) ++CurTemplateDepthTracker; } T.consumeClose(); @@ -1161,7 +1161,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( SourceLocation ConstexprLoc; tryConsumeMutableOrConstexprToken(*this, MutableLoc, ConstexprLoc, DeclEndLoc); - + addConstexprToLambdaDeclSpecifier(*this, ConstexprLoc, DS); // Parse exception-specification[opt]. @@ -1376,7 +1376,7 @@ ExprResult Parser::ParseCXXCasts() { Result = Actions.ActOnCXXNamedCast(OpLoc, Kind, LAngleBracketLoc, DeclaratorInfo, RAngleBracketLoc, - T.getOpenLocation(), Result.get(), + T.getOpenLocation(), Result.get(), T.getCloseLocation()); return Result; @@ -1477,7 +1477,7 @@ ExprResult Parser::ParseCXXUuidof() { return ExprError(); Result = Actions.ActOnCXXUuidof(OpLoc, T.getOpenLocation(), /*isType=*/true, - Ty.get().getAsOpaquePtr(), + Ty.get().getAsOpaquePtr(), T.getCloseLocation()); } else { EnterExpressionEvaluationContext Unevaluated( @@ -1507,13 +1507,13 @@ ExprResult Parser::ParseCXXUuidof() { /// postfix-expression . pseudo-destructor-name /// postfix-expression -> pseudo-destructor-name /// -/// pseudo-destructor-name: -/// ::[opt] nested-name-specifier[opt] type-name :: ~type-name -/// ::[opt] nested-name-specifier template simple-template-id :: -/// ~type-name +/// pseudo-destructor-name: +/// ::[opt] nested-name-specifier[opt] type-name :: ~type-name +/// ::[opt] nested-name-specifier template simple-template-id :: +/// ~type-name /// ::[opt] nested-name-specifier[opt] ~type-name -/// -ExprResult +/// +ExprResult Parser::ParseCXXPseudoDestructor(Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, @@ -1562,13 +1562,13 @@ Parser::ParseCXXPseudoDestructor(Expr *Base, SourceLocation OpLoc, Diag(Tok, diag::err_destructor_tilde_identifier); return ExprError(); } - + // Parse the second type. UnqualifiedId SecondTypeName; IdentifierInfo *Name = Tok.getIdentifierInfo(); SourceLocation NameLoc = ConsumeToken(); SecondTypeName.setIdentifier(Name, NameLoc); - + // If there is a '<', the second type name is a template-id. Parse // it as such. if (Tok.is(tok::less) && @@ -1821,7 +1821,7 @@ Sema::ConditionResult Parser::ParseCXXCondition(StmtResult *InitStmt, MaybeParseGNUAttributes(DeclaratorInfo); // Type-check the declaration itself. - DeclResult Dcl = Actions.ActOnCXXConditionDeclaration(getCurScope(), + DeclResult Dcl = Actions.ActOnCXXConditionDeclaration(getCurScope(), DeclaratorInfo); if (Dcl.isInvalid()) return Sema::ConditionError(); @@ -1909,10 +1909,10 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) { getTypeAnnotation(Tok), Policy); else DS.SetTypeSpecError(); - + DS.SetRangeEnd(Tok.getAnnotationEndLoc()); ConsumeAnnotationToken(); - + DS.Finish(Actions, Policy); return; } @@ -2009,7 +2009,7 @@ bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) { } /// Finish parsing a C++ unqualified-id that is a template-id of -/// some form. +/// some form. /// /// This routine is invoked when a '<' is encountered after an identifier or /// operator-function-id is parsed by \c ParseUnqualifiedId() to determine @@ -2023,10 +2023,10 @@ bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) { /// \param Name for constructor and destructor names, this is the actual /// identifier that may be a template-name. /// -/// \param NameLoc the location of the class-name in a constructor or +/// \param NameLoc the location of the class-name in a constructor or /// destructor. /// -/// \param EnteringContext whether we're entering the scope of the +/// \param EnteringContext whether we're entering the scope of the /// nested-name-specifier. /// /// \param ObjectType if this unqualified-id occurs within a member access @@ -2035,9 +2035,9 @@ bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) { /// \param Id as input, describes the template-name or operator-function-id /// that precedes the '<'. If template arguments were parsed successfully, /// will be updated with the template-id. -/// +/// /// \param AssumeTemplateId When true, this routine will assume that the name -/// refers to a template without performing name lookup to verify. +/// refers to a template without performing name lookup to verify. /// /// \returns true if a parse error occurred, false otherwise. bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, @@ -2070,10 +2070,10 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, TemplateKWLoc.isValid(), Id, ObjectType, EnteringContext, Template, MemberOfUnknownSpecialization); - + if (TNK == TNK_Non_template && MemberOfUnknownSpecialization && ObjectType && IsTemplateArgumentList()) { - // We have something like t->getAs<T>(), where getAs is a + // We have something like t->getAs<T>(), where getAs is a // member of an unknown specialization. However, this will only // parse correctly as a template, so suggest the keyword 'template' // before 'getAs' and treat this as a dependent template name. @@ -2094,22 +2094,22 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, getCurScope(), SS, TemplateKWLoc, Id, ObjectType, EnteringContext, Template, /*AllowInjectedClassName*/ true); if (TNK == TNK_Non_template) - return true; + return true; } } break; - + case UnqualifiedIdKind::IK_ConstructorName: { UnqualifiedId TemplateName; bool MemberOfUnknownSpecialization; TemplateName.setIdentifier(Name, NameLoc); TNK = Actions.isTemplateName(getCurScope(), SS, TemplateKWLoc.isValid(), - TemplateName, ObjectType, + TemplateName, ObjectType, EnteringContext, Template, MemberOfUnknownSpecialization); break; } - + case UnqualifiedIdKind::IK_DestructorName: { UnqualifiedId TemplateName; bool MemberOfUnknownSpecialization; @@ -2122,26 +2122,26 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, return true; } else { TNK = Actions.isTemplateName(getCurScope(), SS, TemplateKWLoc.isValid(), - TemplateName, ObjectType, + TemplateName, ObjectType, EnteringContext, Template, MemberOfUnknownSpecialization); - + if (TNK == TNK_Non_template && !Id.DestructorName.get()) { Diag(NameLoc, diag::err_destructor_template_id) << Name << SS.getRange(); - return true; + return true; } } break; } - + default: return false; } - + if (TNK == TNK_Non_template) return false; - + // Parse the enclosed template argument list. SourceLocation LAngleLoc, RAngleLoc; TemplateArgList TemplateArgs; @@ -2183,12 +2183,12 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, /*IsCtorOrDtorName=*/true); if (Type.isInvalid()) return true; - + if (Id.getKind() == UnqualifiedIdKind::IK_ConstructorName) Id.setConstructorName(Type.get(), NameLoc, RAngleLoc); else Id.setDestructorName(Id.StartLocation, Type.get(), RAngleLoc); - + return false; } @@ -2223,7 +2223,7 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, /// \param SS The nested-name-specifier that preceded this unqualified-id. If /// non-empty, then we are parsing the unqualified-id of a qualified-id. /// -/// \param EnteringContext whether we are entering the scope of the +/// \param EnteringContext whether we are entering the scope of the /// nested-name-specifier. /// /// \param ObjectType if this unqualified-id occurs within a member access @@ -2236,10 +2236,10 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, ParsedType ObjectType, UnqualifiedId &Result) { assert(Tok.is(tok::kw_operator) && "Expected 'operator' keyword"); - + // Consume the 'operator' keyword. SourceLocation KeywordLoc = ConsumeToken(); - + // Determine what kind of operator name we have. unsigned SymbolIdx = 0; SourceLocation SymbolLocations[3]; @@ -2259,7 +2259,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, T.consumeClose(); if (T.getCloseLocation().isInvalid()) return true; - + SymbolLocations[SymbolIdx++] = T.getOpenLocation(); SymbolLocations[SymbolIdx++] = T.getCloseLocation(); Op = isNew? OO_Array_New : OO_Array_Delete; @@ -2268,7 +2268,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, } break; } - + #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ case tok::Token: \ SymbolLocations[SymbolIdx++] = ConsumeToken(); \ @@ -2276,7 +2276,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, break; #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly) #include "clang/Basic/OperatorKinds.def" - + case tok::l_paren: { // Consume the '(' and ')'. BalancedDelimiterTracker T(*this, tok::l_paren); @@ -2284,13 +2284,13 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, T.consumeClose(); if (T.getCloseLocation().isInvalid()) return true; - + SymbolLocations[SymbolIdx++] = T.getOpenLocation(); SymbolLocations[SymbolIdx++] = T.getCloseLocation(); Op = OO_Call; break; } - + case tok::l_square: { // Consume the '[' and ']'. BalancedDelimiterTracker T(*this, tok::l_square); @@ -2298,25 +2298,25 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, T.consumeClose(); if (T.getCloseLocation().isInvalid()) return true; - + SymbolLocations[SymbolIdx++] = T.getOpenLocation(); SymbolLocations[SymbolIdx++] = T.getCloseLocation(); Op = OO_Subscript; break; } - + case tok::code_completion: { // Code completion for the operator name. Actions.CodeCompleteOperatorName(getCurScope()); - cutOffParsing(); + cutOffParsing(); // Don't try to parse any further. return true; } - + default: break; } - + if (Op != OO_None) { // We have parsed an operator-function-id. Result.setOperatorFunctionId(KeywordLoc, Op, SymbolLocations); @@ -2409,12 +2409,12 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, // // conversion-declarator: // ptr-operator conversion-declarator[opt] - + // Parse the type-specifier-seq. DeclSpec DS(AttrFactory); if (ParseCXXTypeSpecifierSeq(DS)) // FIXME: ObjectType? return true; - + // Parse the conversion-declarator, which is merely a sequence of // ptr-operators. Declarator D(DS, DeclaratorContext::ConversionIdContext); @@ -2424,11 +2424,11 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, TypeResult Ty = Actions.ActOnTypeName(getCurScope(), D); if (Ty.isInvalid()) return true; - + // Note that this is a conversion-function-id. - Result.setConversionFunctionId(KeywordLoc, Ty.get(), + Result.setConversionFunctionId(KeywordLoc, Ty.get(), D.getSourceRange().getEnd()); - return false; + return false; } /// Parse a C++ unqualified-id (or a C identifier), which describes the @@ -2448,7 +2448,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, /// \param SS The nested-name-specifier that preceded this unqualified-id. If /// non-empty, then we are parsing the unqualified-id of a qualified-id. /// -/// \param EnteringContext whether we are entering the scope of the +/// \param EnteringContext whether we are entering the scope of the /// nested-name-specifier. /// /// \param AllowDestructorName whether we allow parsing of a destructor name. @@ -2503,7 +2503,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, } ParsedTemplateTy TemplateName; - if (AllowConstructorName && + if (AllowConstructorName && Actions.isCurrentClassName(*Id, getCurScope(), &SS)) { // We have parsed a constructor name. ParsedType Ty = Actions.getConstructorName(*Id, IdLoc, getCurScope(), SS, @@ -2519,7 +2519,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, Result.setDeductionGuideName(TemplateName, IdLoc); } else { // We have parsed an identifier. - Result.setIdentifier(Id, IdLoc); + Result.setIdentifier(Id, IdLoc); } // If the next token is a '<', we may have a template. @@ -2537,13 +2537,13 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, return false; } - + // unqualified-id: // template-id (already parsed and annotated) if (Tok.is(tok::annot_template_id)) { TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok); - // If the template-name names the current class, then this is a constructor + // If the template-name names the current class, then this is a constructor if (AllowConstructorName && TemplateId->Name && Actions.isCurrentClassName(*TemplateId->Name, getCurScope(), &SS)) { if (SS.isSet()) { @@ -2551,7 +2551,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, // is taken as the constructor name where a constructor can be // declared. Thus, the template arguments are extraneous, so // complain about them and remove them entirely. - Diag(TemplateId->TemplateNameLoc, + Diag(TemplateId->TemplateNameLoc, diag::err_out_of_line_constructor_template_id) << TemplateId->Name << FixItHint::CreateRemoval( @@ -2586,17 +2586,17 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, ConsumeAnnotationToken(); return false; } - + // unqualified-id: // operator-function-id // conversion-function-id if (Tok.is(tok::kw_operator)) { if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType, Result)) return true; - + // If we have an operator-function-id or a literal-operator-id and the next // token is a '<', we may have a - // + // // template-id: // operator-function-id < template-argument-list[opt] > TemplateTy Template; @@ -2616,14 +2616,14 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, return false; } - - if (getLangOpts().CPlusPlus && + + if (getLangOpts().CPlusPlus && (AllowDestructorName || SS.isSet()) && Tok.is(tok::tilde)) { // C++ [expr.unary.op]p10: - // There is an ambiguity in the unary-expression ~X(), where X is a - // class-name. The ambiguity is resolved in favor of treating ~ as a + // There is an ambiguity in the unary-expression ~X(), where X is a + // class-name. The ambiguity is resolved in favor of treating ~ as a // unary complement rather than treating ~X as referring to a destructor. - + // Parse the '~'. SourceLocation TildeLoc = ConsumeToken(); @@ -2637,7 +2637,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, } return true; } - + // Parse the class-name. if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_destructor_tilde_identifier); @@ -2688,7 +2688,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, } // Note that this is a destructor name. - ParsedType Ty = Actions.getDestructorName(TildeLoc, *ClassName, + ParsedType Ty = Actions.getDestructorName(TildeLoc, *ClassName, ClassNameLoc, getCurScope(), SS, ObjectType, EnteringContext); @@ -2698,7 +2698,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, Result.setDestructorName(TildeLoc, Ty, ClassNameLoc); return false; } - + Diag(Tok, diag::err_expected_unqualified_id) << getLangOpts().CPlusPlus; return true; @@ -3002,7 +3002,7 @@ static unsigned TypeTraitArity(tok::TokenKind kind) { } } -/// Parse the built-in type-trait pseudo-functions that allow +/// Parse the built-in type-trait pseudo-functions that allow /// implementation of the TR1/C++11 type traits templates. /// /// primary-expression: @@ -3018,7 +3018,7 @@ ExprResult Parser::ParseTypeTrait() { unsigned Arity = TypeTraitArity(Kind); SourceLocation Loc = ConsumeToken(); - + BalancedDelimiterTracker Parens(*this, tok::l_paren); if (Parens.expectAndConsume()) return ExprError(); @@ -3040,7 +3040,7 @@ ExprResult Parser::ParseTypeTrait() { return ExprError(); } } - + // Add this type to the list of arguments. Args.push_back(Ty.get()); } while (TryConsumeToken(tok::comma)); @@ -3266,7 +3266,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, ExprType = SimpleExpr; Result = ParseExpression(); if (!Result.isInvalid() && Tok.is(tok::r_paren)) - Result = Actions.ActOnParenExpr(Tracker.getOpenLocation(), + Result = Actions.ActOnParenExpr(Tracker.getOpenLocation(), Tok.getLocation(), Result.get()); // Match the ')'. diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp index 90f3561cb96..0cd550bc6a4 100644 --- a/clang/lib/Parse/ParseInit.cpp +++ b/clang/lib/Parse/ParseInit.cpp @@ -20,21 +20,21 @@ using namespace clang; -/// MayBeDesignationStart - Return true if the current token might be the start -/// of a designator. If we can tell it is impossible that it is a designator, +/// MayBeDesignationStart - Return true if the current token might be the start +/// of a designator. If we can tell it is impossible that it is a designator, /// return false. bool Parser::MayBeDesignationStart() { switch (Tok.getKind()) { - default: + default: return false; - + case tok::period: // designator: '.' identifier return true; - + case tok::l_square: { // designator: array-designator if (!PP.getLangOpts().CPlusPlus11) return true; - + // C++11 lambda expressions and C99 designators can be ambiguous all the // way through the closing ']' and to the next character. Handle the easy // cases here, and fall back to tentative parsing if those fail. @@ -43,28 +43,28 @@ bool Parser::MayBeDesignationStart() { case tok::r_square: // Definitely starts a lambda expression. return false; - + case tok::amp: case tok::kw_this: case tok::identifier: // We have to do additional analysis, because these could be the // start of a constant expression or a lambda capture list. break; - + default: - // Anything not mentioned above cannot occur following a '[' in a + // Anything not mentioned above cannot occur following a '[' in a // lambda expression. - return true; + return true; } - + // Handle the complicated case below. - break; + break; } case tok::identifier: // designation: identifier ':' return PP.LookAhead(0).is(tok::colon); } - - // Parse up to (at most) the token after the closing ']' to determine + + // Parse up to (at most) the token after the closing ']' to determine // whether this is a C99 designator or a lambda. TentativeParsingAction Tentative(*this); @@ -198,7 +198,7 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator() { // it will be rejected because a constant-expression cannot begin with a // lambda-expression. InMessageExpressionRAIIObject InMessage(*this, true); - + BalancedDelimiterTracker T(*this, tok::l_square); T.consumeOpen(); SourceLocation StartLoc = T.getOpenLocation(); @@ -212,7 +212,7 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator() { if (getLangOpts().ObjC1 && getLangOpts().CPlusPlus) { // Send to 'super'. if (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_super && - NextToken().isNot(tok::period) && + NextToken().isNot(tok::period) && getCurScope()->isInObjcMethodScope()) { CheckArrayDesignatorSyntax(*this, StartLoc, Desig); return ParseAssignmentExprWithObjCMessageExprStart( @@ -226,13 +226,13 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator() { SkipUntil(tok::r_square, StopAtSemi); return ExprError(); } - + // If the receiver was a type, we have a class message; parse // the rest of it. if (!IsExpr) { CheckArrayDesignatorSyntax(*this, StartLoc, Desig); - return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, - SourceLocation(), + return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, + SourceLocation(), ParsedType::getFromOpaquePtr(TypeOrExpr), nullptr); } @@ -281,8 +281,8 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator() { } return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, - SourceLocation(), - ReceiverType, + SourceLocation(), + ReceiverType, nullptr); case Sema::ObjCInstanceMessage: @@ -387,7 +387,7 @@ ExprResult Parser::ParseInitializerWithPotentialDesignator() { /// ExprResult Parser::ParseBraceInitializer() { InMessageExpressionRAIIObject InMessage(*this, false); - + BalancedDelimiterTracker T(*this, tok::l_brace); T.consumeOpen(); SourceLocation LBraceLoc = T.getOpenLocation(); @@ -485,7 +485,7 @@ bool Parser::ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs, IfExistsCondition Result; if (ParseMicrosoftIfExistsCondition(Result)) return false; - + BalancedDelimiterTracker Braces(*this, tok::l_brace); if (Braces.consumeOpen()) { Diag(Tok, diag::err_expected) << tok::l_brace; @@ -496,7 +496,7 @@ bool Parser::ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs, case IEB_Parse: // Parse the declarations below. break; - + case IEB_Dependent: Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists) << Result.IsIfExists; @@ -520,7 +520,7 @@ bool Parser::ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs, if (Tok.is(tok::ellipsis)) SubElt = Actions.ActOnPackExpansion(SubElt.get(), ConsumeToken()); - + // If we couldn't parse the subelement, bail out. if (!SubElt.isInvalid()) InitExprs.push_back(SubElt.get()); diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index 5c5b3cdfcf3..99e5edb9d4a 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -247,7 +247,7 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc, if (Tok.is(tok::l_paren) && !isKnownToBeTypeSpecifier(GetLookAheadToken(1))) { // we have a category. - + BalancedDelimiterTracker T(*this, tok::l_paren); T.consumeOpen(); @@ -258,7 +258,7 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc, cutOffParsing(); return nullptr; } - + // For ObjC2, the category name is optional (not an error). if (Tok.is(tok::identifier)) { categoryId = Tok.getIdentifierInfo(); @@ -269,11 +269,11 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc, << tok::identifier; // missing category name. return nullptr; } - + T.consumeClose(); if (T.getCloseLocation().isInvalid()) return nullptr; - + // Next, we need to check for any protocol references. assert(LAngleLoc.isInvalid() && "Cannot have already parsed protocols"); SmallVector<Decl *, 8> ProtocolRefs; @@ -291,7 +291,7 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc, if (Tok.is(tok::l_brace)) ParseObjCClassInstanceVariables(CategoryType, tok::objc_private, AtLoc); - + ParseObjCInterfaceDeclList(tok::objc_not_keyword, CategoryType); return CategoryType; @@ -592,14 +592,14 @@ ObjCTypeParamList *Parser::parseObjCTypeParamList() { /// @required /// @optional /// -void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey, +void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey, Decl *CDecl) { SmallVector<Decl *, 32> allMethods; SmallVector<DeclGroupPtrTy, 8> allTUVariables; tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword; SourceRange AtEnd; - + while (1) { // If this is a method prototype, parse it. if (Tok.isOneOf(tok::minus, tok::plus)) { @@ -618,8 +618,8 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey, } if (Tok.is(tok::l_paren)) { Diag(Tok, diag::err_expected_minus_or_plus); - ParseObjCMethodDecl(Tok.getLocation(), - tok::minus, + ParseObjCMethodDecl(Tok.getLocation(), + tok::minus, MethodImplKind, false); continue; } @@ -635,12 +635,12 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey, // Code completion within an Objective-C interface. if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteOrdinaryName(getCurScope(), + Actions.CodeCompleteOrdinaryName(getCurScope(), CurParsedObjCImpl? Sema::PCC_ObjCImplementation : Sema::PCC_ObjCInterface); return cutOffParsing(); } - + // If we don't have an @ directive, parse it as a function definition. if (Tok.isNot(tok::at)) { // The code below does not consume '}'s because it is afraid of eating the @@ -685,7 +685,7 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey, // Skip until we see an '@' or '}' or ';'. SkipUntil(tok::r_brace, tok::at, StopAtSemi); break; - + case tok::objc_implementation: case tok::objc_interface: Diag(AtLoc, diag::err_objc_missing_end) @@ -694,7 +694,7 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey, << (int) Actions.getObjCContainerKind(); ConsumeToken(); break; - + case tok::objc_required: case tok::objc_optional: // This is only valid on protocols. @@ -1021,7 +1021,7 @@ IdentifierInfo *Parser::ParseObjCSelectorPiece(SourceLocation &SelectorLoc) { } return nullptr; } - + case tok::identifier: case tok::kw_asm: case tok::kw_auto: @@ -1134,11 +1134,11 @@ void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS, while (1) { if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteObjCPassingType(getCurScope(), DS, + Actions.CodeCompleteObjCPassingType(getCurScope(), DS, Context == DeclaratorContext::ObjCParameterContext); return cutOffParsing(); } - + if (Tok.isNot(tok::identifier)) return; @@ -1160,17 +1160,17 @@ void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS, case objc_bycopy: Qual = ObjCDeclSpec::DQ_Bycopy; break; case objc_byref: Qual = ObjCDeclSpec::DQ_Byref; break; - case objc_nonnull: + case objc_nonnull: Qual = ObjCDeclSpec::DQ_CSNullability; Nullability = NullabilityKind::NonNull; break; - case objc_nullable: + case objc_nullable: Qual = ObjCDeclSpec::DQ_CSNullability; Nullability = NullabilityKind::Nullable; break; - case objc_null_unspecified: + case objc_null_unspecified: Qual = ObjCDeclSpec::DQ_CSNullability; Nullability = NullabilityKind::Unspecified; break; @@ -1222,7 +1222,7 @@ static void takeDeclAttributes(ParsedAttributes &attrs, /// '(' objc-type-qualifiers[opt] type-name ')' /// '(' objc-type-qualifiers[opt] ')' /// -ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, +ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, DeclaratorContext context, ParsedAttributes *paramAttrs) { assert(context == DeclaratorContext::ObjCParameterContext || @@ -1343,7 +1343,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, MaybeParseCXX11Attributes(methodAttrs); if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus, + Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus, ReturnType); cutOffParsing(); return nullptr; @@ -1409,7 +1409,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, // Code completion for the next piece of the selector. if (Tok.is(tok::code_completion)) { KeyIdents.push_back(SelIdent); - Actions.CodeCompleteObjCMethodDeclSelector(getCurScope(), + Actions.CodeCompleteObjCMethodDeclSelector(getCurScope(), mType == tok::minus, /*AtParameterName=*/true, ReturnType, KeyIdents); @@ -1433,14 +1433,14 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, // Code completion for the next piece of the selector. if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteObjCMethodDeclSelector(getCurScope(), + Actions.CodeCompleteObjCMethodDeclSelector(getCurScope(), mType == tok::minus, /*AtParameterName=*/false, ReturnType, KeyIdents); cutOffParsing(); return nullptr; } - + // Check for another keyword selector. SelIdent = ParseObjCSelectorPiece(selLoc); if (!SelIdent && Tok.isNot(tok::colon)) @@ -1478,7 +1478,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, IdentifierInfo *ParmII = ParmDecl.getIdentifier(); Decl *Param = Actions.ActOnParamDeclarator(getCurScope(), ParmDecl); CParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII, - ParmDecl.getIdentifierLoc(), + ParmDecl.getIdentifierLoc(), Param, nullptr)); } @@ -1614,7 +1614,7 @@ void Parser::parseObjCTypeArgsOrProtocolQualifiers( // FIXME: Also include types here. SmallVector<IdentifierLocPair, 4> identifierLocPairs; for (unsigned i = 0, n = identifiers.size(); i != n; ++i) { - identifierLocPairs.push_back(IdentifierLocPair(identifiers[i], + identifierLocPairs.push_back(IdentifierLocPair(identifiers[i], identifierLocs[i])); } @@ -1800,10 +1800,10 @@ void Parser::parseObjCTypeArgsAndProtocolQualifiers( << SourceRange(protocolLAngleLoc, protocolRAngleLoc); SkipUntil(tok::greater, tok::greatergreater, skipFlags); } else { - ParseObjCProtocolReferences(protocols, protocolLocs, + ParseObjCProtocolReferences(protocols, protocolLocs, /*WarnOnDeclarations=*/false, /*ForObjCContainer=*/false, - protocolLAngleLoc, protocolRAngleLoc, + protocolLAngleLoc, protocolRAngleLoc, consumeLastToken); } } @@ -1857,7 +1857,7 @@ void Parser::HelperActionsForIvarDeclarations(Decl *interfaceDecl, SourceLocatio bool RBraceMissing) { if (!RBraceMissing) T.consumeClose(); - + Actions.ActOnObjCContainerStartDefinition(interfaceDecl); Actions.ActOnLastBitfield(T.getCloseLocation(), AllIvarDecls); Actions.ActOnObjCContainerFinishDefinition(); @@ -1893,7 +1893,7 @@ void Parser::ParseObjCClassInstanceVariables(Decl *interfaceDecl, SourceLocation atLoc) { assert(Tok.is(tok::l_brace) && "expected {"); SmallVector<Decl *, 32> AllIvarDecls; - + ParseScope ClassScope(this, Scope::DeclScope|Scope::ClassScope); ObjCDeclContextSwitch ObjCDC(*this); @@ -1915,7 +1915,7 @@ void Parser::ParseObjCClassInstanceVariables(Decl *interfaceDecl, Actions.CodeCompleteObjCAtVisibility(getCurScope()); return cutOffParsing(); } - + switch (Tok.getObjCKeywordID()) { case tok::objc_private: case tok::objc_public: @@ -1934,7 +1934,7 @@ void Parser::ParseObjCClassInstanceVariables(Decl *interfaceDecl, HelperActionsForIvarDeclarations(interfaceDecl, atLoc, T, AllIvarDecls, true); return; - + default: Diag(Tok, diag::err_objc_illegal_visibility_spec); continue; @@ -1942,7 +1942,7 @@ void Parser::ParseObjCClassInstanceVariables(Decl *interfaceDecl, } if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteOrdinaryName(getCurScope(), + Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_ObjCInstanceVariableList); return cutOffParsing(); } @@ -1992,7 +1992,7 @@ void Parser::ParseObjCClassInstanceVariables(Decl *interfaceDecl, /// "\@protocol identifier ;" should be resolved as "\@protocol /// identifier-list ;": objc-interface-decl-list may not start with a /// semicolon in the first alternative if objc-protocol-refs are omitted. -Parser::DeclGroupPtrTy +Parser::DeclGroupPtrTy Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc, ParsedAttributes &attrs) { assert(Tok.isObjCAtKeyword(tok::objc_protocol) && @@ -2125,7 +2125,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) { cutOffParsing(); return nullptr; } - + if (Tok.is(tok::identifier)) { categoryId = Tok.getIdentifierInfo(); categoryLoc = ConsumeToken(); @@ -2145,7 +2145,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) { SourceLocation protocolLAngleLoc, protocolRAngleLoc; SmallVector<Decl *, 4> protocols; SmallVector<SourceLocation, 4> protocolLocs; - (void)ParseObjCProtocolReferences(protocols, protocolLocs, + (void)ParseObjCProtocolReferences(protocols, protocolLocs, /*warnOnIncompleteProtocols=*/false, /*ForObjCContainer=*/false, protocolLAngleLoc, protocolRAngleLoc, @@ -2169,7 +2169,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) { ObjCImpDecl = Actions.ActOnStartClassImplementation( AtLoc, nameId, nameLoc, superClassId, superClassLoc); - + if (Tok.is(tok::l_brace)) // we have ivars ParseObjCClassInstanceVariables(ObjCImpDecl, tok::objc_private, AtLoc); else if (Tok.is(tok::less)) { // we have illegal '<' try to recover @@ -2178,7 +2178,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) { SourceLocation protocolLAngleLoc, protocolRAngleLoc; SmallVector<Decl *, 4> protocols; SmallVector<SourceLocation, 4> protocolLocs; - (void)ParseObjCProtocolReferences(protocols, protocolLocs, + (void)ParseObjCProtocolReferences(protocols, protocolLocs, /*warnOnIncompleteProtocols=*/false, /*ForObjCContainer=*/false, protocolLAngleLoc, protocolRAngleLoc, @@ -2235,16 +2235,16 @@ void Parser::ObjCImplParsingDataRAII::finish(SourceRange AtEnd) { assert(!Finished); P.Actions.DefaultSynthesizeProperties(P.getCurScope(), Dcl, AtEnd.getBegin()); for (size_t i = 0; i < LateParsedObjCMethods.size(); ++i) - P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i], + P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i], true/*Methods*/); P.Actions.ActOnAtEnd(P.getCurScope(), AtEnd); if (HasCFunction) for (size_t i = 0; i < LateParsedObjCMethods.size(); ++i) - P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i], + P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i], false/*c-functions*/); - + /// Clear and free the cached objc methods. for (LateParsedObjCMethodContainer::iterator I = LateParsedObjCMethods.begin(), @@ -2297,7 +2297,7 @@ Decl *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) { cutOffParsing(); return nullptr; } - + if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_synthesized_property_name); SkipUntil(tok::semi); @@ -2380,7 +2380,7 @@ Decl *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) { SkipUntil(tok::semi); return nullptr; } - + IdentifierInfo *propertyId = Tok.getIdentifierInfo(); SourceLocation propertyLoc = ConsumeToken(); // consume property name Actions.ActOnPropertyImplDecl( @@ -2538,14 +2538,14 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { Diag(Tok, diag::err_expected) << tok::l_brace; if (CatchBody.isInvalid()) CatchBody = Actions.ActOnNullStmt(Tok.getLocation()); - + StmtResult Catch = Actions.ActOnObjCAtCatchStmt(AtCatchFinallyLoc, - RParenLoc, - FirstPart, + RParenLoc, + FirstPart, CatchBody.get()); if (!Catch.isInvalid()) CatchStmts.push_back(Catch.get()); - + } else { Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after) << "@catch clause"; @@ -2588,8 +2588,8 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { Diag(atLoc, diag::err_missing_catch_finally); return StmtError(); } - - return Actions.ActOnObjCAtTryStmt(atLoc, TryBody.get(), + + return Actions.ActOnObjCAtTryStmt(atLoc, TryBody.get(), CatchStmts, FinallyStmt.get()); } @@ -2613,11 +2613,11 @@ Parser::ParseObjCAutoreleasePoolStmt(SourceLocation atLoc) { BodyScope.Exit(); if (AutoreleasePoolBody.isInvalid()) AutoreleasePoolBody = Actions.ActOnNullStmt(Tok.getLocation()); - return Actions.ActOnObjCAutoreleasePoolStmt(atLoc, + return Actions.ActOnObjCAutoreleasePoolStmt(atLoc, AutoreleasePoolBody.get()); } -/// StashAwayMethodOrFunctionBodyTokens - Consume the tokens and store them +/// StashAwayMethodOrFunctionBodyTokens - Consume the tokens and store them /// for later parsing. void Parser::StashAwayMethodOrFunctionBodyTokens(Decl *MDecl) { if (SkipFunctionBodies && (!MDecl || Actions.canSkipFunctionBody(MDecl)) && @@ -2698,7 +2698,7 @@ Decl *Parser::ParseObjCMethodDefinition() { // Allow the rest of sema to find private method decl implementations. Actions.AddAnyMethodToGlobalPool(MDecl); - assert (CurParsedObjCImpl + assert (CurParsedObjCImpl && "ParseObjCMethodDefinition - Method out of @implementation"); // Consume the tokens and store them for later parsing. StashAwayMethodOrFunctionBodyTokens(MDecl); @@ -2711,13 +2711,13 @@ StmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc) { cutOffParsing(); return StmtError(); } - + if (Tok.isObjCAtKeyword(tok::objc_try)) return ParseObjCTryStmt(AtLoc); - + if (Tok.isObjCAtKeyword(tok::objc_throw)) return ParseObjCThrowStmt(AtLoc); - + if (Tok.isObjCAtKeyword(tok::objc_synchronized)) return ParseObjCSynchronizedStmt(AtLoc); @@ -2739,7 +2739,7 @@ StmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc) { SkipUntil(tok::semi); return StmtError(); } - + // Otherwise, eat the semicolon. ExpectAndConsumeSemi(diag::err_expected_semi_after_expr); return Actions.ActOnExprStmt(Res); @@ -2789,7 +2789,7 @@ ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { case tok::char_constant: return ParsePostfixExpressionSuffix(ParseObjCCharacterLiteral(AtLoc)); - + case tok::numeric_constant: return ParsePostfixExpressionSuffix(ParseObjCNumericLiteral(AtLoc)); @@ -2799,19 +2799,19 @@ ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { case tok::kw_false: // Objective-C++, etc. case tok::kw___objc_no: // c/c++/objc/objc++ __objc_no return ParsePostfixExpressionSuffix(ParseObjCBooleanLiteral(AtLoc, false)); - + case tok::l_square: // Objective-C array literal return ParsePostfixExpressionSuffix(ParseObjCArrayLiteral(AtLoc)); - + case tok::l_brace: // Objective-C dictionary literal return ParsePostfixExpressionSuffix(ParseObjCDictionaryLiteral(AtLoc)); - + case tok::l_paren: // Objective-C boxed expression return ParsePostfixExpressionSuffix(ParseObjCBoxedExpr(AtLoc)); - + default: if (Tok.getIdentifierInfo() == nullptr) return ExprError(Diag(AtLoc, diag::err_unexpected_at)); @@ -2833,14 +2833,14 @@ ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { if (GetLookAheadToken(1).is(tok::l_brace) && ExprStatementTokLoc == AtLoc) { char ch = Tok.getIdentifierInfo()->getNameStart()[0]; - str = - ch == 't' ? "try" - : (ch == 'f' ? "finally" + str = + ch == 't' ? "try" + : (ch == 'f' ? "finally" : (ch == 'a' ? "autoreleasepool" : nullptr)); } if (str) { SourceLocation kwLoc = Tok.getLocation(); - return ExprError(Diag(AtLoc, diag::err_unexpected_at) << + return ExprError(Diag(AtLoc, diag::err_unexpected_at) << FixItHint::CreateReplacement(kwLoc, str)); } else @@ -2856,7 +2856,7 @@ ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { /// Objective-C++ either as a type or as an expression. Note that this /// routine must not be called to parse a send to 'super', since it /// has no way to return such a result. -/// +/// /// \param IsExpr Whether the receiver was parsed as an expression. /// /// \param TypeOrExpr If the receiver was parsed as an expression (\c @@ -2900,7 +2900,7 @@ bool Parser::ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr) { // expression (that starts with one of the above) DeclSpec DS(AttrFactory); ParseCXXSimpleTypeSpecifier(DS); - + if (Tok.is(tok::l_paren)) { // If we see an opening parentheses at this point, we are // actually parsing an expression that starts with a @@ -2926,7 +2926,7 @@ bool Parser::ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr) { TypeOrExpr = Receiver.get(); return false; } - + // We have a class message. Turn the simple-type-specifier or // typename-specifier we parsed into a type and parse the // remainder of the class message. @@ -2953,26 +2953,26 @@ bool Parser::isSimpleObjCMessageExpression() { } bool Parser::isStartOfObjCClassMessageMissingOpenBracket() { - if (!getLangOpts().ObjC1 || !NextToken().is(tok::identifier) || + if (!getLangOpts().ObjC1 || !NextToken().is(tok::identifier) || InMessageExpression) return false; - + ParsedType Type; - if (Tok.is(tok::annot_typename)) + if (Tok.is(tok::annot_typename)) Type = getTypeAnnotation(Tok); else if (Tok.is(tok::identifier)) - Type = Actions.getTypeName(*Tok.getIdentifierInfo(), Tok.getLocation(), + Type = Actions.getTypeName(*Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope()); else return false; - + if (!Type.get().isNull() && Type.get()->isObjCObjectOrInterfaceType()) { const Token &AfterNext = GetLookAheadToken(2); if (AfterNext.isOneOf(tok::colon, tok::r_square)) { if (Tok.is(tok::identifier)) TryAnnotateTypeOrScopeToken(); - + return Tok.is(tok::annot_typename); } } @@ -2998,14 +2998,14 @@ ExprResult Parser::ParseObjCMessageExpression() { cutOffParsing(); return ExprError(); } - + InMessageExpressionRAIIObject InMessage(*this, true); - + if (getLangOpts().CPlusPlus) { // We completely separate the C and C++ cases because C++ requires - // more complicated (read: slower) parsing. - - // Handle send to super. + // more complicated (read: slower) parsing. + + // Handle send to super. // FIXME: This doesn't benefit from the same typo-correction we // get in Objective-C. if (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_super && @@ -3025,11 +3025,11 @@ ExprResult Parser::ParseObjCMessageExpression() { return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), nullptr, static_cast<Expr *>(TypeOrExpr)); - return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), + return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), ParsedType::getFromOpaquePtr(TypeOrExpr), nullptr); } - + if (Tok.is(tok::identifier)) { IdentifierInfo *Name = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); @@ -3065,7 +3065,7 @@ ExprResult Parser::ParseObjCMessageExpression() { ReceiverType = NewReceiverType.get(); } - return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), + return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), ReceiverType, nullptr); case Sema::ObjCInstanceMessage: @@ -3073,7 +3073,7 @@ ExprResult Parser::ParseObjCMessageExpression() { break; } } - + // Otherwise, an arbitrary expression can be the receiver of a send. ExprResult Res = Actions.CorrectDelayedTyposInExpr(ParseExpression()); if (Res.isInvalid()) { @@ -3143,11 +3143,11 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc, cutOffParsing(); return ExprError(); } - + // Parse objc-selector SourceLocation Loc; IdentifierInfo *selIdent = ParseObjCSelectorPiece(Loc); - + SmallVector<IdentifierInfo *, 12> KeyIdents; SmallVector<SourceLocation, 12> KeyLocs; ExprVector KeyExprs; @@ -3167,10 +3167,10 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc, } /// Parse the expression after ':' - + if (Tok.is(tok::code_completion)) { if (SuperLoc.isValid()) - Actions.CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc, + Actions.CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc, KeyIdents, /*AtArgumentEpression=*/true); else if (ReceiverType) @@ -3185,14 +3185,14 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc, cutOffParsing(); return ExprError(); } - + ExprResult Expr; if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) { Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists); Expr = ParseBraceInitializer(); } else Expr = ParseAssignmentExpression(); - + ExprResult Res(Expr); if (Res.isInvalid()) { // We must manually skip to a ']', otherwise the expression skipper will @@ -3208,7 +3208,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc, // Code completion after each argument. if (Tok.is(tok::code_completion)) { if (SuperLoc.isValid()) - Actions.CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc, + Actions.CodeCompleteObjCSuperMessage(getCurScope(), SuperLoc, KeyIdents, /*AtArgumentEpression=*/false); else if (ReceiverType) @@ -3222,7 +3222,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc, cutOffParsing(); return ExprError(); } - + // Check for another keyword selector. selIdent = ParseObjCSelectorPiece(Loc); if (!selIdent && Tok.isNot(tok::colon)) @@ -3260,7 +3260,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc, SkipUntil(tok::r_square, StopAtSemi); return ExprError(); } - + if (Tok.isNot(tok::r_square)) { Diag(Tok, diag::err_expected) << (Tok.is(tok::identifier) ? tok::colon : tok::r_square); @@ -3270,7 +3270,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc, SkipUntil(tok::r_square, StopAtSemi); return ExprError(); } - + SourceLocation RBracLoc = ConsumeBracket(); // consume ']' unsigned nKeys = KeyIdents.size(); @@ -3324,7 +3324,7 @@ ExprResult Parser::ParseObjCStringLiteral(SourceLocation AtLoc) { /// ; /// boolean-keyword: 'true' | 'false' | '__objc_yes' | '__objc_no' /// ; -ExprResult Parser::ParseObjCBooleanLiteral(SourceLocation AtLoc, +ExprResult Parser::ParseObjCBooleanLiteral(SourceLocation AtLoc, bool ArgValue) { SourceLocation EndLoc = ConsumeToken(); // consume the keyword. return Actions.ActOnObjCBoolLiteral(AtLoc, EndLoc, ArgValue); @@ -3395,15 +3395,15 @@ ExprResult Parser::ParseObjCArrayLiteral(SourceLocation AtLoc) { // the enclosing expression. SkipUntil(tok::r_square, StopAtSemi); return Res; - } - + } + Res = Actions.CorrectDelayedTyposInExpr(Res.get()); if (Res.isInvalid()) HasInvalidEltExpr = true; // Parse the ellipsis that indicates a pack expansion. if (Tok.is(tok::ellipsis)) - Res = Actions.ActOnPackExpansion(Res.get(), ConsumeToken()); + Res = Actions.ActOnPackExpansion(Res.get(), ConsumeToken()); if (Res.isInvalid()) HasInvalidEltExpr = true; @@ -3447,7 +3447,7 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) { SkipUntil(tok::r_brace, StopAtSemi); return ExprError(); } - + ExprResult ValueExpr(ParseAssignmentExpression()); if (ValueExpr.isInvalid()) { // We must manually skip to a '}', otherwise the expression skipper will @@ -3456,7 +3456,7 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) { SkipUntil(tok::r_brace, StopAtSemi); return ValueExpr; } - + // Check the key and value for possible typos KeyExpr = Actions.CorrectDelayedTyposInExpr(KeyExpr.get()); ValueExpr = Actions.CorrectDelayedTyposInExpr(ValueExpr.get()); @@ -3472,8 +3472,8 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) { // We have a valid expression. Collect it in a vector so we can // build the argument list. - ObjCDictionaryElement Element = { - KeyExpr.get(), ValueExpr.get(), EllipsisLoc, None + ObjCDictionaryElement Element = { + KeyExpr.get(), ValueExpr.get(), EllipsisLoc, None }; Elements.push_back(Element); @@ -3485,7 +3485,7 @@ ExprResult Parser::ParseObjCDictionaryLiteral(SourceLocation AtLoc) { if (HasInvalidEltExpr) return ExprError(); - + // Create the ObjCDictionaryLiteral. return Actions.BuildObjCDictionaryLiteral(SourceRange(AtLoc, EndLoc), Elements); @@ -3551,26 +3551,26 @@ ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) { SmallVector<IdentifierInfo *, 12> KeyIdents; SourceLocation sLoc; - + BalancedDelimiterTracker T(*this, tok::l_paren); T.consumeOpen(); bool HasOptionalParen = Tok.is(tok::l_paren); if (HasOptionalParen) ConsumeParen(); - + if (Tok.is(tok::code_completion)) { Actions.CodeCompleteObjCSelector(getCurScope(), KeyIdents); cutOffParsing(); return ExprError(); } - + IdentifierInfo *SelIdent = ParseObjCSelectorPiece(sLoc); if (!SelIdent && // missing selector name. Tok.isNot(tok::colon) && Tok.isNot(tok::coloncolon)) return ExprError(Diag(Tok, diag::err_expected) << tok::identifier); KeyIdents.push_back(SelIdent); - + unsigned nColons = 0; if (Tok.isNot(tok::r_paren)) { while (1) { @@ -3583,7 +3583,7 @@ ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) { if (Tok.is(tok::r_paren)) break; - + if (Tok.is(tok::code_completion)) { Actions.CodeCompleteObjCSelector(getCurScope(), KeyIdents); cutOffParsing(); @@ -3611,12 +3611,12 @@ ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) { void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM, bool parseMethod) { // MCDecl might be null due to error in method or c-function prototype, etc. Decl *MCDecl = LM.D; - bool skip = MCDecl && + bool skip = MCDecl && ((parseMethod && !Actions.isObjCMethodDecl(MCDecl)) || (!parseMethod && Actions.isObjCMethodDecl(MCDecl))); if (skip) return; - + // Save the current token position. SourceLocation OrigLoc = Tok.getLocation(); @@ -3636,15 +3636,15 @@ void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM, bool parseMethod) { // Consume the previously pushed token. ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true); - - assert(Tok.isOneOf(tok::l_brace, tok::kw_try, tok::colon) && + + assert(Tok.isOneOf(tok::l_brace, tok::kw_try, tok::colon) && "Inline objective-c method not starting with '{' or 'try' or ':'"); // Enter a scope for the method or c-function body. ParseScope BodyScope(this, (parseMethod ? Scope::ObjCMethodScope : 0) | Scope::FnScope | Scope::DeclScope | Scope::CompoundStmtScope); - // Tell the actions module that we have entered a method or c-function definition + // Tell the actions module that we have entered a method or c-function definition // with the specified Declarator for the method/function. if (parseMethod) Actions.ActOnStartOfObjCMethodDef(getCurScope(), MCDecl); diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp index 9a25f9c25c0..07f48e0779d 100644 --- a/clang/lib/Parse/ParsePragma.cpp +++ b/clang/lib/Parse/ParsePragma.cpp @@ -1492,7 +1492,7 @@ void Parser::HandlePragmaAttribute() { // #pragma GCC visibility comes in two variants: // 'push' '(' [visibility] ')' // 'pop' -void PragmaGCCVisibilityHandler::HandlePragma(Preprocessor &PP, +void PragmaGCCVisibilityHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &VisTok) { SourceLocation VisLoc = VisTok.getLocation(); @@ -1552,7 +1552,7 @@ void PragmaGCCVisibilityHandler::HandlePragma(Preprocessor &PP, // pack '(' [integer] ')' // pack '(' 'show' ')' // pack '(' ('push' | 'pop') [',' identifier] [, integer] ')' -void PragmaPackHandler::HandlePragma(Preprocessor &PP, +void PragmaPackHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &PackTok) { SourceLocation PackLoc = PackTok.getLocation(); @@ -1663,7 +1663,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, // #pragma ms_struct on // #pragma ms_struct off -void PragmaMSStructHandler::HandlePragma(Preprocessor &PP, +void PragmaMSStructHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &MSStructTok) { PragmaMSStructKind Kind = PMSST_OFF; @@ -1686,7 +1686,7 @@ void PragmaMSStructHandler::HandlePragma(Preprocessor &PP, PP.Diag(Tok.getLocation(), diag::warn_pragma_ms_struct); return; } - + if (Tok.isNot(tok::eod)) { PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol) << "ms_struct"; @@ -1817,20 +1817,20 @@ static void ParseAlignPragma(Preprocessor &PP, Token &FirstTok, PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true); } -void PragmaAlignHandler::HandlePragma(Preprocessor &PP, +void PragmaAlignHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &AlignTok) { ParseAlignPragma(PP, AlignTok, /*IsOptions=*/false); } -void PragmaOptionsHandler::HandlePragma(Preprocessor &PP, +void PragmaOptionsHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &OptionsTok) { ParseAlignPragma(PP, OptionsTok, /*IsOptions=*/true); } // #pragma unused(identifier) -void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, +void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &UnusedTok) { // FIXME: Should we be expanding macros here? My guess is no. @@ -1911,7 +1911,7 @@ void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, // #pragma weak identifier // #pragma weak identifier '=' identifier -void PragmaWeakHandler::HandlePragma(Preprocessor &PP, +void PragmaWeakHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &WeakTok) { SourceLocation WeakLoc = WeakTok.getLocation(); @@ -1970,7 +1970,7 @@ void PragmaWeakHandler::HandlePragma(Preprocessor &PP, } // #pragma redefine_extname identifier identifier -void PragmaRedefineExtnameHandler::HandlePragma(Preprocessor &PP, +void PragmaRedefineExtnameHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &RedefToken) { SourceLocation RedefLoc = RedefToken.getLocation(); @@ -2015,7 +2015,7 @@ void PragmaRedefineExtnameHandler::HandlePragma(Preprocessor &PP, void -PragmaFPContractHandler::HandlePragma(Preprocessor &PP, +PragmaFPContractHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &Tok) { tok::OnOffSwitch OOS; @@ -2033,8 +2033,8 @@ PragmaFPContractHandler::HandlePragma(Preprocessor &PP, PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true); } -void -PragmaOpenCLExtensionHandler::HandlePragma(Preprocessor &PP, +void +PragmaOpenCLExtensionHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &Tok) { PP.LexUnexpandedToken(Tok); @@ -2095,7 +2095,7 @@ PragmaOpenCLExtensionHandler::HandlePragma(Preprocessor &PP, PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true); if (PP.getPPCallbacks()) - PP.getPPCallbacks()->PragmaOpenCLExtension(NameLoc, Ext, + PP.getPPCallbacks()->PragmaOpenCLExtension(NameLoc, Ext, StateLoc, State); } @@ -2523,7 +2523,7 @@ void PragmaCommentHandler::HandlePragma(Preprocessor &PP, // #pragma clang optimize off // #pragma clang optimize on -void PragmaOptimizeHandler::HandlePragma(Preprocessor &PP, +void PragmaOptimizeHandler::HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, Token &FirstToken) { Token Tok; @@ -2549,7 +2549,7 @@ void PragmaOptimizeHandler::HandlePragma(Preprocessor &PP, return; } PP.Lex(Tok); - + if (Tok.isNot(tok::eod)) { PP.Diag(Tok.getLocation(), diag::err_pragma_optimize_extra_argument) << PP.getSpelling(Tok); diff --git a/clang/lib/Parse/ParseStmtAsm.cpp b/clang/lib/Parse/ParseStmtAsm.cpp index 290723c2953..9b96c5150e5 100644 --- a/clang/lib/Parse/ParseStmtAsm.cpp +++ b/clang/lib/Parse/ParseStmtAsm.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file implements parsing for GCC and Microsoft inline assembly. +// This file implements parsing for GCC and Microsoft inline assembly. // //===----------------------------------------------------------------------===// diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp index f7a69c482e1..063f7ccea32 100644 --- a/clang/lib/Parse/ParseTemplate.cpp +++ b/clang/lib/Parse/ParseTemplate.cpp @@ -27,7 +27,7 @@ Decl *Parser::ParseDeclarationStartingWithTemplate( DeclaratorContext Context, SourceLocation &DeclEnd, ParsedAttributes &AccessAttrs, AccessSpecifier AS) { ObjCDeclContextSwitch ObjCDC(*this); - + if (Tok.is(tok::kw_template) && NextToken().isNot(tok::less)) { return ParseExplicitInstantiation(Context, SourceLocation(), ConsumeToken(), DeclEnd, AccessAttrs, AS); @@ -360,7 +360,7 @@ bool Parser::ParseTemplateParameterList(const unsigned Depth, SmallVectorImpl<NamedDecl*> &TemplateParams) { while (1) { - + if (NamedDecl *TmpParam = ParseTemplateParameter(Depth, TemplateParams.size())) { TemplateParams.push_back(TmpParam); @@ -403,23 +403,23 @@ bool Parser::isStartOfTemplateTypeParameter() { case tok::greatergreater: case tok::ellipsis: return true; - + case tok::identifier: - // This may be either a type-parameter or an elaborated-type-specifier. + // This may be either a type-parameter or an elaborated-type-specifier. // We have to look further. break; - + default: return false; } - + switch (GetLookAheadToken(2).getKind()) { case tok::equal: case tok::comma: case tok::greater: case tok::greatergreater: return true; - + default: return false; } @@ -464,7 +464,7 @@ bool Parser::isStartOfTemplateTypeParameter() { /// 'class' identifier[opt] '=' type-id /// 'typename' ...[opt] identifier[opt] /// 'typename' identifier[opt] '=' type-id -/// 'template' '<' template-parameter-list '>' +/// 'template' '<' template-parameter-list '>' /// 'class' ...[opt] identifier[opt] /// 'template' '<' template-parameter-list '>' 'class' identifier[opt] /// = id-expression @@ -617,7 +617,7 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) { getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_variadic_templates : diag::ext_variadic_templates); - + // Get the identifier, if given. SourceLocation NameLoc; IdentifierInfo *ParamName = nullptr; @@ -652,16 +652,16 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) { if (TryConsumeToken(tok::equal, EqualLoc)) { DefaultArg = ParseTemplateTemplateArgument(); if (DefaultArg.isInvalid()) { - Diag(Tok.getLocation(), + Diag(Tok.getLocation(), diag::err_default_template_template_parameter_not_template); SkipUntil(tok::comma, tok::greater, tok::greatergreater, StopAtSemi | StopBeforeMatch); } } - + return Actions.ActOnTemplateTemplateParameter(getCurScope(), TemplateLoc, - ParamList, EllipsisLoc, - ParamName, NameLoc, Depth, + ParamList, EllipsisLoc, + ParamName, NameLoc, Depth, Position, EqualLoc, DefaultArg); } @@ -714,8 +714,8 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) { } // Create the parameter. - return Actions.ActOnNonTypeTemplateParameter(getCurScope(), ParamDecl, - Depth, Position, EqualLoc, + return Actions.ActOnNonTypeTemplateParameter(getCurScope(), ParamDecl, + Depth, Position, EqualLoc, DefaultArg.get()); } @@ -1045,7 +1045,7 @@ bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK, // Build a template-id annotation token that can be processed // later. Tok.setKind(tok::annot_template_id); - + IdentifierInfo *TemplateII = TemplateName.getKind() == UnqualifiedIdKind::IK_Identifier ? TemplateName.Identifier @@ -1059,7 +1059,7 @@ bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK, TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create( SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK, LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds); - + Tok.setAnnotationValue(TemplateId); if (TemplateKWLoc.isValid()) Tok.setLocation(TemplateKWLoc); @@ -1135,13 +1135,13 @@ ParsedTemplateArgument Parser::ParseTemplateTemplateArgument() { // C++0x [temp.arg.template]p1: // A template-argument for a template template-parameter shall be the name // of a class template or an alias template, expressed as id-expression. - // + // // We parse an id-expression that refers to a class template or alias // template. The grammar we parse is: // // nested-name-specifier[opt] template[opt] identifier ...[opt] // - // followed by a token that terminates a template argument, such as ',', + // followed by a token that terminates a template argument, such as ',', // '>', or (in some cases) '>>'. CXXScopeSpec SS; // nested-name-specifier, if present ParseOptionalCXXScopeSpecifier(SS, nullptr, @@ -1150,10 +1150,10 @@ ParsedTemplateArgument Parser::ParseTemplateTemplateArgument() { ParsedTemplateArgument Result; SourceLocation EllipsisLoc; if (SS.isSet() && Tok.is(tok::kw_template)) { - // Parse the optional 'template' keyword following the + // Parse the optional 'template' keyword following the // nested-name-specifier. SourceLocation TemplateKWLoc = ConsumeToken(); - + if (Tok.is(tok::identifier)) { // We appear to have a dependent template name. UnqualifiedId Name; @@ -1191,16 +1191,16 @@ ParsedTemplateArgument Parser::ParseTemplateTemplateArgument() { /*EnteringContext=*/false, Template, MemberOfUnknownSpecialization); if (TNK == TNK_Dependent_template_name || TNK == TNK_Type_template) { // We have an id-expression that refers to a class template or - // (C++0x) alias template. + // (C++0x) alias template. Result = ParsedTemplateArgument(SS, Template, Name.StartLocation); } } } - + // If this is a pack expansion, build it as such. if (EllipsisLoc.isValid() && !Result.isInvalid()) Result = Actions.ActOnPackExpansion(Result, EllipsisLoc); - + return Result; } @@ -1230,7 +1230,7 @@ ParsedTemplateArgument Parser::ParseTemplateArgument() { /*Range=*/nullptr, DeclaratorContext::TemplateArgContext); return Actions.ActOnTemplateTypeArgument(TypeArg); } - + // Try to parse a template template argument. { TentativeParsingAction TPA(*this); @@ -1241,35 +1241,35 @@ ParsedTemplateArgument Parser::ParseTemplateArgument() { TPA.Commit(); return TemplateTemplateArgument; } - + // Revert this tentative parse to parse a non-type template argument. TPA.Revert(); } - - // Parse a non-type template argument. + + // Parse a non-type template argument. SourceLocation Loc = Tok.getLocation(); ExprResult ExprArg = ParseConstantExpressionInExprEvalContext(MaybeTypeCast); if (ExprArg.isInvalid() || !ExprArg.get()) return ParsedTemplateArgument(); - return ParsedTemplateArgument(ParsedTemplateArgument::NonType, + return ParsedTemplateArgument(ParsedTemplateArgument::NonType, ExprArg.get(), Loc); } -/// Determine whether the current tokens can only be parsed as a -/// template argument list (starting with the '<') and never as a '<' +/// Determine whether the current tokens can only be parsed as a +/// template argument list (starting with the '<') and never as a '<' /// expression. bool Parser::IsTemplateArgumentList(unsigned Skip) { struct AlwaysRevertAction : TentativeParsingAction { AlwaysRevertAction(Parser &P) : TentativeParsingAction(P) { } ~AlwaysRevertAction() { Revert(); } } Tentative(*this); - + while (Skip) { ConsumeAnyToken(); --Skip; } - + // '<' if (!TryConsumeToken(tok::less)) return false; @@ -1277,11 +1277,11 @@ bool Parser::IsTemplateArgumentList(unsigned Skip) { // An empty template argument list. if (Tok.is(tok::greater)) return true; - + // See whether we have declaration specifiers, which indicate a type. while (isCXXDeclarationSpecifier() == TPResult::True) ConsumeAnyToken(); - + // If we have a '>' or a ',' then this is a template argument list. return Tok.isOneOf(tok::greater, tok::comma); } @@ -1294,7 +1294,7 @@ bool Parser::IsTemplateArgumentList(unsigned Skip) { /// template-argument-list ',' template-argument bool Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs) { - + ColonProtectionRAIIObject ColonProtection(*this, false); do { @@ -1310,7 +1310,7 @@ Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs) { // Save this template argument. TemplateArgs.push_back(Arg); - + // If the next token is a comma, consume it and keep reading // arguments. } while (TryConsumeToken(tok::comma)); diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index 0603d8e75ee..dfd1f8c3b2e 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -80,10 +80,10 @@ bool Parser::isCXXDeclarationStatement() { /// (if AllowForRangeDecl specified) /// for ( for-range-declaration : for-range-initializer ) statement /// -/// for-range-declaration: +/// for-range-declaration: /// decl-specifier-seq declarator /// decl-specifier-seq ref-qualifier[opt] '[' identifier-list ']' -/// +/// /// In any of the above cases there can be a preceding attribute-specifier-seq, /// but the caller is expected to handle that. bool Parser::isCXXSimpleDeclaration(bool AllowForRangeDecl) { @@ -132,7 +132,7 @@ bool Parser::isCXXSimpleDeclaration(bool AllowForRangeDecl) { // Ok, we have a simple-type-specifier/typename-specifier followed by a '(', // or an identifier which doesn't resolve as anything. We need tentative // parsing... - + { RevertingTentativeParsingAction PA(*this); TPR = TryParseSimpleDeclaration(AllowForRangeDecl); @@ -236,7 +236,7 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() { /// /// (if AllowForRangeDecl specified) /// for ( for-range-declaration : for-range-initializer ) statement -/// for-range-declaration: +/// for-range-declaration: /// attribute-specifier-seqopt type-specifier-seq declarator /// Parser::TPResult Parser::TryParseSimpleDeclaration(bool AllowForRangeDecl) { @@ -964,7 +964,7 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract, return TPResult::Ambiguous; } -Parser::TPResult +Parser::TPResult Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { switch (Kind) { // Obviously starts an expression. @@ -1026,7 +1026,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { case tok::kw_##Spelling: #include "clang/Basic/TokenKinds.def" return TPResult::True; - + // Obviously starts a type-specifier-seq: case tok::kw_char: case tok::kw_const: @@ -1084,7 +1084,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { default: break; } - + return TPResult::Ambiguous; } @@ -1338,7 +1338,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, // Debugger support case tok::kw___unknown_anytype: - + // type-specifier: // simple-type-specifier // class-specifier @@ -1395,7 +1395,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, // Borland case tok::kw___pascal: return TPResult::True; - + // AltiVec case tok::kw___vector: return TPResult::True; @@ -1510,24 +1510,24 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, // Tentatively parse the protocol qualifiers. RevertingTentativeParsingAction PA(*this); ConsumeAnyToken(); // The type token - + TPResult TPR = TryParseProtocolQualifiers(); bool isFollowedByParen = Tok.is(tok::l_paren); bool isFollowedByBrace = Tok.is(tok::l_brace); - + if (TPR == TPResult::Error) return TPResult::Error; - + if (isFollowedByParen) return TPResult::Ambiguous; if (getLangOpts().CPlusPlus11 && isFollowedByBrace) return BracedCastResult; - + return TPResult::True; } LLVM_FALLTHROUGH; - + case tok::kw_char: case tok::kw_wchar_t: case tok::kw_char8_t: @@ -1562,7 +1562,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, if (isStartOfObjCClassMessageMissingOpenBracket()) return TPResult::False; - + return TPResult::True; // GNU typeof support. @@ -1681,18 +1681,18 @@ Parser::TPResult Parser::TryParseProtocolQualifiers() { if (Tok.isNot(tok::identifier)) return TPResult::Error; ConsumeToken(); - + if (Tok.is(tok::comma)) { ConsumeToken(); continue; } - + if (Tok.is(tok::greater)) { ConsumeToken(); return TPResult::Ambiguous; } } while (false); - + return TPResult::Error; } @@ -1910,7 +1910,7 @@ Parser::TPResult Parser::TryParseFunctionDeclarator() { // ref-qualifier[opt] if (Tok.isOneOf(tok::amp, tok::ampamp)) ConsumeToken(); - + // exception-specification if (Tok.is(tok::kw_throw)) { ConsumeToken(); diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 7a0b29cbae8..c3085654f52 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -41,7 +41,7 @@ public: } // end anonymous namespace IdentifierInfo *Parser::getSEHExceptKeyword() { - // __except is accepted as a (contextual) keyword + // __except is accepted as a (contextual) keyword if (!Ident__except && (getLangOpts().MicrosoftExt || getLangOpts().Borland)) Ident__except = PP.getIdentifierInfo("__except"); @@ -50,7 +50,7 @@ IdentifierInfo *Parser::getSEHExceptKeyword() { Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies) : PP(pp), Actions(actions), Diags(PP.getDiagnostics()), - GreaterThanIsOperator(true), ColonIsSacred(false), + GreaterThanIsOperator(true), ColonIsSacred(false), InMessageExpression(false), TemplateParameterDepth(0), ParsingInObjCContainer(false) { SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies; @@ -161,8 +161,8 @@ bool Parser::ExpectAndConsumeSemi(unsigned DiagID) { handleUnexpectedCodeCompletionToken(); return false; } - - if ((Tok.is(tok::r_paren) || Tok.is(tok::r_square)) && + + if ((Tok.is(tok::r_paren) || Tok.is(tok::r_square)) && NextToken().is(tok::semi)) { Diag(Tok, diag::err_extraneous_token_before_semi) << PP.getSpelling(Tok) @@ -171,7 +171,7 @@ bool Parser::ExpectAndConsumeSemi(unsigned DiagID) { ConsumeToken(); // The ';'. return false; } - + return ExpectAndConsume(tok::semi, DiagID); } @@ -291,7 +291,7 @@ bool Parser::SkipUntil(ArrayRef<tok::TokenKind> Toks, SkipUntilFlags Flags) { if (!HasFlagsSet(Flags, StopAtCodeCompletion)) handleUnexpectedCodeCompletionToken(); return false; - + case tok::l_paren: // Recursively skip properly-nested parens. ConsumeParen(); @@ -796,17 +796,17 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); } goto dont_know; - + case tok::kw_inline: if (getLangOpts().CPlusPlus) { tok::TokenKind NextKind = NextToken().getKind(); - + // Inline namespaces. Allowed as an extension even in C++03. if (NextKind == tok::kw_namespace) { SourceLocation DeclEnd; return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); } - + // Parse (then ignore) 'inline' prior to a template instantiation. This is // a GCC extension that we intentionally do not support. if (NextKind == tok::kw_template) { @@ -867,7 +867,7 @@ bool Parser::isDeclarationAfterDeclarator() { if (KW.is(tok::kw_default) || KW.is(tok::kw_delete)) return false; } - + return Tok.is(tok::equal) || // int X()= -> not a function def Tok.is(tok::comma) || // int X(), -> not a function def Tok.is(tok::semi) || // int X(); -> not a function def @@ -883,17 +883,17 @@ bool Parser::isStartOfFunctionDefinition(const ParsingDeclarator &Declarator) { assert(Declarator.isFunctionDeclarator() && "Isn't a function declarator"); if (Tok.is(tok::l_brace)) // int X() {} return true; - + // Handle K&R C argument lists: int X(f) int f; {} if (!getLangOpts().CPlusPlus && - Declarator.getFunctionTypeInfo().isKNRPrototype()) + Declarator.getFunctionTypeInfo().isKNRPrototype()) return isDeclarationSpecifier(); if (getLangOpts().CPlusPlus && Tok.is(tok::equal)) { const Token &KW = NextToken(); return KW.is(tok::kw_default) || KW.is(tok::kw_delete); } - + return Tok.is(tok::colon) || // X() : Base() {} (used for ctors) Tok.is(tok::kw_try); // X() try { ... } } @@ -947,7 +947,7 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs, default: llvm_unreachable("we only expect to get the length of the class/struct/union/enum"); } - + }; // Suggest correct location to fix '[[attrib]] struct' to 'struct [[attrib]]' SourceLocation CorrectLocationForAttributes = @@ -1072,7 +1072,7 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, // We should have either an opening brace or, in a C++ constructor, // we may have a colon. - if (Tok.isNot(tok::l_brace) && + if (Tok.isNot(tok::l_brace) && (!getLangOpts().CPlusPlus || (Tok.isNot(tok::colon) && Tok.isNot(tok::kw_try) && Tok.isNot(tok::equal)))) { @@ -1128,10 +1128,10 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, } return DP; } - else if (CurParsedObjCImpl && + else if (CurParsedObjCImpl && !TemplateInfo.TemplateParams && (Tok.is(tok::l_brace) || Tok.is(tok::kw_try) || - Tok.is(tok::colon)) && + Tok.is(tok::colon)) && Actions.CurContext->isTranslationUnit()) { ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope | Scope::CompoundStmtScope); @@ -1171,7 +1171,7 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, // Break out of the ParsingDeclarator context before we parse the body. D.complete(Res); - + // Break out of the ParsingDeclSpec context, too. This const_cast is // safe because we're always the sole owner. D.getMutableDeclSpec().abort(); @@ -1710,7 +1710,7 @@ bool Parser::TryAnnotateTypeOrScopeToken() { TypeResult Ty; if (Tok.is(tok::identifier)) { // FIXME: check whether the next token is '<', first! - Ty = Actions.ActOnTypenameType(getCurScope(), TypenameLoc, SS, + Ty = Actions.ActOnTypenameType(getCurScope(), TypenameLoc, SS, *Tok.getIdentifierInfo(), Tok.getLocation()); } else if (Tok.is(tok::annot_template_id)) { @@ -1926,14 +1926,14 @@ SourceLocation Parser::handleUnexpectedCodeCompletionToken() { cutOffParsing(); return PrevTokLocation; } - + if (S->getFlags() & Scope::ClassScope) { Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Class); cutOffParsing(); return PrevTokLocation; } } - + Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace); cutOffParsing(); return PrevTokLocation; @@ -1953,7 +1953,7 @@ void Parser::CodeCompleteMacroName(bool IsDefinition) { Actions.CodeCompletePreprocessorMacroName(IsDefinition); } -void Parser::CodeCompletePreprocessorExpression() { +void Parser::CodeCompletePreprocessorExpression() { Actions.CodeCompletePreprocessorExpression(); } @@ -1976,11 +1976,11 @@ bool Parser::ParseMicrosoftIfExistsCondition(IfExistsCondition& Result) { BalancedDelimiterTracker T(*this, tok::l_paren); if (T.consumeOpen()) { - Diag(Tok, diag::err_expected_lparen_after) + Diag(Tok, diag::err_expected_lparen_after) << (Result.IsIfExists? "__if_exists" : "__if_not_exists"); return true; } - + // Parse nested-name-specifier. if (getLangOpts().CPlusPlus) ParseOptionalCXXScopeSpecifier(Result.SS, nullptr, @@ -2004,7 +2004,7 @@ bool Parser::ParseMicrosoftIfExistsCondition(IfExistsCondition& Result) { if (T.consumeClose()) return true; - + // Check if the symbol exists. switch (Actions.CheckMicrosoftIfExistsSymbol(getCurScope(), Result.KeywordLoc, Result.IsIfExists, Result.SS, @@ -2020,7 +2020,7 @@ bool Parser::ParseMicrosoftIfExistsCondition(IfExistsCondition& Result) { case Sema::IER_Dependent: Result.Behavior = IEB_Dependent; break; - + case Sema::IER_Error: return true; } @@ -2032,7 +2032,7 @@ void Parser::ParseMicrosoftIfExistsExternalDeclaration() { IfExistsCondition Result; if (ParseMicrosoftIfExistsCondition(Result)) return; - + BalancedDelimiterTracker Braces(*this, tok::l_brace); if (Braces.consumeOpen()) { Diag(Tok, diag::err_expected) << tok::l_brace; @@ -2043,10 +2043,10 @@ void Parser::ParseMicrosoftIfExistsExternalDeclaration() { case IEB_Parse: // Parse declarations below. break; - + case IEB_Dependent: llvm_unreachable("Cannot have a dependent external declaration"); - + case IEB_Skip: Braces.skipToEnd(); return; @@ -2109,7 +2109,7 @@ Parser::DeclGroupPtrTy Parser::ParseModuleDecl() { /// Parse a module import declaration. This is essentially the same for /// Objective-C and the C++ Modules TS, except for the leading '@' (in ObjC) /// and the trailing optional attributes (in C++). -/// +/// /// [ObjC] @import declaration: /// '@' 'import' module-name ';' /// [ModTS] module-import-declaration: @@ -2121,7 +2121,7 @@ Decl *Parser::ParseModuleImport(SourceLocation AtLoc) { bool IsObjCAtImport = Tok.isObjCAtKeyword(tok::objc_import); SourceLocation ImportLoc = ConsumeToken(); SourceLocation StartLoc = AtLoc.isInvalid() ? ImportLoc : AtLoc; - + SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> Path; if (ParseModuleName(ImportLoc, Path, /*IsImport*/true)) return nullptr; @@ -2174,12 +2174,12 @@ bool Parser::ParseModuleName( cutOffParsing(); return true; } - + Diag(Tok, diag::err_module_expected_ident) << IsImport; SkipUntil(tok::semi); return true; } - + // Record this part of the module path. Path.push_back(std::make_pair(Tok.getIdentifierInfo(), Tok.getLocation())); ConsumeToken(); @@ -2258,7 +2258,7 @@ bool BalancedDelimiterTracker::expectAndConsume(unsigned DiagID, if (getDepth() < P.getLangOpts().BracketDepth) return false; - + return diagnoseOverflow(); } |