From: Faisal Vali Date: Wed, 11 Nov 2020 05:40:12 +0000 (-0600) Subject: [NFC, Refactor] Rename the (scoped) enum DeclaratorContext's enumerators to remove... X-Git-Tag: llvmorg-13-init~6463 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4d27932a59fb61aaba3ff7a3ccd1b5bc9215fb9;p=platform%2Fupstream%2Fllvm.git [NFC, Refactor] Rename the (scoped) enum DeclaratorContext's enumerators to remove duplication Since these are scoped enumerators, they have to be prefixed by DeclaratorContext, so lets remove Context from the name, and return some characters to the multiverse. Patch was reviewed here: https://reviews.llvm.org/D91011 Thank you to aaron, bruno, wyatt and barry for indulging me. --- diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 02b73b3..20dba70 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -2579,12 +2579,11 @@ private: bool TrySkipAttributes(); public: - TypeResult ParseTypeName(SourceRange *Range = nullptr, - DeclaratorContext Context - = DeclaratorContext::TypeNameContext, - AccessSpecifier AS = AS_none, - Decl **OwnedType = nullptr, - ParsedAttributes *Attrs = nullptr); + TypeResult + ParseTypeName(SourceRange *Range = nullptr, + DeclaratorContext Context = DeclaratorContext::TypeName, + AccessSpecifier AS = AS_none, Decl **OwnedType = nullptr, + ParsedAttributes *Attrs = nullptr); private: void ParseBlockId(SourceLocation CaretLoc); diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index abbefc9..0598d0d 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -1761,36 +1761,35 @@ enum FunctionDefinitionKind { }; enum class DeclaratorContext { - FileContext, // File scope declaration. - PrototypeContext, // Within a function prototype. - ObjCResultContext, // An ObjC method result type. - ObjCParameterContext,// An ObjC method parameter type. - KNRTypeListContext, // K&R type definition list for formals. - TypeNameContext, // Abstract declarator for types. - FunctionalCastContext, // Type in a C++ functional cast expression. - MemberContext, // Struct/Union field. - BlockContext, // Declaration within a block in a function. - ForContext, // Declaration within first part of a for loop. - InitStmtContext, // Declaration within optional init stmt of if/switch. - ConditionContext, // Condition declaration in a C++ if/switch/while/for. - TemplateParamContext,// Within a template parameter list. - CXXNewContext, // C++ new-expression. - CXXCatchContext, // C++ catch exception-declaration - ObjCCatchContext, // Objective-C catch exception-declaration - BlockLiteralContext, // Block literal declarator. - LambdaExprContext, // Lambda-expression declarator. - LambdaExprParameterContext, // Lambda-expression parameter declarator. - ConversionIdContext, // C++ conversion-type-id. - TrailingReturnContext, // C++11 trailing-type-specifier. - TrailingReturnVarContext, // C++11 trailing-type-specifier for variable. - TemplateArgContext, // Any template argument (in template argument list). - TemplateTypeArgContext, // Template type argument (in default argument). - AliasDeclContext, // C++11 alias-declaration. - AliasTemplateContext, // C++11 alias-declaration template. - RequiresExprContext // C++2a requires-expression. + File, // File scope declaration. + Prototype, // Within a function prototype. + ObjCResult, // An ObjC method result type. + ObjCParameter, // An ObjC method parameter type. + KNRTypeList, // K&R type definition list for formals. + TypeName, // Abstract declarator for types. + FunctionalCast, // Type in a C++ functional cast expression. + Member, // Struct/Union field. + Block, // Declaration within a block in a function. + ForInit, // Declaration within first part of a for loop. + SelectionInit, // Declaration within optional init stmt of if/switch. + Condition, // Condition declaration in a C++ if/switch/while/for. + TemplateParam, // Within a template parameter list. + CXXNew, // C++ new-expression. + CXXCatch, // C++ catch exception-declaration + ObjCCatch, // Objective-C catch exception-declaration + BlockLiteral, // Block literal declarator. + LambdaExpr, // Lambda-expression declarator. + LambdaExprParameter, // Lambda-expression parameter declarator. + ConversionId, // C++ conversion-type-id. + TrailingReturn, // C++11 trailing-type-specifier. + TrailingReturnVar, // C++11 trailing-type-specifier for variable. + TemplateArg, // Any template argument (in template argument list). + TemplateTypeArg, // Template type argument (in default argument). + AliasDecl, // C++11 alias-declaration. + AliasTemplate, // C++11 alias-declaration template. + RequiresExpr // C++2a requires-expression. }; - /// Information about one declarator, including the parsed type /// information and the identifier. /// @@ -1934,10 +1933,10 @@ public: DeclaratorContext getContext() const { return Context; } bool isPrototypeContext() const { - return (Context == DeclaratorContext::PrototypeContext || - Context == DeclaratorContext::ObjCParameterContext || - Context == DeclaratorContext::ObjCResultContext || - Context == DeclaratorContext::LambdaExprParameterContext); + return (Context == DeclaratorContext::Prototype || + Context == DeclaratorContext::ObjCParameter || + Context == DeclaratorContext::ObjCResult || + Context == DeclaratorContext::LambdaExprParameter); } /// Get the source range that spans this declarator. @@ -1992,35 +1991,35 @@ public: /// parameter lists. bool mayOmitIdentifier() const { switch (Context) { - case DeclaratorContext::FileContext: - case DeclaratorContext::KNRTypeListContext: - case DeclaratorContext::MemberContext: - case DeclaratorContext::BlockContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: - case DeclaratorContext::ConditionContext: + case DeclaratorContext::File: + case DeclaratorContext::KNRTypeList: + case DeclaratorContext::Member: + case DeclaratorContext::Block: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: + case DeclaratorContext::Condition: return false; - case DeclaratorContext::TypeNameContext: - case DeclaratorContext::FunctionalCastContext: - case DeclaratorContext::AliasDeclContext: - case DeclaratorContext::AliasTemplateContext: - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::LambdaExprParameterContext: - case DeclaratorContext::ObjCParameterContext: - case DeclaratorContext::ObjCResultContext: - case DeclaratorContext::TemplateParamContext: - case DeclaratorContext::CXXNewContext: - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::ObjCCatchContext: - case DeclaratorContext::BlockLiteralContext: - case DeclaratorContext::LambdaExprContext: - case DeclaratorContext::ConversionIdContext: - case DeclaratorContext::TemplateArgContext: - case DeclaratorContext::TemplateTypeArgContext: - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::TrailingReturnVarContext: - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::TypeName: + case DeclaratorContext::FunctionalCast: + case DeclaratorContext::AliasDecl: + case DeclaratorContext::AliasTemplate: + case DeclaratorContext::Prototype: + case DeclaratorContext::LambdaExprParameter: + case DeclaratorContext::ObjCParameter: + case DeclaratorContext::ObjCResult: + case DeclaratorContext::TemplateParam: + case DeclaratorContext::CXXNew: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::ObjCCatch: + case DeclaratorContext::BlockLiteral: + case DeclaratorContext::LambdaExpr: + case DeclaratorContext::ConversionId: + case DeclaratorContext::TemplateArg: + case DeclaratorContext::TemplateTypeArg: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::TrailingReturnVar: + case DeclaratorContext::RequiresExpr: return true; } llvm_unreachable("unknown context kind!"); @@ -2031,35 +2030,35 @@ public: /// typenames. bool mayHaveIdentifier() const { switch (Context) { - case DeclaratorContext::FileContext: - case DeclaratorContext::KNRTypeListContext: - case DeclaratorContext::MemberContext: - case DeclaratorContext::BlockContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: - case DeclaratorContext::ConditionContext: - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::LambdaExprParameterContext: - case DeclaratorContext::TemplateParamContext: - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::ObjCCatchContext: - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::File: + case DeclaratorContext::KNRTypeList: + case DeclaratorContext::Member: + case DeclaratorContext::Block: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: + case DeclaratorContext::Condition: + case DeclaratorContext::Prototype: + case DeclaratorContext::LambdaExprParameter: + case DeclaratorContext::TemplateParam: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::ObjCCatch: + case DeclaratorContext::RequiresExpr: return true; - case DeclaratorContext::TypeNameContext: - case DeclaratorContext::FunctionalCastContext: - case DeclaratorContext::CXXNewContext: - case DeclaratorContext::AliasDeclContext: - case DeclaratorContext::AliasTemplateContext: - case DeclaratorContext::ObjCParameterContext: - case DeclaratorContext::ObjCResultContext: - case DeclaratorContext::BlockLiteralContext: - case DeclaratorContext::LambdaExprContext: - case DeclaratorContext::ConversionIdContext: - case DeclaratorContext::TemplateArgContext: - case DeclaratorContext::TemplateTypeArgContext: - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::TrailingReturnVarContext: + case DeclaratorContext::TypeName: + case DeclaratorContext::FunctionalCast: + case DeclaratorContext::CXXNew: + case DeclaratorContext::AliasDecl: + case DeclaratorContext::AliasTemplate: + case DeclaratorContext::ObjCParameter: + case DeclaratorContext::ObjCResult: + case DeclaratorContext::BlockLiteral: + case DeclaratorContext::LambdaExpr: + case DeclaratorContext::ConversionId: + case DeclaratorContext::TemplateArg: + case DeclaratorContext::TemplateTypeArg: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::TrailingReturnVar: return false; } llvm_unreachable("unknown context kind!"); @@ -2068,41 +2067,41 @@ public: /// Return true if the context permits a C++17 decomposition declarator. bool mayHaveDecompositionDeclarator() const { switch (Context) { - case DeclaratorContext::FileContext: + case DeclaratorContext::File: // FIXME: It's not clear that the proposal meant to allow file-scope // structured bindings, but it does. - case DeclaratorContext::BlockContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: - case DeclaratorContext::ConditionContext: + case DeclaratorContext::Block: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: + case DeclaratorContext::Condition: return true; - case DeclaratorContext::MemberContext: - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::TemplateParamContext: - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::Member: + case DeclaratorContext::Prototype: + case DeclaratorContext::TemplateParam: + case DeclaratorContext::RequiresExpr: // Maybe one day... return false; // These contexts don't allow any kind of non-abstract declarator. - case DeclaratorContext::KNRTypeListContext: - case DeclaratorContext::TypeNameContext: - case DeclaratorContext::FunctionalCastContext: - case DeclaratorContext::AliasDeclContext: - case DeclaratorContext::AliasTemplateContext: - case DeclaratorContext::LambdaExprParameterContext: - case DeclaratorContext::ObjCParameterContext: - case DeclaratorContext::ObjCResultContext: - case DeclaratorContext::CXXNewContext: - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::ObjCCatchContext: - case DeclaratorContext::BlockLiteralContext: - case DeclaratorContext::LambdaExprContext: - case DeclaratorContext::ConversionIdContext: - case DeclaratorContext::TemplateArgContext: - case DeclaratorContext::TemplateTypeArgContext: - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::TrailingReturnVarContext: + case DeclaratorContext::KNRTypeList: + case DeclaratorContext::TypeName: + case DeclaratorContext::FunctionalCast: + case DeclaratorContext::AliasDecl: + case DeclaratorContext::AliasTemplate: + case DeclaratorContext::LambdaExprParameter: + case DeclaratorContext::ObjCParameter: + case DeclaratorContext::ObjCResult: + case DeclaratorContext::CXXNew: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::ObjCCatch: + case DeclaratorContext::BlockLiteral: + case DeclaratorContext::LambdaExpr: + case DeclaratorContext::ConversionId: + case DeclaratorContext::TemplateArg: + case DeclaratorContext::TemplateTypeArg: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::TrailingReturnVar: return false; } llvm_unreachable("unknown context kind!"); @@ -2117,7 +2116,7 @@ public: return false; if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_extern && - Context != DeclaratorContext::FileContext) + Context != DeclaratorContext::File) return false; // Special names can't have direct initializers. @@ -2125,40 +2124,40 @@ public: return false; switch (Context) { - case DeclaratorContext::FileContext: - case DeclaratorContext::BlockContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: - case DeclaratorContext::TrailingReturnVarContext: + case DeclaratorContext::File: + case DeclaratorContext::Block: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: + case DeclaratorContext::TrailingReturnVar: return true; - case DeclaratorContext::ConditionContext: + case DeclaratorContext::Condition: // This may not be followed by a direct initializer, but it can't be a // function declaration either, and we'd prefer to perform a tentative // parse in order to produce the right diagnostic. return true; - case DeclaratorContext::KNRTypeListContext: - case DeclaratorContext::MemberContext: - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::LambdaExprParameterContext: - case DeclaratorContext::ObjCParameterContext: - case DeclaratorContext::ObjCResultContext: - case DeclaratorContext::TemplateParamContext: - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::ObjCCatchContext: - case DeclaratorContext::TypeNameContext: - case DeclaratorContext::FunctionalCastContext: // FIXME - case DeclaratorContext::CXXNewContext: - case DeclaratorContext::AliasDeclContext: - case DeclaratorContext::AliasTemplateContext: - case DeclaratorContext::BlockLiteralContext: - case DeclaratorContext::LambdaExprContext: - case DeclaratorContext::ConversionIdContext: - case DeclaratorContext::TemplateArgContext: - case DeclaratorContext::TemplateTypeArgContext: - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::KNRTypeList: + case DeclaratorContext::Member: + case DeclaratorContext::Prototype: + case DeclaratorContext::LambdaExprParameter: + case DeclaratorContext::ObjCParameter: + case DeclaratorContext::ObjCResult: + case DeclaratorContext::TemplateParam: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::ObjCCatch: + case DeclaratorContext::TypeName: + case DeclaratorContext::FunctionalCast: // FIXME + case DeclaratorContext::CXXNew: + case DeclaratorContext::AliasDecl: + case DeclaratorContext::AliasTemplate: + case DeclaratorContext::BlockLiteral: + case DeclaratorContext::LambdaExpr: + case DeclaratorContext::ConversionId: + case DeclaratorContext::TemplateArg: + case DeclaratorContext::TemplateTypeArg: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::RequiresExpr: return false; } llvm_unreachable("unknown context kind!"); @@ -2352,35 +2351,35 @@ public: return false; switch (Context) { - case DeclaratorContext::FileContext: - case DeclaratorContext::MemberContext: - case DeclaratorContext::BlockContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: + case DeclaratorContext::File: + case DeclaratorContext::Member: + case DeclaratorContext::Block: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: return true; - case DeclaratorContext::ConditionContext: - case DeclaratorContext::KNRTypeListContext: - case DeclaratorContext::TypeNameContext: - case DeclaratorContext::FunctionalCastContext: - case DeclaratorContext::AliasDeclContext: - case DeclaratorContext::AliasTemplateContext: - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::LambdaExprParameterContext: - case DeclaratorContext::ObjCParameterContext: - case DeclaratorContext::ObjCResultContext: - case DeclaratorContext::TemplateParamContext: - case DeclaratorContext::CXXNewContext: - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::ObjCCatchContext: - case DeclaratorContext::BlockLiteralContext: - case DeclaratorContext::LambdaExprContext: - case DeclaratorContext::ConversionIdContext: - case DeclaratorContext::TemplateArgContext: - case DeclaratorContext::TemplateTypeArgContext: - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::TrailingReturnVarContext: - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::Condition: + case DeclaratorContext::KNRTypeList: + case DeclaratorContext::TypeName: + case DeclaratorContext::FunctionalCast: + case DeclaratorContext::AliasDecl: + case DeclaratorContext::AliasTemplate: + case DeclaratorContext::Prototype: + case DeclaratorContext::LambdaExprParameter: + case DeclaratorContext::ObjCParameter: + case DeclaratorContext::ObjCResult: + case DeclaratorContext::TemplateParam: + case DeclaratorContext::CXXNew: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::ObjCCatch: + case DeclaratorContext::BlockLiteral: + case DeclaratorContext::LambdaExpr: + case DeclaratorContext::ConversionId: + case DeclaratorContext::TemplateArg: + case DeclaratorContext::TemplateTypeArg: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::TrailingReturnVar: + case DeclaratorContext::RequiresExpr: return false; } llvm_unreachable("unknown context kind!"); @@ -2390,38 +2389,38 @@ public: /// expression could appear. bool isExpressionContext() const { switch (Context) { - case DeclaratorContext::FileContext: - case DeclaratorContext::KNRTypeListContext: - case DeclaratorContext::MemberContext: + case DeclaratorContext::File: + case DeclaratorContext::KNRTypeList: + case DeclaratorContext::Member: // FIXME: sizeof(...) permits an expression. - case DeclaratorContext::TypeNameContext: - - case DeclaratorContext::FunctionalCastContext: - case DeclaratorContext::AliasDeclContext: - case DeclaratorContext::AliasTemplateContext: - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::LambdaExprParameterContext: - case DeclaratorContext::ObjCParameterContext: - case DeclaratorContext::ObjCResultContext: - case DeclaratorContext::TemplateParamContext: - case DeclaratorContext::CXXNewContext: - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::ObjCCatchContext: - case DeclaratorContext::BlockLiteralContext: - case DeclaratorContext::LambdaExprContext: - case DeclaratorContext::ConversionIdContext: - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::TrailingReturnVarContext: - case DeclaratorContext::TemplateTypeArgContext: - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::TypeName: + + case DeclaratorContext::FunctionalCast: + case DeclaratorContext::AliasDecl: + case DeclaratorContext::AliasTemplate: + case DeclaratorContext::Prototype: + case DeclaratorContext::LambdaExprParameter: + case DeclaratorContext::ObjCParameter: + case DeclaratorContext::ObjCResult: + case DeclaratorContext::TemplateParam: + case DeclaratorContext::CXXNew: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::ObjCCatch: + case DeclaratorContext::BlockLiteral: + case DeclaratorContext::LambdaExpr: + case DeclaratorContext::ConversionId: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::TrailingReturnVar: + case DeclaratorContext::TemplateTypeArg: + case DeclaratorContext::RequiresExpr: return false; - case DeclaratorContext::BlockContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: - case DeclaratorContext::ConditionContext: - case DeclaratorContext::TemplateArgContext: + case DeclaratorContext::Block: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: + case DeclaratorContext::Condition: + case DeclaratorContext::TemplateArg: return true; } @@ -2581,7 +2580,7 @@ public: /// Returns true if this declares a real member and not a friend. bool isFirstDeclarationOfMember() { - return getContext() == DeclaratorContext::MemberContext && + return getContext() == DeclaratorContext::Member && !getDeclSpec().isFriendSpecified(); } @@ -2603,8 +2602,7 @@ struct FieldDeclarator { Declarator D; Expr *BitfieldSize; explicit FieldDeclarator(const DeclSpec &DS) - : D(DS, DeclaratorContext::MemberContext), - BitfieldSize(nullptr) {} + : D(DS, DeclaratorContext::Member), BitfieldSize(nullptr) {} }; /// Represents a C++11 virt-specifier-seq. diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 281cd6d..68ee29f 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1773,12 +1773,11 @@ bool Parser::MightBeDeclarator(DeclaratorContext Context) { return getLangOpts().CPlusPlus; case tok::l_square: // Might be an attribute on an unnamed bit-field. - return Context == DeclaratorContext::MemberContext && - getLangOpts().CPlusPlus11 && NextToken().is(tok::l_square); + return Context == DeclaratorContext::Member && getLangOpts().CPlusPlus11 && + NextToken().is(tok::l_square); case tok::colon: // Might be a typo for '::' or an unnamed bit-field. - return Context == DeclaratorContext::MemberContext || - getLangOpts().CPlusPlus; + return Context == DeclaratorContext::Member || getLangOpts().CPlusPlus; case tok::identifier: switch (NextToken().getKind()) { @@ -1804,9 +1803,8 @@ bool Parser::MightBeDeclarator(DeclaratorContext Context) { // At namespace scope, 'identifier:' is probably a typo for 'identifier::' // and in block scope it's probably a label. Inside a class definition, // this is a bit-field. - return Context == DeclaratorContext::MemberContext || - (getLangOpts().CPlusPlus && - Context == DeclaratorContext::FileContext); + return Context == DeclaratorContext::Member || + (getLangOpts().CPlusPlus && Context == DeclaratorContext::File); case tok::identifier: // Possible virt-specifier. return getLangOpts().CPlusPlus11 && isCXX11VirtSpecifier(NextToken()); @@ -1964,7 +1962,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, // Function definitions are only allowed at file scope and in C++ classes. // The C++ inline method definition case is handled elsewhere, so we only // need to handle the file scope definition case. - if (Context == DeclaratorContext::FileContext) { + if (Context == DeclaratorContext::File) { if (isStartOfFunctionDefinition(D)) { if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) { Diag(Tok, diag::err_function_declared_typedef); @@ -2043,7 +2041,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, if (FirstDecl) DeclsInGroup.push_back(FirstDecl); - bool ExpectSemi = Context != DeclaratorContext::ForContext; + bool ExpectSemi = Context != DeclaratorContext::ForInit; // If we don't have a comma, it is either the end of the list (a ';') or an // error, bail out. @@ -2094,10 +2092,10 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, if (DeclEnd) *DeclEnd = Tok.getLocation(); - if (ExpectSemi && - ExpectAndConsumeSemi(Context == DeclaratorContext::FileContext - ? diag::err_invalid_token_after_toplevel_declarator - : diag::err_expected_semi_declaration)) { + if (ExpectSemi && ExpectAndConsumeSemi( + Context == DeclaratorContext::File + ? diag::err_invalid_token_after_toplevel_declarator + : diag::err_expected_semi_declaration)) { // Okay, there was no semicolon and one was expected. If we see a // declaration specifier, just assume it was missing and continue parsing. // Otherwise things are very confused and we skip to recover. @@ -2303,8 +2301,8 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes( if (Init.isInvalid()) { SmallVector StopTokens; StopTokens.push_back(tok::comma); - if (D.getContext() == DeclaratorContext::ForContext || - D.getContext() == DeclaratorContext::InitStmtContext) + if (D.getContext() == DeclaratorContext::ForInit || + D.getContext() == DeclaratorContext::SelectionInit) StopTokens.push_back(tok::r_paren); SkipUntil(StopTokens, StopAtSemi | StopBeforeMatch); Actions.ActOnInitializerError(ThisDecl); @@ -2710,20 +2708,20 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, /// DeclaratorContext enumerator values. Parser::DeclSpecContext Parser::getDeclSpecContextFromDeclaratorContext(DeclaratorContext Context) { - if (Context == DeclaratorContext::MemberContext) + if (Context == DeclaratorContext::Member) return DeclSpecContext::DSC_class; - if (Context == DeclaratorContext::FileContext) + if (Context == DeclaratorContext::File) return DeclSpecContext::DSC_top_level; - if (Context == DeclaratorContext::TemplateParamContext) + if (Context == DeclaratorContext::TemplateParam) return DeclSpecContext::DSC_template_param; - if (Context == DeclaratorContext::TemplateArgContext || - Context == DeclaratorContext::TemplateTypeArgContext) + if (Context == DeclaratorContext::TemplateArg || + Context == DeclaratorContext::TemplateTypeArg) return DeclSpecContext::DSC_template_type_arg; - if (Context == DeclaratorContext::TrailingReturnContext || - Context == DeclaratorContext::TrailingReturnVarContext) + if (Context == DeclaratorContext::TrailingReturn || + Context == DeclaratorContext::TrailingReturnVar) return DeclSpecContext::DSC_trailing; - if (Context == DeclaratorContext::AliasDeclContext || - Context == DeclaratorContext::AliasTemplateContext) + if (Context == DeclaratorContext::AliasDecl || + Context == DeclaratorContext::AliasTemplate) return DeclSpecContext::DSC_alias_declaration; return DeclSpecContext::DSC_normal; } @@ -4474,7 +4472,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS, // declares 'enum E : int; E *p;' not 'enum E : int*; E p;'. DeclSpec DS(AttrFactory); ParseSpecifierQualifierList(DS, AS, DeclSpecContext::DSC_type_specifier); - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); BaseType = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); BaseRange = SourceRange(ColonLoc, DeclaratorInfo.getSourceRange().getEnd()); @@ -5574,9 +5572,8 @@ static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang, // (The same thing can in theory happen after a trailing-return-type, but // since those are a C++11 feature, there is no rejects-valid issue there.) if (Kind == tok::ampamp) - return Lang.CPlusPlus11 || - (TheContext != DeclaratorContext::ConversionIdContext && - TheContext != DeclaratorContext::CXXNewContext); + return Lang.CPlusPlus11 || (TheContext != DeclaratorContext::ConversionId && + TheContext != DeclaratorContext::CXXNew); return false; } @@ -5630,9 +5627,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D, (Tok.is(tok::identifier) && (NextToken().is(tok::coloncolon) || NextToken().is(tok::less))) || Tok.is(tok::annot_cxxscope))) { - bool EnteringContext = - D.getContext() == DeclaratorContext::FileContext || - D.getContext() == DeclaratorContext::MemberContext; + bool EnteringContext = D.getContext() == DeclaratorContext::File || + D.getContext() == DeclaratorContext::Member; CXXScopeSpec SS; ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr, /*ObjectHadErrors=*/false, EnteringContext); @@ -5704,7 +5700,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D, // GNU attributes are not allowed here in a new-type-id, but Declspec and // C++11 attributes are allowed. unsigned Reqs = AR_CXX11AttributesParsed | AR_DeclspecAttributesParsed | - ((D.getContext() != DeclaratorContext::CXXNewContext) + ((D.getContext() != DeclaratorContext::CXXNew) ? AR_GNUAttributesParsed : AR_GNUAttributesParsedAndRejected); ParseTypeQualifierListOpt(DS, Reqs, true, !D.mayOmitIdentifier()); @@ -5854,15 +5850,14 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // this context it is a bitfield. Also in range-based for statement colon // may delimit for-range-declaration. ColonProtectionRAIIObject X( - *this, D.getContext() == DeclaratorContext::MemberContext || - (D.getContext() == DeclaratorContext::ForContext && + *this, D.getContext() == DeclaratorContext::Member || + (D.getContext() == DeclaratorContext::ForInit && getLangOpts().CPlusPlus11)); // ParseDeclaratorInternal might already have parsed the scope. if (D.getCXXScopeSpec().isEmpty()) { - bool EnteringContext = - D.getContext() == DeclaratorContext::FileContext || - D.getContext() == DeclaratorContext::MemberContext; + bool EnteringContext = D.getContext() == DeclaratorContext::File || + D.getContext() == DeclaratorContext::Member; ParseOptionalCXXScopeSpecifier( D.getCXXScopeSpec(), /*ObjectType=*/nullptr, /*ObjectHadErrors=*/false, EnteringContext); @@ -5892,11 +5887,10 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // been expanded or contains auto; otherwise, it is parsed as part of the // parameter-declaration-clause. if (Tok.is(tok::ellipsis) && D.getCXXScopeSpec().isEmpty() && - !((D.getContext() == DeclaratorContext::PrototypeContext || - D.getContext() == DeclaratorContext::LambdaExprParameterContext || - D.getContext() == DeclaratorContext::BlockLiteralContext) && - NextToken().is(tok::r_paren) && - !D.hasGroupingParens() && + !((D.getContext() == DeclaratorContext::Prototype || + D.getContext() == DeclaratorContext::LambdaExprParameter || + D.getContext() == DeclaratorContext::BlockLiteral) && + NextToken().is(tok::r_paren) && !D.hasGroupingParens() && !Actions.containsUnexpandedParameterPacks(D) && D.getDeclSpec().getTypeSpecType() != TST_auto)) { SourceLocation EllipsisLoc = ConsumeToken(); @@ -5925,16 +5919,13 @@ void Parser::ParseDirectDeclarator(Declarator &D) { AllowConstructorName = false; AllowDeductionGuide = false; } else if (D.getCXXScopeSpec().isSet()) { - AllowConstructorName = - (D.getContext() == DeclaratorContext::FileContext || - D.getContext() == DeclaratorContext::MemberContext); + AllowConstructorName = (D.getContext() == DeclaratorContext::File || + D.getContext() == DeclaratorContext::Member); AllowDeductionGuide = false; } else { - AllowConstructorName = - (D.getContext() == DeclaratorContext::MemberContext); - AllowDeductionGuide = - (D.getContext() == DeclaratorContext::FileContext || - D.getContext() == DeclaratorContext::MemberContext); + AllowConstructorName = (D.getContext() == DeclaratorContext::Member); + AllowDeductionGuide = (D.getContext() == DeclaratorContext::File || + D.getContext() == DeclaratorContext::Member); } bool HadScope = D.getCXXScopeSpec().isValid(); @@ -5990,16 +5981,16 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // An identifier within parens is unlikely to be intended to be anything // other than a name being "declared". DiagnoseIdentifier = true; - else if (D.getContext() == DeclaratorContext::TemplateArgContext) + else if (D.getContext() == DeclaratorContext::TemplateArg) // T is an accidental identifier; T'. DiagnoseIdentifier = NextToken().isOneOf(tok::comma, tok::greater, tok::greatergreater); - else if (D.getContext() == DeclaratorContext::AliasDeclContext || - D.getContext() == DeclaratorContext::AliasTemplateContext) + else if (D.getContext() == DeclaratorContext::AliasDecl || + D.getContext() == DeclaratorContext::AliasTemplate) // The most likely error is that the ';' was forgotten. DiagnoseIdentifier = NextToken().isOneOf(tok::comma, tok::semi); - else if ((D.getContext() == DeclaratorContext::TrailingReturnContext || - D.getContext() == DeclaratorContext::TrailingReturnVarContext) && + else if ((D.getContext() == DeclaratorContext::TrailingReturn || + D.getContext() == DeclaratorContext::TrailingReturnVar) && !isCXX11VirtSpecifier(Tok)) DiagnoseIdentifier = NextToken().isOneOf( tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try); @@ -6058,7 +6049,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { LLVM_BUILTIN_TRAP; if (Tok.is(tok::l_square)) return ParseMisplacedBracketDeclarator(D); - if (D.getContext() == DeclaratorContext::MemberContext) { + if (D.getContext() == DeclaratorContext::Member) { // Objective-C++: Detect C++ keywords and try to prevent further errors by // treating these keyword as valid member names. if (getLangOpts().ObjC && getLangOpts().CPlusPlus && @@ -6349,13 +6340,14 @@ void Parser::InitCXXThisScopeForDeclaratorIfRelevant( // and the end of the function-definition, member-declarator, or // declarator. // FIXME: currently, "static" case isn't handled correctly. - bool IsCXX11MemberFunction = getLangOpts().CPlusPlus11 && - D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef && - (D.getContext() == DeclaratorContext::MemberContext - ? !D.getDeclSpec().isFriendSpecified() - : D.getContext() == DeclaratorContext::FileContext && - D.getCXXScopeSpec().isValid() && - Actions.CurContext->isRecord()); + bool IsCXX11MemberFunction = + getLangOpts().CPlusPlus11 && + D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef && + (D.getContext() == DeclaratorContext::Member + ? !D.getDeclSpec().isFriendSpecified() + : D.getContext() == DeclaratorContext::File && + D.getCXXScopeSpec().isValid() && + Actions.CurContext->isRecord()); if (!IsCXX11MemberFunction) return; @@ -6757,11 +6749,11 @@ void Parser::ParseParameterDeclarationClause( // "LambdaExprParameterContext", because we must accept either // 'declarator' or 'abstract-declarator' here. Declarator ParmDeclarator( - DS, DeclaratorCtx == DeclaratorContext::RequiresExprContext - ? DeclaratorContext::RequiresExprContext - : DeclaratorCtx == DeclaratorContext::LambdaExprContext - ? DeclaratorContext::LambdaExprParameterContext - : DeclaratorContext::PrototypeContext); + DS, DeclaratorCtx == DeclaratorContext::RequiresExpr + ? DeclaratorContext::RequiresExpr + : DeclaratorCtx == DeclaratorContext::LambdaExpr + ? DeclaratorContext::LambdaExprParameter + : DeclaratorContext::Prototype); ParseDeclarator(ParmDeclarator); // Parse GNU attributes, if present. @@ -6840,7 +6832,7 @@ void Parser::ParseParameterDeclarationClause( SourceLocation EqualLoc = Tok.getLocation(); // Parse the default argument - if (DeclaratorCtx == DeclaratorContext::MemberContext) { + if (DeclaratorCtx == DeclaratorContext::Member) { // If we're inside a class definition, cache the tokens // corresponding to the default argument. We'll actually parse // them when we see the end of the class definition. diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 6e9eced..0a810fc 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -624,8 +624,7 @@ bool Parser::ParseUsingDeclarator(DeclaratorContext Context, // or the simple-template-id's template-name in the last component of the // nested-name-specifier, the name is [...] considered to name the // constructor. - if (getLangOpts().CPlusPlus11 && - Context == DeclaratorContext::MemberContext && + if (getLangOpts().CPlusPlus11 && Context == DeclaratorContext::Member && Tok.is(tok::identifier) && (NextToken().is(tok::semi) || NextToken().is(tok::comma) || NextToken().is(tok::ellipsis)) && @@ -834,11 +833,11 @@ Decl *Parser::ParseAliasDeclarationAfterDeclarator( << FixItHint::CreateRemoval(SourceRange(D.EllipsisLoc)); Decl *DeclFromDeclSpec = nullptr; - TypeResult TypeAlias = ParseTypeName( - nullptr, - TemplateInfo.Kind ? DeclaratorContext::AliasTemplateContext - : DeclaratorContext::AliasDeclContext, - AS, &DeclFromDeclSpec, &Attrs); + TypeResult TypeAlias = + ParseTypeName(nullptr, + TemplateInfo.Kind ? DeclaratorContext::AliasTemplate + : DeclaratorContext::AliasDecl, + AS, &DeclFromDeclSpec, &Attrs); if (OwnedType) *OwnedType = DeclFromDeclSpec; @@ -1140,7 +1139,7 @@ TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc, EndLocation = ParseDecltypeSpecifier(DS); - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); } @@ -1232,7 +1231,7 @@ TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc, DS.SetTypeSpecType(TST_typename, IdLoc, PrevSpec, DiagID, Type, Actions.getASTContext().getPrintingPolicy()); - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); } @@ -2566,7 +2565,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, SourceLocation DeclEnd; return DeclGroupPtrTy::make( DeclGroupRef(ParseTemplateDeclarationOrSpecialization( - DeclaratorContext::MemberContext, DeclEnd, AccessAttrs, AS))); + DeclaratorContext::Member, DeclEnd, AccessAttrs, AS))); } // Handle: member-declaration ::= '__extension__' member-declaration @@ -2609,7 +2608,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, } SourceLocation DeclEnd; // Otherwise, it must be a using-declaration or an alias-declaration. - return ParseUsingDeclaration(DeclaratorContext::MemberContext, TemplateInfo, + return ParseUsingDeclaration(DeclaratorContext::Member, TemplateInfo, UsingLoc, DeclEnd, AS); } @@ -2657,7 +2656,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, return Actions.ConvertDeclToDeclGroup(TheDecl); } - ParsingDeclarator DeclaratorInfo(*this, DS, DeclaratorContext::MemberContext); + ParsingDeclarator DeclaratorInfo(*this, DS, DeclaratorContext::Member); if (TemplateInfo.TemplateParams) DeclaratorInfo.setTemplateParameterLists(TemplateParams); VirtSpecifiers VS; @@ -2929,7 +2928,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, break; if (Tok.isAtStartOfLine() && - !MightBeDeclarator(DeclaratorContext::MemberContext)) { + !MightBeDeclarator(DeclaratorContext::Member)) { // This comma was followed by a line-break and something which can't be // the start of a declarator. The comma was probably a typo for a // semicolon. @@ -3844,8 +3843,8 @@ TypeResult Parser::ParseTrailingReturnType(SourceRange &Range, ConsumeToken(); return ParseTypeName(&Range, MayBeFollowedByDirectInit - ? DeclaratorContext::TrailingReturnVarContext - : DeclaratorContext::TrailingReturnContext); + ? DeclaratorContext::TrailingReturnVar + : DeclaratorContext::TrailingReturn); } /// Parse a requires-clause as part of a function declaration. diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 4b38253..1475cc7 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1211,7 +1211,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind, DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ, Actions.getASTContext().getPrintingPolicy()); - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); if (Ty.isInvalid()) @@ -1485,7 +1485,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind, PrevSpec, DiagID, Type, Actions.getASTContext().getPrintingPolicy()); - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); if (Ty.isInvalid()) break; @@ -2261,7 +2261,7 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok, if (isTypeIdUnambiguously()) { DeclSpec DS(AttrFactory); ParseSpecifierQualifierList(DS); - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); ParseDeclarator(DeclaratorInfo); SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.getLocation()); @@ -2887,7 +2887,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, // Parse the type declarator. DeclSpec DS(AttrFactory); ParseSpecifierQualifierList(DS); - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); ParseDeclarator(DeclaratorInfo); // If our type is followed by an identifier and either ':' or ']', then @@ -3413,7 +3413,7 @@ void Parser::ParseBlockId(SourceLocation CaretLoc) { ParseSpecifierQualifierList(DS); // Parse the block-declarator. - Declarator DeclaratorInfo(DS, DeclaratorContext::BlockLiteralContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::BlockLiteral); DeclaratorInfo.setFunctionDefinitionKind(FDK_Definition); ParseDeclarator(DeclaratorInfo); @@ -3452,7 +3452,7 @@ ExprResult Parser::ParseBlockLiteralExpression() { // Parse the return type if present. DeclSpec DS(AttrFactory); - Declarator ParamInfo(DS, DeclaratorContext::BlockLiteralContext); + Declarator ParamInfo(DS, DeclaratorContext::BlockLiteral); ParamInfo.setFunctionDefinitionKind(FDK_Definition); // FIXME: Since the return type isn't actually parsed, it can't be used to // fill ParamInfo with an initial valid range, so do it manually. diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 8181d2a..99dd627 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -1242,7 +1242,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( // Parse lambda-declarator[opt]. DeclSpec DS(AttrFactory); - Declarator D(DS, DeclaratorContext::LambdaExprContext); + Declarator D(DS, DeclaratorContext::LambdaExpr); TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth); Actions.PushLambdaScope(); @@ -1557,7 +1557,7 @@ ExprResult Parser::ParseCXXCasts() { ParseSpecifierQualifierList(DS); // Parse the abstract-declarator, if present. - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); ParseDeclarator(DeclaratorInfo); SourceLocation RAngleBracketLoc = Tok.getLocation(); @@ -1883,7 +1883,7 @@ ExprResult Parser::ParseCXXThis() { /// In C++1z onwards, the type specifier can also be a template-name. ExprResult Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) { - Declarator DeclaratorInfo(DS, DeclaratorContext::FunctionalCastContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::FunctionalCast); ParsedType TypeRep = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get(); assert((Tok.is(tok::l_paren) || @@ -2031,9 +2031,8 @@ Sema::ConditionResult Parser::ParseCXXCondition(StmtResult *InitStmt, case ConditionOrInitStatement::InitStmtDecl: { WarnOnInit(); SourceLocation DeclStart = Tok.getLocation(), DeclEnd; - DeclGroupPtrTy DG = - ParseSimpleDeclaration(DeclaratorContext::InitStmtContext, DeclEnd, - attrs, /*RequireSemi=*/true); + DeclGroupPtrTy DG = ParseSimpleDeclaration( + DeclaratorContext::SelectionInit, DeclEnd, attrs, /*RequireSemi=*/true); *InitStmt = Actions.ActOnDeclStmt(DG, DeclStart, DeclEnd); return ParseCXXCondition(nullptr, Loc, CK); } @@ -2041,8 +2040,8 @@ Sema::ConditionResult Parser::ParseCXXCondition(StmtResult *InitStmt, case ConditionOrInitStatement::ForRangeDecl: { assert(FRI && "should not parse a for range declaration here"); SourceLocation DeclStart = Tok.getLocation(), DeclEnd; - DeclGroupPtrTy DG = ParseSimpleDeclaration( - DeclaratorContext::ForContext, DeclEnd, attrs, false, FRI); + DeclGroupPtrTy DG = ParseSimpleDeclaration(DeclaratorContext::ForInit, + DeclEnd, attrs, false, FRI); FRI->LoopVar = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation()); return Sema::ConditionResult(); } @@ -2058,7 +2057,7 @@ Sema::ConditionResult Parser::ParseCXXCondition(StmtResult *InitStmt, ParseSpecifierQualifierList(DS, AS_none, DeclSpecContext::DSC_condition); // declarator - Declarator DeclaratorInfo(DS, DeclaratorContext::ConditionContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::Condition); ParseDeclarator(DeclaratorInfo); // simple-asm-expr[opt] @@ -2699,7 +2698,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, // Parse the conversion-declarator, which is merely a sequence of // ptr-operators. - Declarator D(DS, DeclaratorContext::ConversionIdContext); + Declarator D(DS, DeclaratorContext::ConversionId); ParseDeclaratorInternal(D, /*DirectDeclParser=*/nullptr); // Finish up the type. @@ -3057,7 +3056,7 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) { SourceRange TypeIdParens; DeclSpec DS(AttrFactory); - Declarator DeclaratorInfo(DS, DeclaratorContext::CXXNewContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::CXXNew); if (Tok.is(tok::l_paren)) { // If it turns out to be a placement, we change the type location. BalancedDelimiterTracker T(*this, tok::l_paren); @@ -3379,7 +3378,7 @@ ExprResult Parser::ParseRequiresExpression() { ParsedAttributes FirstArgAttrs(getAttrFactory()); SourceLocation EllipsisLoc; llvm::SmallVector LocalParameters; - ParseParameterDeclarationClause(DeclaratorContext::RequiresExprContext, + ParseParameterDeclarationClause(DeclaratorContext::RequiresExpr, FirstArgAttrs, LocalParameters, EllipsisLoc); if (EllipsisLoc.isValid()) @@ -3907,7 +3906,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, if (ParseAs >= CompoundLiteral) { // Parse the type declarator. DeclSpec DS(AttrFactory); - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); { ColonProtectionRAIIObject InnerColonProtection(*this); ParseSpecifierQualifierList(DS); @@ -3985,7 +3984,7 @@ ExprResult Parser::ParseBuiltinBitCast() { ParseSpecifierQualifierList(DS); // Parse the abstract-declarator, if present. - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); ParseDeclarator(DeclaratorInfo); if (ExpectAndConsume(tok::comma)) { diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index eaea866..88942ed 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -657,7 +657,7 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey, if (Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) { SourceLocation DeclEnd; allTUVariables.push_back( - ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs)); + ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs)); continue; } @@ -1141,13 +1141,13 @@ bool Parser::isTokIdentifier_in() const { /// void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS, DeclaratorContext Context) { - assert(Context == DeclaratorContext::ObjCParameterContext || - Context == DeclaratorContext::ObjCResultContext); + assert(Context == DeclaratorContext::ObjCParameter || + Context == DeclaratorContext::ObjCResult); while (1) { if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteObjCPassingType(getCurScope(), DS, - Context == DeclaratorContext::ObjCParameterContext); + Actions.CodeCompleteObjCPassingType( + getCurScope(), DS, Context == DeclaratorContext::ObjCParameter); return cutOffParsing(); } @@ -1237,10 +1237,10 @@ static void takeDeclAttributes(ParsedAttributes &attrs, ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, DeclaratorContext context, ParsedAttributes *paramAttrs) { - assert(context == DeclaratorContext::ObjCParameterContext || - context == DeclaratorContext::ObjCResultContext); + assert(context == DeclaratorContext::ObjCParameter || + context == DeclaratorContext::ObjCResult); assert((paramAttrs != nullptr) == - (context == DeclaratorContext::ObjCParameterContext)); + (context == DeclaratorContext::ObjCParameter)); assert(Tok.is(tok::l_paren) && "expected ("); @@ -1259,7 +1259,7 @@ ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, DeclSpec declSpec(AttrFactory); declSpec.setObjCQualifiers(&DS); DeclSpecContext dsContext = DeclSpecContext::DSC_normal; - if (context == DeclaratorContext::ObjCResultContext) + if (context == DeclaratorContext::ObjCResult) dsContext = DeclSpecContext::DSC_objc_method_result; ParseSpecifierQualifierList(declSpec, AS_none, dsContext); Declarator declarator(declSpec, context); @@ -1281,7 +1281,7 @@ ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, // If we're parsing a parameter, steal all the decl attributes // and add them to the decl spec. - if (context == DeclaratorContext::ObjCParameterContext) + if (context == DeclaratorContext::ObjCParameter) takeDeclAttributes(*paramAttrs, declarator); } } @@ -1345,8 +1345,8 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, ParsedType ReturnType; ObjCDeclSpec DSRet; if (Tok.is(tok::l_paren)) - ReturnType = ParseObjCTypeName(DSRet, DeclaratorContext::ObjCResultContext, - nullptr); + ReturnType = + ParseObjCTypeName(DSRet, DeclaratorContext::ObjCResult, nullptr); // If attributes exist before the method, parse them. ParsedAttributes methodAttrs(AttrFactory); @@ -1407,9 +1407,8 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, ArgInfo.Type = nullptr; if (Tok.is(tok::l_paren)) // Parse the argument type if present. - ArgInfo.Type = ParseObjCTypeName(ArgInfo.DeclSpec, - DeclaratorContext::ObjCParameterContext, - ¶mAttrs); + ArgInfo.Type = ParseObjCTypeName( + ArgInfo.DeclSpec, DeclaratorContext::ObjCParameter, ¶mAttrs); // If attributes exist before the argument name, parse them. // Regardless, collect all the attributes we've parsed so far. @@ -1485,7 +1484,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, DeclSpec DS(AttrFactory); ParseDeclarationSpecifiers(DS); // Parse the declarator. - Declarator ParmDecl(DS, DeclaratorContext::PrototypeContext); + Declarator ParmDecl(DS, DeclaratorContext::Prototype); ParseDeclarator(ParmDecl); IdentifierInfo *ParmII = ParmDecl.getIdentifier(); Decl *Param = Actions.ActOnParamDeclarator(getCurScope(), ParmDecl); @@ -1692,7 +1691,7 @@ void Parser::parseObjCTypeArgsOrProtocolQualifiers( typeArg, Actions.getASTContext().getPrintingPolicy()); // Form a declarator to turn this into a type. - Declarator D(DS, DeclaratorContext::TypeNameContext); + Declarator D(DS, DeclaratorContext::TypeName); TypeResult fullTypeArg = Actions.ActOnTypeName(getCurScope(), D); if (fullTypeArg.isUsable()) { typeArgs.push_back(fullTypeArg.get()); @@ -2536,7 +2535,7 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { if (Tok.isNot(tok::ellipsis)) { DeclSpec DS(AttrFactory); ParseDeclarationSpecifiers(DS); - Declarator ParmDecl(DS, DeclaratorContext::ObjCCatchContext); + Declarator ParmDecl(DS, DeclaratorContext::ObjCCatch); ParseDeclarator(ParmDecl); // Inform the actions module about the declarator, so it @@ -2952,7 +2951,7 @@ bool Parser::ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr) { // 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. - Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeName); TypeResult Type = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); if (Type.isInvalid()) return true; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index a82961c..6f5ec06 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -297,8 +297,7 @@ Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) { do { ColonProtectionRAIIObject ColonRAII(*this); SourceRange Range; - TypeResult TR = - ParseTypeName(&Range, DeclaratorContext::PrototypeContext, AS); + TypeResult TR = ParseTypeName(&Range, DeclaratorContext::Prototype, AS); if (TR.isUsable()) { QualType ReductionType = Actions.ActOnOpenMPDeclareReductionType(Range.getBegin(), TR); @@ -624,7 +623,7 @@ TypeResult Parser::parseOpenMPDeclareMapperVarDecl(SourceRange &Range, ParseSpecifierQualifierList(DS, AS, DSC); // Parse the declarator. - DeclaratorContext Context = DeclaratorContext::PrototypeContext; + DeclaratorContext Context = DeclaratorContext::Prototype; Declarator DeclaratorInfo(DS, Context); ParseDeclarator(DeclaratorInfo); Range = DeclaratorInfo.getSourceRange(); diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index a48db31..26a0257 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -215,11 +215,10 @@ Retry: DeclGroupPtrTy Decl; if (GNUAttributeLoc.isValid()) { DeclStart = GNUAttributeLoc; - Decl = ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, Attrs, + Decl = ParseDeclaration(DeclaratorContext::Block, DeclEnd, Attrs, &GNUAttributeLoc); } else { - Decl = - ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, Attrs); + Decl = ParseDeclaration(DeclaratorContext::Block, DeclEnd, Attrs); } if (Attrs.Range.getBegin().isValid()) DeclStart = Attrs.Range.getBegin(); @@ -1119,7 +1118,7 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { SourceLocation DeclStart = Tok.getLocation(), DeclEnd; DeclGroupPtrTy Res = - ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, attrs); + ParseDeclaration(DeclaratorContext::Block, DeclEnd, attrs); R = Actions.ActOnDeclStmt(Res, DeclStart, DeclEnd); } else { // Otherwise this was a unary __extension__ marker. @@ -1872,7 +1871,7 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) { SourceLocation DeclStart = Tok.getLocation(), DeclEnd; DeclGroupPtrTy DG = ParseSimpleDeclaration( - DeclaratorContext::ForContext, DeclEnd, attrs, false, + DeclaratorContext::ForInit, DeclEnd, attrs, false, MightBeForRangeStmt ? &ForRangeInfo : nullptr); FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation()); if (ForRangeInfo.ParsedForRangeDecl()) { @@ -2471,7 +2470,7 @@ StmtResult Parser::ParseCXXCatchBlock(bool FnCatch) { if (ParseCXXTypeSpecifierSeq(DS)) return StmtError(); - Declarator ExDecl(DS, DeclaratorContext::CXXCatchContext); + Declarator ExDecl(DS, DeclaratorContext::CXXCatch); ParseDeclarator(ExDecl); ExceptionDecl = Actions.ActOnExceptionDeclarator(getCurScope(), ExDecl); } else diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp index 3ef73f5..09ffc42 100644 --- a/clang/lib/Parse/ParseTemplate.cpp +++ b/clang/lib/Parse/ParseTemplate.cpp @@ -198,7 +198,7 @@ Decl *Parser::ParseSingleDeclarationAfterTemplate( return ParseStaticAssertDeclaration(DeclEnd); } - if (Context == DeclaratorContext::MemberContext) { + if (Context == DeclaratorContext::Member) { // We are parsing a member template. ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo, &DiagsFromTParams); @@ -279,7 +279,7 @@ Decl *Parser::ParseSingleDeclarationAfterTemplate( // Function definitions are only allowed at file scope and in C++ classes. // The C++ inline method definition case is handled elsewhere, so we only // need to handle the file scope definition case. - if (Context != DeclaratorContext::FileContext) { + if (Context != DeclaratorContext::File) { Diag(Tok, diag::err_function_definition_not_allowed); SkipMalformedDecl(); return nullptr; @@ -646,7 +646,7 @@ NamedDecl *Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) { // probably meant to write the type of a NTTP. DeclSpec DS(getAttrFactory()); DS.SetTypeSpecError(); - Declarator D(DS, DeclaratorContext::TemplateParamContext); + Declarator D(DS, DeclaratorContext::TemplateParam); D.SetIdentifier(nullptr, Tok.getLocation()); D.setInvalidType(true); NamedDecl *ErrorParam = Actions.ActOnNonTypeTemplateParameter( @@ -821,9 +821,9 @@ NamedDecl *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) { SourceLocation EqualLoc; ParsedType DefaultArg; if (TryConsumeToken(tok::equal, EqualLoc)) - DefaultArg = ParseTypeName(/*Range=*/nullptr, - DeclaratorContext::TemplateTypeArgContext) - .get(); + DefaultArg = + ParseTypeName(/*Range=*/nullptr, DeclaratorContext::TemplateTypeArg) + .get(); NamedDecl *NewDecl = Actions.ActOnTypeParameter(getCurScope(), TypenameKeyword, EllipsisLoc, @@ -967,7 +967,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) { DeclSpecContext::DSC_template_param); // Parse this as a typename. - Declarator ParamDecl(DS, DeclaratorContext::TemplateParamContext); + Declarator ParamDecl(DS, DeclaratorContext::TemplateParam); ParseDeclarator(ParamDecl); if (DS.getTypeSpecType() == DeclSpec::TST_unspecified) { Diag(Tok.getLocation(), diag::err_expected_template_parameter); @@ -1527,7 +1527,7 @@ ParsedTemplateArgument Parser::ParseTemplateArgument() { /*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument); if (isCXXTypeId(TypeIdAsTemplateArgument)) { TypeResult TypeArg = ParseTypeName( - /*Range=*/nullptr, DeclaratorContext::TemplateArgContext); + /*Range=*/nullptr, DeclaratorContext::TemplateArg); return Actions.ActOnTemplateTypeArgument(TypeArg); } diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 109f244..825e004 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -901,7 +901,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, // A function definition cannot start with any of these keywords. { SourceLocation DeclEnd; - return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); + return ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs); } case tok::kw_static: @@ -911,7 +911,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, Diag(ConsumeToken(), diag::warn_static_inline_explicit_inst_ignored) << 0; SourceLocation DeclEnd; - return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); + return ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs); } goto dont_know; @@ -922,7 +922,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, // Inline namespaces. Allowed as an extension even in C++03. if (NextKind == tok::kw_namespace) { SourceLocation DeclEnd; - return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); + return ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs); } // Parse (then ignore) 'inline' prior to a template instantiation. This is @@ -931,7 +931,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, Diag(ConsumeToken(), diag::warn_static_inline_explicit_inst_ignored) << 1; SourceLocation DeclEnd; - return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); + return ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs); } } goto dont_know; @@ -945,9 +945,8 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, diag::warn_cxx98_compat_extern_template : diag::ext_extern_template) << SourceRange(ExternLoc, TemplateLoc); SourceLocation DeclEnd; - return Actions.ConvertDeclToDeclGroup( - ParseExplicitInstantiation(DeclaratorContext::FileContext, ExternLoc, - TemplateLoc, DeclEnd, attrs)); + return Actions.ConvertDeclToDeclGroup(ParseExplicitInstantiation( + DeclaratorContext::File, ExternLoc, TemplateLoc, DeclEnd, attrs)); } goto dont_know; @@ -1128,11 +1127,11 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs, if (getLangOpts().CPlusPlus && isTokenStringLiteral() && DS.getStorageClassSpec() == DeclSpec::SCS_extern && DS.getParsedSpecifiers() == DeclSpec::PQ_StorageClassSpecifier) { - Decl *TheDecl = ParseLinkage(DS, DeclaratorContext::FileContext); + Decl *TheDecl = ParseLinkage(DS, DeclaratorContext::File); return Actions.ConvertDeclToDeclGroup(TheDecl); } - return ParseDeclGroup(DS, DeclaratorContext::FileContext); + return ParseDeclGroup(DS, DeclaratorContext::File); } Parser::DeclGroupPtrTy @@ -1441,7 +1440,7 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { } // Parse the first declarator attached to this declspec. - Declarator ParmDeclarator(DS, DeclaratorContext::KNRTypeListContext); + Declarator ParmDeclarator(DS, DeclaratorContext::KNRTypeList); ParseDeclarator(ParmDeclarator); // Handle the full declarator list. diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index b139855..8831cb5 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -408,7 +408,7 @@ bool Declarator::isDeclarationOfFunction() const { } bool Declarator::isStaticMember() { - assert(getContext() == DeclaratorContext::MemberContext); + assert(getContext() == DeclaratorContext::Member); return getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static || (getName().Kind == UnqualifiedIdKind::IK_OperatorFunctionId && CXXMethodDecl::isStaticOverloadedOperator( diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index cf38b10..5f04997 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -5395,8 +5395,8 @@ void Sema::CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, AddTypeQualifierResults(DS, Results, LangOpts); if (LangOpts.CPlusPlus11) { Results.AddResult("noexcept"); - if (D.getContext() == DeclaratorContext::MemberContext && - !D.isCtorOrDtor() && !D.isStaticMember()) { + if (D.getContext() == DeclaratorContext::Member && !D.isCtorOrDtor() && + !D.isStaticMember()) { if (!VS || !VS->isFinalSpecified()) Results.AddResult("final"); if (!VS || !VS->isOverrideSpecified()) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1afb4dc..02dfbd4 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5160,7 +5160,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, Diag(DS.getBeginLoc(), diag::ext_no_declarators) << DS.getSourceRange(); // Mock up a declarator. - Declarator Dc(DS, DeclaratorContext::MemberContext); + Declarator Dc(DS, DeclaratorContext::Member); TypeSourceInfo *TInfo = GetTypeForDeclarator(Dc, S); assert(TInfo && "couldn't build declarator info for anonymous struct/union"); @@ -5257,7 +5257,7 @@ Decl *Sema::BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, assert(Record && "expected a record!"); // Mock up a declarator. - Declarator Dc(DS, DeclaratorContext::TypeNameContext); + Declarator Dc(DS, DeclaratorContext::TypeName); TypeSourceInfo *TInfo = GetTypeForDeclarator(Dc, S); assert(TInfo && "couldn't build declarator info for anonymous struct"); @@ -12778,7 +12778,7 @@ Sema::ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, DS.SetTypeSpecType(DeclSpec::TST_auto, IdentLoc, PrevSpec, DiagID, getPrintingPolicy()); - Declarator D(DS, DeclaratorContext::ForContext); + Declarator D(DS, DeclaratorContext::ForInit); D.SetIdentifier(Ident, IdentLoc); D.takeAttributes(Attrs, AttrEnd); @@ -13758,7 +13758,7 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, // Use the identifier location for the type source range. DS.SetRangeStart(FTI.Params[i].IdentLoc); DS.SetRangeEnd(FTI.Params[i].IdentLoc); - Declarator ParamD(DS, DeclaratorContext::KNRTypeListContext); + Declarator ParamD(DS, DeclaratorContext::KNRTypeList); ParamD.SetIdentifier(FTI.Params[i].Ident, FTI.Params[i].IdentLoc); FTI.Params[i].Param = ActOnParamDeclarator(S, ParamD); } @@ -14695,7 +14695,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, (void)Error; // Silence warning. assert(!Error && "Error setting up implicit decl!"); SourceLocation NoLoc; - Declarator D(DS, DeclaratorContext::BlockContext); + Declarator D(DS, DeclaratorContext::Block); D.AddTypeInfo(DeclaratorChunk::getFunction(/*HasProto=*/false, /*IsAmbiguous=*/false, /*LParenLoc=*/NoLoc, diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 2b1481e..ebda013 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -734,7 +734,7 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, Diag(Decomp.getLSquareLoc(), !getLangOpts().CPlusPlus17 ? diag::ext_decomp_decl - : D.getContext() == DeclaratorContext::ConditionContext + : D.getContext() == DeclaratorContext::Condition ? diag::ext_decomp_decl_cond : diag::warn_cxx14_compat_decomp_decl) << Decomp.getSourceRange(); @@ -16331,7 +16331,7 @@ Decl *Sema::ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, // Try to convert the decl specifier to a type. This works for // friend templates because ActOnTag never produces a ClassTemplateDecl // for a TUK_Friend. - Declarator TheDeclarator(DS, DeclaratorContext::MemberContext); + Declarator TheDeclarator(DS, DeclaratorContext::Member); TypeSourceInfo *TSI = GetTypeForDeclarator(TheDeclarator, S); QualType T = TSI->getType(); if (TheDeclarator.isInvalidType()) diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 733a50e..a489196 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1586,7 +1586,7 @@ void Sema::actOnObjCTypeArgsOrProtocolQualifiers( DS.SetRangeEnd(loc); // Form the declarator. - Declarator D(DS, DeclaratorContext::TypeNameContext); + Declarator D(DS, DeclaratorContext::TypeName); // If we have a typedef of an Objective-C class type that is missing a '*', // add the '*'. diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 99a3e77..3dedb3e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -15091,7 +15091,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope) { assert(ParamInfo.getIdentifier() == nullptr && "block-id should have no identifier!"); - assert(ParamInfo.getContext() == DeclaratorContext::BlockLiteralContext); + assert(ParamInfo.getContext() == DeclaratorContext::BlockLiteral); BlockScopeInfo *CurBlock = getCurBlock(); TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 21aa208..3203e13 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -50,7 +50,7 @@ enum TypeDiagSelector { /// isOmittedBlockReturnType - Return true if this declarator is missing a /// return type because this is a omitted return type on a block literal. static bool isOmittedBlockReturnType(const Declarator &D) { - if (D.getContext() != DeclaratorContext::BlockLiteralContext || + if (D.getContext() != DeclaratorContext::BlockLiteral || D.getDeclSpec().hasTypeSpecifier()) return false; @@ -1348,12 +1348,11 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { // The declspec is always missing in a lambda expr context; it is either // specified with a trailing return type or inferred. if (S.getLangOpts().CPlusPlus14 && - declarator.getContext() == DeclaratorContext::LambdaExprContext) { + declarator.getContext() == DeclaratorContext::LambdaExpr) { // In C++1y, a lambda's implicit return type is 'auto'. Result = Context.getAutoDeductType(); break; - } else if (declarator.getContext() == - DeclaratorContext::LambdaExprContext || + } else if (declarator.getContext() == DeclaratorContext::LambdaExpr || checkOmittedBlockReturnType(S, declarator, Context.DependentTy)) { Result = Context.DependentTy; @@ -1741,7 +1740,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { // Before we process any type attributes, synthesize a block literal // function declarator if necessary. - if (declarator.getContext() == DeclaratorContext::BlockLiteralContext) + if (declarator.getContext() == DeclaratorContext::BlockLiteral) maybeSynthesizeBlockSignature(state, Result); // Apply any type attributes from the decl spec. This may cause the @@ -3306,21 +3305,21 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, bool IsDeducedReturnType = false; switch (D.getContext()) { - case DeclaratorContext::LambdaExprContext: + case DeclaratorContext::LambdaExpr: // Declared return type of a lambda-declarator is implicit and is always // 'auto'. break; - case DeclaratorContext::ObjCParameterContext: - case DeclaratorContext::ObjCResultContext: + case DeclaratorContext::ObjCParameter: + case DeclaratorContext::ObjCResult: Error = 0; break; - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::RequiresExpr: Error = 22; break; - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::LambdaExprParameterContext: { + case DeclaratorContext::Prototype: + case DeclaratorContext::LambdaExprParameter: { InventedTemplateParameterInfo *Info = nullptr; - if (D.getContext() == DeclaratorContext::PrototypeContext) { + if (D.getContext() == DeclaratorContext::Prototype) { // With concepts we allow 'auto' in function parameters. if (!SemaRef.getLangOpts().CPlusPlus20 || !Auto || Auto->getKeyword() != AutoTypeKeyword::Auto) { @@ -3350,7 +3349,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, T = InventTemplateParameter(state, T, nullptr, Auto, *Info).first; break; } - case DeclaratorContext::MemberContext: { + case DeclaratorContext::Member: { if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static || D.isFunctionDeclarator()) break; @@ -3370,21 +3369,21 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, Error = 20; // Friend type break; } - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::ObjCCatchContext: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::ObjCCatch: Error = 7; // Exception declaration break; - case DeclaratorContext::TemplateParamContext: + case DeclaratorContext::TemplateParam: if (isa(Deduced) && !SemaRef.getLangOpts().CPlusPlus20) Error = 19; // Template parameter (until C++20) else if (!SemaRef.getLangOpts().CPlusPlus17) Error = 8; // Template parameter (until C++17) break; - case DeclaratorContext::BlockLiteralContext: + case DeclaratorContext::BlockLiteral: Error = 9; // Block literal break; - case DeclaratorContext::TemplateArgContext: + case DeclaratorContext::TemplateArg: // Within a template argument list, a deduced template specialization // type will be reinterpreted as a template template argument. if (isa(Deduced) && @@ -3392,47 +3391,47 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, D.getDeclSpec().getParsedSpecifiers() == DeclSpec::PQ_TypeSpecifier) break; LLVM_FALLTHROUGH; - case DeclaratorContext::TemplateTypeArgContext: + case DeclaratorContext::TemplateTypeArg: Error = 10; // Template type argument break; - case DeclaratorContext::AliasDeclContext: - case DeclaratorContext::AliasTemplateContext: + case DeclaratorContext::AliasDecl: + case DeclaratorContext::AliasTemplate: Error = 12; // Type alias break; - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::TrailingReturnVarContext: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::TrailingReturnVar: if (!SemaRef.getLangOpts().CPlusPlus14 || !IsCXXAutoType) Error = 13; // Function return type IsDeducedReturnType = true; break; - case DeclaratorContext::ConversionIdContext: + case DeclaratorContext::ConversionId: if (!SemaRef.getLangOpts().CPlusPlus14 || !IsCXXAutoType) Error = 14; // conversion-type-id IsDeducedReturnType = true; break; - case DeclaratorContext::FunctionalCastContext: + case DeclaratorContext::FunctionalCast: if (isa(Deduced)) break; LLVM_FALLTHROUGH; - case DeclaratorContext::TypeNameContext: + case DeclaratorContext::TypeName: Error = 15; // Generic break; - case DeclaratorContext::FileContext: - case DeclaratorContext::BlockContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: - case DeclaratorContext::ConditionContext: + case DeclaratorContext::File: + case DeclaratorContext::Block: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: + case DeclaratorContext::Condition: // FIXME: P0091R3 (erroneously) does not permit class template argument // deduction in conditions, for-init-statements, and other declarations // that are not simple-declarations. break; - case DeclaratorContext::CXXNewContext: + case DeclaratorContext::CXXNew: // FIXME: P0091R3 does not permit class template argument deduction here, // but we follow GCC and allow it anyway. if (!IsCXXAutoType && !isa(Deduced)) Error = 17; // 'new' type break; - case DeclaratorContext::KNRTypeListContext: + case DeclaratorContext::KNRTypeList: Error = 18; // K&R function parameter break; } @@ -3475,16 +3474,15 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, T = SemaRef.Context.IntTy; D.setInvalidType(true); - } else if (Auto && D.getContext() != DeclaratorContext::LambdaExprContext) { + } else if (Auto && D.getContext() != DeclaratorContext::LambdaExpr) { // If there was a trailing return type, we already got // warn_cxx98_compat_trailing_return_type in the parser. SemaRef.Diag(AutoRange.getBegin(), - D.getContext() == - DeclaratorContext::LambdaExprParameterContext + D.getContext() == DeclaratorContext::LambdaExprParameter ? diag::warn_cxx11_compat_generic_lambda - : IsDeducedReturnType - ? diag::warn_cxx11_compat_deduced_return_type - : diag::warn_cxx98_compat_auto_type_specifier) + : IsDeducedReturnType + ? diag::warn_cxx11_compat_deduced_return_type + : diag::warn_cxx98_compat_auto_type_specifier) << AutoRange; } } @@ -3495,50 +3493,50 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, // or enumeration in a type-specifier-seq. unsigned DiagID = 0; switch (D.getContext()) { - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::TrailingReturnVarContext: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::TrailingReturnVar: // Class and enumeration definitions are syntactically not allowed in // trailing return types. llvm_unreachable("parser should not have allowed this"); break; - case DeclaratorContext::FileContext: - case DeclaratorContext::MemberContext: - case DeclaratorContext::BlockContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: - case DeclaratorContext::BlockLiteralContext: - case DeclaratorContext::LambdaExprContext: + case DeclaratorContext::File: + case DeclaratorContext::Member: + case DeclaratorContext::Block: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: + case DeclaratorContext::BlockLiteral: + case DeclaratorContext::LambdaExpr: // C++11 [dcl.type]p3: // A type-specifier-seq shall not define a class or enumeration unless // it appears in the type-id of an alias-declaration (7.1.3) that is not // the declaration of a template-declaration. - case DeclaratorContext::AliasDeclContext: + case DeclaratorContext::AliasDecl: break; - case DeclaratorContext::AliasTemplateContext: + case DeclaratorContext::AliasTemplate: DiagID = diag::err_type_defined_in_alias_template; break; - case DeclaratorContext::TypeNameContext: - case DeclaratorContext::FunctionalCastContext: - case DeclaratorContext::ConversionIdContext: - case DeclaratorContext::TemplateParamContext: - case DeclaratorContext::CXXNewContext: - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::ObjCCatchContext: - case DeclaratorContext::TemplateArgContext: - case DeclaratorContext::TemplateTypeArgContext: + case DeclaratorContext::TypeName: + case DeclaratorContext::FunctionalCast: + case DeclaratorContext::ConversionId: + case DeclaratorContext::TemplateParam: + case DeclaratorContext::CXXNew: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::ObjCCatch: + case DeclaratorContext::TemplateArg: + case DeclaratorContext::TemplateTypeArg: DiagID = diag::err_type_defined_in_type_specifier; break; - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::LambdaExprParameterContext: - case DeclaratorContext::ObjCParameterContext: - case DeclaratorContext::ObjCResultContext: - case DeclaratorContext::KNRTypeListContext: - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::Prototype: + case DeclaratorContext::LambdaExprParameter: + case DeclaratorContext::ObjCParameter: + case DeclaratorContext::ObjCResult: + case DeclaratorContext::KNRTypeList: + case DeclaratorContext::RequiresExpr: // C++ [dcl.fct]p6: // Types shall not be defined in return or parameter types. DiagID = diag::err_type_defined_in_param_type; break; - case DeclaratorContext::ConditionContext: + case DeclaratorContext::Condition: // C++ 6.4p2: // The type-specifier-seq shall not contain typedef and shall not declare // a new class or enumeration. @@ -3587,7 +3585,7 @@ static void warnAboutAmbiguousFunction(Sema &S, Declarator &D, // Inside a condition, a direct initializer is not permitted. We allow one to // be parsed in order to give better diagnostics in condition parsing. - if (D.getContext() == DeclaratorContext::ConditionContext) + if (D.getContext() == DeclaratorContext::Condition) return; SourceRange ParenRange(DeclType.Loc, DeclType.EndLoc); @@ -3703,7 +3701,7 @@ static void warnAboutRedundantParens(Sema &S, Declarator &D, QualType T) { case DeclaratorChunk::Function: // In a new-type-id, function chunks require parentheses. - if (D.getContext() == DeclaratorContext::CXXNewContext) + if (D.getContext() == DeclaratorContext::CXXNew) return; // FIXME: "A(f())" deserves a vexing-parse warning, not just a // redundant-parens warning, but we don't know whether the function @@ -3820,7 +3818,7 @@ static CallingConv getCCForDeclaratorChunk( // in a member pointer. IsCXXInstanceMethod = D.getTypeObject(I).Kind == DeclaratorChunk::MemberPointer; - } else if (D.getContext() == DeclaratorContext::LambdaExprContext) { + } else if (D.getContext() == DeclaratorContext::LambdaExpr) { // This can only be a call operator for a lambda, which is an instance // method. IsCXXInstanceMethod = true; @@ -4362,9 +4360,9 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // Does this declaration declare a typedef-name? bool IsTypedefName = - D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef || - D.getContext() == DeclaratorContext::AliasDeclContext || - D.getContext() == DeclaratorContext::AliasTemplateContext; + D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef || + D.getContext() == DeclaratorContext::AliasDecl || + D.getContext() == DeclaratorContext::AliasTemplate; // Does T refer to a function type with a cv-qualifier or a ref-qualifier? bool IsQualifiedFunction = T->isFunctionProtoType() && @@ -4493,15 +4491,15 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, } else { bool isFunctionOrMethod = false; switch (auto context = state.getDeclarator().getContext()) { - case DeclaratorContext::ObjCParameterContext: - case DeclaratorContext::ObjCResultContext: - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::TrailingReturnVarContext: + case DeclaratorContext::ObjCParameter: + case DeclaratorContext::ObjCResult: + case DeclaratorContext::Prototype: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::TrailingReturnVar: isFunctionOrMethod = true; LLVM_FALLTHROUGH; - case DeclaratorContext::MemberContext: + case DeclaratorContext::Member: if (state.getDeclarator().isObjCIvar() && !isFunctionOrMethod) { complainAboutMissingNullability = CAMN_No; break; @@ -4515,8 +4513,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, LLVM_FALLTHROUGH; - case DeclaratorContext::FileContext: - case DeclaratorContext::KNRTypeListContext: { + case DeclaratorContext::File: + case DeclaratorContext::KNRTypeList: { complainAboutMissingNullability = CAMN_Yes; // Nullability inference depends on the type and declarator. @@ -4532,9 +4530,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (inAssumeNonNullRegion) { complainAboutInferringWithinChunk = wrappingKind; inferNullability = NullabilityKind::NonNull; - inferNullabilityCS = - (context == DeclaratorContext::ObjCParameterContext || - context == DeclaratorContext::ObjCResultContext); + inferNullabilityCS = (context == DeclaratorContext::ObjCParameter || + context == DeclaratorContext::ObjCResult); } break; @@ -4570,28 +4567,28 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, break; } - case DeclaratorContext::ConversionIdContext: + case DeclaratorContext::ConversionId: complainAboutMissingNullability = CAMN_Yes; break; - case DeclaratorContext::AliasDeclContext: - case DeclaratorContext::AliasTemplateContext: - case DeclaratorContext::BlockContext: - case DeclaratorContext::BlockLiteralContext: - case DeclaratorContext::ConditionContext: - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::CXXNewContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: - case DeclaratorContext::LambdaExprContext: - case DeclaratorContext::LambdaExprParameterContext: - case DeclaratorContext::ObjCCatchContext: - case DeclaratorContext::TemplateParamContext: - case DeclaratorContext::TemplateArgContext: - case DeclaratorContext::TemplateTypeArgContext: - case DeclaratorContext::TypeNameContext: - case DeclaratorContext::FunctionalCastContext: - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::AliasDecl: + case DeclaratorContext::AliasTemplate: + case DeclaratorContext::Block: + case DeclaratorContext::BlockLiteral: + case DeclaratorContext::Condition: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::CXXNew: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: + case DeclaratorContext::LambdaExpr: + case DeclaratorContext::LambdaExprParameter: + case DeclaratorContext::ObjCCatch: + case DeclaratorContext::TemplateParam: + case DeclaratorContext::TemplateArg: + case DeclaratorContext::TemplateTypeArg: + case DeclaratorContext::TypeName: + case DeclaratorContext::FunctionalCast: + case DeclaratorContext::RequiresExpr: // Don't infer in these contexts. break; } @@ -4828,7 +4825,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // array type, ... if (ASM == ArrayType::Static || ATI.TypeQuals) { if (!(D.isPrototypeContext() || - D.getContext() == DeclaratorContext::KNRTypeListContext)) { + D.getContext() == DeclaratorContext::KNRTypeList)) { S.Diag(DeclType.Loc, diag::err_array_static_outside_prototype) << (ASM == ArrayType::Static ? "'static'" : "type qualifier"); // Remove the 'static' and the type qualifiers. @@ -4852,12 +4849,11 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, const AutoType *AT = T->getContainedAutoType(); // Allow arrays of auto if we are a generic lambda parameter. // i.e. [](auto (&array)[5]) { return array[0]; }; OK - if (AT && - D.getContext() != DeclaratorContext::LambdaExprParameterContext) { + if (AT && D.getContext() != DeclaratorContext::LambdaExprParameter) { // We've already diagnosed this for decltype(auto). if (!AT->isDecltypeAuto()) S.Diag(DeclType.Loc, diag::err_illegal_decl_array_of_auto) - << getPrintableNameForEntity(Name) << T; + << getPrintableNameForEntity(Name) << T; T = QualType(); break; } @@ -4916,7 +4912,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, << D.getSourceRange(); D.setInvalidType(true); } - } else if (D.getContext() != DeclaratorContext::LambdaExprContext && + } else if (D.getContext() != DeclaratorContext::LambdaExpr && (T.hasQualifiers() || !isa(T) || cast(T)->getKeyword() != AutoTypeKeyword::Auto || @@ -4936,10 +4932,9 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // invent a template parameter for it, for cases like // `auto f() -> C auto` or `[](auto (*p) -> auto) {}`. InventedTemplateParameterInfo *InventedParamInfo = nullptr; - if (D.getContext() == DeclaratorContext::PrototypeContext) + if (D.getContext() == DeclaratorContext::Prototype) InventedParamInfo = &S.InventedParameterInfos.back(); - else if (D.getContext() == - DeclaratorContext::LambdaExprParameterContext) + else if (D.getContext() == DeclaratorContext::LambdaExprParameter) InventedParamInfo = S.getCurLambda(); if (InventedParamInfo) { std::tie(T, TInfo) = InventTemplateParameter( @@ -4961,7 +4956,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // Last processing chunk in block context means this function chunk // represents the block. if (chunkIndex == 0 && - D.getContext() == DeclaratorContext::BlockLiteralContext) + D.getContext() == DeclaratorContext::BlockLiteral) diagID = diag::err_block_returning_array_function; S.Diag(DeclType.Loc, diagID) << T->isFunctionType() << T; T = Context.IntTy; @@ -5102,8 +5097,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (IsTypedefName && FTI.getExceptionSpecType() && !LangOpts.CPlusPlus17) S.Diag(FTI.getExceptionSpecLocBeg(), diag::err_exception_spec_in_typedef) - << (D.getContext() == DeclaratorContext::AliasDeclContext || - D.getContext() == DeclaratorContext::AliasTemplateContext); + << (D.getContext() == DeclaratorContext::AliasDecl || + D.getContext() == DeclaratorContext::AliasTemplate); // If we see "T var();" or "T var(T());" at block scope, it is probably // an attempt to initialize a variable, not a function declaration. @@ -5284,9 +5279,9 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, .getScopeRep() ->getKind() == NestedNameSpecifier::TypeSpec) || state.getDeclarator().getContext() == - DeclaratorContext::MemberContext || + DeclaratorContext::Member || state.getDeclarator().getContext() == - DeclaratorContext::LambdaExprContext; + DeclaratorContext::LambdaExpr; }; if (state.getSema().getLangOpts().OpenCLCPlusPlus && IsClassMember()) { @@ -5453,8 +5448,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (D.getName().getKind() == UnqualifiedIdKind::IK_DeductionGuideName) Kind = DeductionGuide; else if (!D.getCXXScopeSpec().isSet()) { - if ((D.getContext() == DeclaratorContext::MemberContext || - D.getContext() == DeclaratorContext::LambdaExprContext) && + if ((D.getContext() == DeclaratorContext::Member || + D.getContext() == DeclaratorContext::LambdaExpr) && !D.getDeclSpec().isFriendSpecified()) Kind = Member; } else { @@ -5482,9 +5477,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (IsQualifiedFunction && !(Kind == Member && D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static) && - !IsTypedefName && - D.getContext() != DeclaratorContext::TemplateArgContext && - D.getContext() != DeclaratorContext::TemplateTypeArgContext) { + !IsTypedefName && D.getContext() != DeclaratorContext::TemplateArg && + D.getContext() != DeclaratorContext::TemplateTypeArg) { SourceLocation Loc = D.getBeginLoc(); SourceRange RemovalRange; unsigned I; @@ -5546,8 +5540,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // C++2a [dcl.fct]p4: // A parameter with volatile-qualified type is deprecated if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20 && - (D.getContext() == DeclaratorContext::PrototypeContext || - D.getContext() == DeclaratorContext::LambdaExprParameterContext)) + (D.getContext() == DeclaratorContext::Prototype || + D.getContext() == DeclaratorContext::LambdaExprParameter)) S.Diag(D.getIdentifierLoc(), diag::warn_deprecated_volatile_param) << T; // If there was an ellipsis in the declarator, the declaration declares a @@ -5558,9 +5552,9 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // only be used in a parameter-declaration. Such a parameter-declaration // is a parameter pack (14.5.3). [...] switch (D.getContext()) { - case DeclaratorContext::PrototypeContext: - case DeclaratorContext::LambdaExprParameterContext: - case DeclaratorContext::RequiresExprContext: + case DeclaratorContext::Prototype: + case DeclaratorContext::LambdaExprParameter: + case DeclaratorContext::RequiresExpr: // C++0x [dcl.fct]p13: // [...] When it is part of a parameter-declaration-clause, the // parameter pack is a function parameter pack (14.5.3). The type T @@ -5580,7 +5574,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, T = Context.getPackExpansionType(T, None, /*ExpectPackInType=*/false); } break; - case DeclaratorContext::TemplateParamContext: + case DeclaratorContext::TemplateParam: // C++0x [temp.param]p15: // If a template-parameter is a [...] is a parameter-declaration that // declares a parameter pack (8.3.5), then the template-parameter is a @@ -5598,31 +5592,29 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, : diag::ext_variadic_templates); break; - case DeclaratorContext::FileContext: - case DeclaratorContext::KNRTypeListContext: - case DeclaratorContext::ObjCParameterContext: // FIXME: special diagnostic - // here? - case DeclaratorContext::ObjCResultContext: // FIXME: special diagnostic - // here? - case DeclaratorContext::TypeNameContext: - case DeclaratorContext::FunctionalCastContext: - case DeclaratorContext::CXXNewContext: - case DeclaratorContext::AliasDeclContext: - case DeclaratorContext::AliasTemplateContext: - case DeclaratorContext::MemberContext: - case DeclaratorContext::BlockContext: - case DeclaratorContext::ForContext: - case DeclaratorContext::InitStmtContext: - case DeclaratorContext::ConditionContext: - case DeclaratorContext::CXXCatchContext: - case DeclaratorContext::ObjCCatchContext: - case DeclaratorContext::BlockLiteralContext: - case DeclaratorContext::LambdaExprContext: - case DeclaratorContext::ConversionIdContext: - case DeclaratorContext::TrailingReturnContext: - case DeclaratorContext::TrailingReturnVarContext: - case DeclaratorContext::TemplateArgContext: - case DeclaratorContext::TemplateTypeArgContext: + case DeclaratorContext::File: + case DeclaratorContext::KNRTypeList: + case DeclaratorContext::ObjCParameter: // FIXME: special diagnostic here? + case DeclaratorContext::ObjCResult: // FIXME: special diagnostic here? + case DeclaratorContext::TypeName: + case DeclaratorContext::FunctionalCast: + case DeclaratorContext::CXXNew: + case DeclaratorContext::AliasDecl: + case DeclaratorContext::AliasTemplate: + case DeclaratorContext::Member: + case DeclaratorContext::Block: + case DeclaratorContext::ForInit: + case DeclaratorContext::SelectionInit: + case DeclaratorContext::Condition: + case DeclaratorContext::CXXCatch: + case DeclaratorContext::ObjCCatch: + case DeclaratorContext::BlockLiteral: + case DeclaratorContext::LambdaExpr: + case DeclaratorContext::ConversionId: + case DeclaratorContext::TrailingReturn: + case DeclaratorContext::TrailingReturnVar: + case DeclaratorContext::TemplateArg: + case DeclaratorContext::TemplateTypeArg: // FIXME: We may want to allow parameter packs in block-literal contexts // in the future. S.Diag(D.getEllipsisLoc(), @@ -6283,9 +6275,9 @@ TypeResult Sema::ActOnTypeName(Scope *S, Declarator &D) { // to apply them to the actual parameter declaration. // Likewise, we don't want to do this for alias declarations, because // we are actually going to build a declaration from this eventually. - if (D.getContext() != DeclaratorContext::ObjCParameterContext && - D.getContext() != DeclaratorContext::AliasDeclContext && - D.getContext() != DeclaratorContext::AliasTemplateContext) + if (D.getContext() != DeclaratorContext::ObjCParameter && + D.getContext() != DeclaratorContext::AliasDecl && + D.getContext() != DeclaratorContext::AliasTemplate) checkUnusedDeclAttributes(D); if (getLangOpts().CPlusPlus) {