diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 4a25c70956a3..8f136f4f4438 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -1447,7 +1447,7 @@ private: bool isTokIdentifier_in() const; - ParsedType ParseObjCTypeName(ObjCDeclSpec &DS, Declarator::TheContext Ctx, + ParsedType ParseObjCTypeName(ObjCDeclSpec &DS, DeclaratorContext Ctx, ParsedAttributes *ParamAttrs); void ParseObjCMethodRequirement(); Decl *ParseObjCMethodPrototype( @@ -1920,15 +1920,16 @@ private: bool ParsedForRangeDecl() { return !ColonLoc.isInvalid(); } }; - DeclGroupPtrTy ParseDeclaration(unsigned Context, SourceLocation &DeclEnd, + DeclGroupPtrTy ParseDeclaration(DeclaratorContext Context, + SourceLocation &DeclEnd, ParsedAttributesWithRange &attrs); - DeclGroupPtrTy ParseSimpleDeclaration(unsigned Context, + DeclGroupPtrTy ParseSimpleDeclaration(DeclaratorContext Context, SourceLocation &DeclEnd, ParsedAttributesWithRange &attrs, bool RequireSemi, ForRangeInit *FRI = nullptr); - bool MightBeDeclarator(unsigned Context); - DeclGroupPtrTy ParseDeclGroup(ParsingDeclSpec &DS, unsigned Context, + bool MightBeDeclarator(DeclaratorContext Context); + DeclGroupPtrTy ParseDeclGroup(ParsingDeclSpec &DS, DeclaratorContext Context, SourceLocation *DeclEnd = nullptr, ForRangeInit *FRI = nullptr); Decl *ParseDeclarationAfterDeclarator(Declarator &D, @@ -1951,7 +1952,8 @@ private: const ParsedTemplateInfo &TemplateInfo, AccessSpecifier AS, DeclSpecContext DSC, ParsedAttributesWithRange &Attrs); - DeclSpecContext getDeclSpecContextFromDeclaratorContext(unsigned Context); + DeclSpecContext + getDeclSpecContextFromDeclaratorContext(DeclaratorContext Context); void ParseDeclarationSpecifiers(DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(), AccessSpecifier AS = AS_none, @@ -1965,7 +1967,7 @@ private: DeclSpecContext DSC = DSC_normal); void ParseObjCTypeQualifierList(ObjCDeclSpec &DS, - Declarator::TheContext Context); + DeclaratorContext Context); void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS, const ParsedTemplateInfo &TemplateInfo, @@ -2161,8 +2163,8 @@ private: public: TypeResult ParseTypeName(SourceRange *Range = nullptr, - Declarator::TheContext Context - = Declarator::TypeNameContext, + DeclaratorContext Context + = DeclaratorContext::TypeNameContext, AccessSpecifier AS = AS_none, Decl **OwnedType = nullptr, ParsedAttributes *Attrs = nullptr); @@ -2512,20 +2514,21 @@ private: void DiagnoseUnexpectedNamespace(NamedDecl *Context); - DeclGroupPtrTy ParseNamespace(unsigned Context, SourceLocation &DeclEnd, + DeclGroupPtrTy ParseNamespace(DeclaratorContext Context, + SourceLocation &DeclEnd, SourceLocation InlineLoc = SourceLocation()); - void ParseInnerNamespace(std::vector& IdentLoc, - std::vector& Ident, - std::vector& NamespaceLoc, - unsigned int index, SourceLocation& InlineLoc, - ParsedAttributes& attrs, + void ParseInnerNamespace(std::vector &IdentLoc, + std::vector &Ident, + std::vector &NamespaceLoc, + unsigned int index, SourceLocation &InlineLoc, + ParsedAttributes &attrs, BalancedDelimiterTracker &Tracker); - Decl *ParseLinkage(ParsingDeclSpec &DS, unsigned Context); + Decl *ParseLinkage(ParsingDeclSpec &DS, DeclaratorContext Context); Decl *ParseExportDeclaration(); DeclGroupPtrTy ParseUsingDirectiveOrDeclaration( - unsigned Context, const ParsedTemplateInfo &TemplateInfo, + DeclaratorContext Context, const ParsedTemplateInfo &TemplateInfo, SourceLocation &DeclEnd, ParsedAttributesWithRange &attrs); - Decl *ParseUsingDirective(unsigned Context, + Decl *ParseUsingDirective(DeclaratorContext Context, SourceLocation UsingLoc, SourceLocation &DeclEnd, ParsedAttributes &attrs); @@ -2544,8 +2547,8 @@ private: } }; - bool ParseUsingDeclarator(unsigned Context, UsingDeclarator &D); - DeclGroupPtrTy ParseUsingDeclaration(unsigned Context, + bool ParseUsingDeclarator(DeclaratorContext Context, UsingDeclarator &D); + DeclGroupPtrTy ParseUsingDeclaration(DeclaratorContext Context, const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc, SourceLocation &DeclEnd, @@ -2729,16 +2732,16 @@ private: // C++ 14: Templates [temp] // C++ 14.1: Template Parameters [temp.param] - Decl *ParseDeclarationStartingWithTemplate(unsigned Context, + Decl *ParseDeclarationStartingWithTemplate(DeclaratorContext Context, SourceLocation &DeclEnd, AccessSpecifier AS = AS_none, AttributeList *AccessAttrs = nullptr); - Decl *ParseTemplateDeclarationOrSpecialization(unsigned Context, + Decl *ParseTemplateDeclarationOrSpecialization(DeclaratorContext Context, SourceLocation &DeclEnd, AccessSpecifier AS, AttributeList *AccessAttrs); Decl *ParseSingleDeclarationAfterTemplate( - unsigned Context, + DeclaratorContext Context, const ParsedTemplateInfo &TemplateInfo, ParsingDeclRAIIObject &DiagsFromParams, SourceLocation &DeclEnd, @@ -2782,7 +2785,7 @@ private: bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs); ParsedTemplateArgument ParseTemplateTemplateArgument(); ParsedTemplateArgument ParseTemplateArgument(); - Decl *ParseExplicitInstantiation(unsigned Context, + Decl *ParseExplicitInstantiation(DeclaratorContext Context, SourceLocation ExternLoc, SourceLocation TemplateLoc, SourceLocation &DeclEnd, diff --git a/clang/include/clang/Parse/RAIIObjectsForParser.h b/clang/include/clang/Parse/RAIIObjectsForParser.h index 0422b038da65..acaeb442a21a 100644 --- a/clang/include/clang/Parse/RAIIObjectsForParser.h +++ b/clang/include/clang/Parse/RAIIObjectsForParser.h @@ -202,7 +202,7 @@ namespace clang { ParsingDeclRAIIObject ParsingRAII; public: - ParsingDeclarator(Parser &P, const ParsingDeclSpec &DS, TheContext C) + ParsingDeclarator(Parser &P, const ParsingDeclSpec &DS, DeclaratorContext C) : Declarator(DS, C), ParsingRAII(P, &DS.getDelayedDiagnosticPool()) { } diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index 760a04d3c8d2..39aa2f24ad76 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -1705,21 +1705,7 @@ enum FunctionDefinitionKind { FDK_Deleted }; -/// \brief Information about one declarator, including the parsed type -/// information and the identifier. -/// -/// When the declarator is fully formed, this is turned into the appropriate -/// Decl object. -/// -/// Declarators come in two types: normal declarators and abstract declarators. -/// Abstract declarators are used when parsing types, and don't have an -/// identifier. Normal declarators do have ID's. -/// -/// Instances of this class should be a transient object that lives on the -/// stack, not objects that are allocated in large quantities on the heap. -class Declarator { -public: - enum TheContext { +enum class DeclaratorContext { FileContext, // File scope declaration. PrototypeContext, // Within a function prototype. ObjCResultContext, // An ObjC method result type. @@ -1744,8 +1730,23 @@ public: TemplateTypeArgContext, // Template type argument. AliasDeclContext, // C++11 alias-declaration. AliasTemplateContext // C++11 alias-declaration template. - }; +}; + +/// \brief Information about one declarator, including the parsed type +/// information and the identifier. +/// +/// When the declarator is fully formed, this is turned into the appropriate +/// Decl object. +/// +/// Declarators come in two types: normal declarators and abstract declarators. +/// Abstract declarators are used when parsing types, and don't have an +/// identifier. Normal declarators do have ID's. +/// +/// Instances of this class should be a transient object that lives on the +/// stack, not objects that are allocated in large quantities on the heap. +class Declarator { + private: const DeclSpec &DS; CXXScopeSpec SS; @@ -1753,7 +1754,7 @@ private: SourceRange Range; /// \brief Where we are parsing this declarator. - TheContext Context; + DeclaratorContext Context; /// The C++17 structured binding, if any. This is an alternative to a Name. DecompositionDeclarator BindingGroup; @@ -1820,7 +1821,7 @@ private: friend struct DeclaratorChunk; public: - Declarator(const DeclSpec &ds, TheContext C) + Declarator(const DeclSpec &ds, DeclaratorContext C) : DS(ds), Range(ds.getSourceRange()), Context(C), InvalidType(DS.getTypeSpecType() == DeclSpec::TST_error), GroupingParens(false), FunctionDefinition(FDK_Declaration), @@ -1858,13 +1859,13 @@ public: return BindingGroup; } - TheContext getContext() const { return Context; } + DeclaratorContext getContext() const { return Context; } bool isPrototypeContext() const { - return (Context == PrototypeContext || - Context == ObjCParameterContext || - Context == ObjCResultContext || - Context == LambdaExprParameterContext); + return (Context == DeclaratorContext::PrototypeContext || + Context == DeclaratorContext::ObjCParameterContext || + Context == DeclaratorContext::ObjCResultContext || + Context == DeclaratorContext::LambdaExprParameterContext); } /// \brief Get the source range that spans this declarator. @@ -1919,32 +1920,32 @@ public: /// parameter lists. bool mayOmitIdentifier() const { switch (Context) { - case FileContext: - case KNRTypeListContext: - case MemberContext: - case BlockContext: - case ForContext: - case InitStmtContext: - case ConditionContext: + case DeclaratorContext::FileContext: + case DeclaratorContext::KNRTypeListContext: + case DeclaratorContext::MemberContext: + case DeclaratorContext::BlockContext: + case DeclaratorContext::ForContext: + case DeclaratorContext::InitStmtContext: + case DeclaratorContext::ConditionContext: return false; - case TypeNameContext: - case FunctionalCastContext: - case AliasDeclContext: - case AliasTemplateContext: - case PrototypeContext: - case LambdaExprParameterContext: - case ObjCParameterContext: - case ObjCResultContext: - case TemplateParamContext: - case CXXNewContext: - case CXXCatchContext: - case ObjCCatchContext: - case BlockLiteralContext: - case LambdaExprContext: - case ConversionIdContext: - case TemplateTypeArgContext: - case TrailingReturnContext: + 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::TemplateTypeArgContext: + case DeclaratorContext::TrailingReturnContext: return true; } llvm_unreachable("unknown context kind!"); @@ -1955,32 +1956,32 @@ public: /// typenames. bool mayHaveIdentifier() const { switch (Context) { - case FileContext: - case KNRTypeListContext: - case MemberContext: - case BlockContext: - case ForContext: - case InitStmtContext: - case ConditionContext: - case PrototypeContext: - case LambdaExprParameterContext: - case TemplateParamContext: - case CXXCatchContext: - case ObjCCatchContext: + 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: return true; - case TypeNameContext: - case FunctionalCastContext: - case CXXNewContext: - case AliasDeclContext: - case AliasTemplateContext: - case ObjCParameterContext: - case ObjCResultContext: - case BlockLiteralContext: - case LambdaExprContext: - case ConversionIdContext: - case TemplateTypeArgContext: - case TrailingReturnContext: + 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::TemplateTypeArgContext: + case DeclaratorContext::TrailingReturnContext: return false; } llvm_unreachable("unknown context kind!"); @@ -1989,38 +1990,38 @@ public: /// Return true if the context permits a C++17 decomposition declarator. bool mayHaveDecompositionDeclarator() const { switch (Context) { - case FileContext: + case DeclaratorContext::FileContext: // FIXME: It's not clear that the proposal meant to allow file-scope // structured bindings, but it does. - case BlockContext: - case ForContext: - case InitStmtContext: - case ConditionContext: + case DeclaratorContext::BlockContext: + case DeclaratorContext::ForContext: + case DeclaratorContext::InitStmtContext: + case DeclaratorContext::ConditionContext: return true; - case MemberContext: - case PrototypeContext: - case TemplateParamContext: + case DeclaratorContext::MemberContext: + case DeclaratorContext::PrototypeContext: + case DeclaratorContext::TemplateParamContext: // Maybe one day... return false; // These contexts don't allow any kind of non-abstract declarator. - case KNRTypeListContext: - case TypeNameContext: - case FunctionalCastContext: - case AliasDeclContext: - case AliasTemplateContext: - case LambdaExprParameterContext: - case ObjCParameterContext: - case ObjCResultContext: - case CXXNewContext: - case CXXCatchContext: - case ObjCCatchContext: - case BlockLiteralContext: - case LambdaExprContext: - case ConversionIdContext: - case TemplateTypeArgContext: - case TrailingReturnContext: + 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::TemplateTypeArgContext: + case DeclaratorContext::TrailingReturnContext: return false; } llvm_unreachable("unknown context kind!"); @@ -2035,7 +2036,7 @@ public: return false; if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_extern && - Context != FileContext) + Context != DeclaratorContext::FileContext) return false; // Special names can't have direct initializers. @@ -2043,37 +2044,37 @@ public: return false; switch (Context) { - case FileContext: - case BlockContext: - case ForContext: - case InitStmtContext: + case DeclaratorContext::FileContext: + case DeclaratorContext::BlockContext: + case DeclaratorContext::ForContext: + case DeclaratorContext::InitStmtContext: return true; - case ConditionContext: + case DeclaratorContext::ConditionContext: // 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 KNRTypeListContext: - case MemberContext: - case PrototypeContext: - case LambdaExprParameterContext: - case ObjCParameterContext: - case ObjCResultContext: - case TemplateParamContext: - case CXXCatchContext: - case ObjCCatchContext: - case TypeNameContext: - case FunctionalCastContext: // FIXME - case CXXNewContext: - case AliasDeclContext: - case AliasTemplateContext: - case BlockLiteralContext: - case LambdaExprContext: - case ConversionIdContext: - case TemplateTypeArgContext: - case TrailingReturnContext: + 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::TemplateTypeArgContext: + case DeclaratorContext::TrailingReturnContext: return false; } llvm_unreachable("unknown context kind!"); @@ -2257,32 +2258,32 @@ public: return false; switch (Context) { - case FileContext: - case MemberContext: - case BlockContext: - case ForContext: - case InitStmtContext: + case DeclaratorContext::FileContext: + case DeclaratorContext::MemberContext: + case DeclaratorContext::BlockContext: + case DeclaratorContext::ForContext: + case DeclaratorContext::InitStmtContext: return true; - case ConditionContext: - case KNRTypeListContext: - case TypeNameContext: - case FunctionalCastContext: - case AliasDeclContext: - case AliasTemplateContext: - case PrototypeContext: - case LambdaExprParameterContext: - case ObjCParameterContext: - case ObjCResultContext: - case TemplateParamContext: - case CXXNewContext: - case CXXCatchContext: - case ObjCCatchContext: - case BlockLiteralContext: - case LambdaExprContext: - case ConversionIdContext: - case TemplateTypeArgContext: - case TrailingReturnContext: + 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::TemplateTypeArgContext: + case DeclaratorContext::TrailingReturnContext: return false; } llvm_unreachable("unknown context kind!"); @@ -2292,32 +2293,35 @@ public: /// expression could appear. bool isExpressionContext() const { switch (Context) { - case FileContext: - case KNRTypeListContext: - case MemberContext: - case TypeNameContext: // FIXME: sizeof(...) permits an expression. - case FunctionalCastContext: - case AliasDeclContext: - case AliasTemplateContext: - case PrototypeContext: - case LambdaExprParameterContext: - case ObjCParameterContext: - case ObjCResultContext: - case TemplateParamContext: - case CXXNewContext: - case CXXCatchContext: - case ObjCCatchContext: - case BlockLiteralContext: - case LambdaExprContext: - case ConversionIdContext: - case TrailingReturnContext: + case DeclaratorContext::FileContext: + case DeclaratorContext::KNRTypeListContext: + case DeclaratorContext::MemberContext: + + // 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: return false; - case BlockContext: - case ForContext: - case InitStmtContext: - case ConditionContext: - case TemplateTypeArgContext: + case DeclaratorContext::BlockContext: + case DeclaratorContext::ForContext: + case DeclaratorContext::InitStmtContext: + case DeclaratorContext::ConditionContext: + case DeclaratorContext::TemplateTypeArgContext: return true; } @@ -2430,7 +2434,8 @@ public: /// Returns true if this declares a real member and not a friend. bool isFirstDeclarationOfMember() { - return getContext() == MemberContext && !getDeclSpec().isFriendSpecified(); + return getContext() == DeclaratorContext::MemberContext && + !getDeclSpec().isFriendSpecified(); } /// Returns true if this declares a static member. This cannot be called on a @@ -2451,7 +2456,8 @@ struct FieldDeclarator { Declarator D; Expr *BitfieldSize; explicit FieldDeclarator(const DeclSpec &DS) - : D(DS, Declarator::MemberContext), BitfieldSize(nullptr) { } + : D(DS, DeclaratorContext::MemberContext), + BitfieldSize(nullptr) {} }; /// \brief Represents a C++11 virt-specifier-seq. diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 2a999399fb50..35bb6a9e5cc8 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -43,7 +43,7 @@ using namespace clang; /// /// Called type-id in C++. TypeResult Parser::ParseTypeName(SourceRange *Range, - Declarator::TheContext Context, + DeclaratorContext Context, AccessSpecifier AS, Decl **OwnedType, ParsedAttributes *Attrs) { @@ -1639,7 +1639,7 @@ void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs, /// ParseDeclaration - Parse a full 'declaration', which consists of /// declaration-specifiers, some number of declarators, and a semicolon. -/// 'Context' should be a Declarator::TheContext value. This returns the +/// 'Context' should be a DeclaratorContext value. This returns the /// location of the semicolon in DeclEnd. /// /// declaration: [C99 6.7] @@ -1653,7 +1653,7 @@ void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs, /// [C++11/C11] static_assert-declaration /// others... [FIXME] /// -Parser::DeclGroupPtrTy Parser::ParseDeclaration(unsigned Context, +Parser::DeclGroupPtrTy Parser::ParseDeclaration(DeclaratorContext Context, SourceLocation &DeclEnd, ParsedAttributesWithRange &attrs) { ParenBraceBracketBalancer BalancerRAIIObj(*this); @@ -1714,7 +1714,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(unsigned Context, /// of a simple-declaration. If we find that we are, we also parse the /// for-range-initializer, and place it here. Parser::DeclGroupPtrTy -Parser::ParseSimpleDeclaration(unsigned Context, +Parser::ParseSimpleDeclaration(DeclaratorContext Context, SourceLocation &DeclEnd, ParsedAttributesWithRange &Attrs, bool RequireSemi, ForRangeInit *FRI) { @@ -1753,7 +1753,7 @@ Parser::ParseSimpleDeclaration(unsigned Context, /// Returns true if this might be the start of a declarator, or a common typo /// for a declarator. -bool Parser::MightBeDeclarator(unsigned Context) { +bool Parser::MightBeDeclarator(DeclaratorContext Context) { switch (Tok.getKind()) { case tok::annot_cxxscope: case tok::annot_template_id: @@ -1772,11 +1772,12 @@ bool Parser::MightBeDeclarator(unsigned Context) { return getLangOpts().CPlusPlus; case tok::l_square: // Might be an attribute on an unnamed bit-field. - return Context == Declarator::MemberContext && getLangOpts().CPlusPlus11 && - NextToken().is(tok::l_square); + return Context == DeclaratorContext::MemberContext && + getLangOpts().CPlusPlus11 && NextToken().is(tok::l_square); case tok::colon: // Might be a typo for '::' or an unnamed bit-field. - return Context == Declarator::MemberContext || getLangOpts().CPlusPlus; + return Context == DeclaratorContext::MemberContext || + getLangOpts().CPlusPlus; case tok::identifier: switch (NextToken().getKind()) { @@ -1802,8 +1803,9 @@ bool Parser::MightBeDeclarator(unsigned 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 == Declarator::MemberContext || - (getLangOpts().CPlusPlus && Context == Declarator::FileContext); + return Context == DeclaratorContext::MemberContext || + (getLangOpts().CPlusPlus && + Context == DeclaratorContext::FileContext); case tok::identifier: // Possible virt-specifier. return getLangOpts().CPlusPlus11 && isCXX11VirtSpecifier(NextToken()); @@ -1902,11 +1904,11 @@ void Parser::SkipMalformedDecl() { /// definition or a group of object declarations, actually parse the /// result. Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, - unsigned Context, + DeclaratorContext Context, SourceLocation *DeclEnd, ForRangeInit *FRI) { // Parse the first declarator. - ParsingDeclarator D(*this, DS, static_cast(Context)); + ParsingDeclarator D(*this, DS, Context); ParseDeclarator(D); // Bail out if the first declarator didn't seem well-formed. @@ -1953,7 +1955,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 == Declarator::FileContext) { + if (Context == DeclaratorContext::FileContext) { if (isStartOfFunctionDefinition(D)) { if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) { Diag(Tok, diag::err_function_declared_typedef); @@ -2024,7 +2026,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, if (FirstDecl) DeclsInGroup.push_back(FirstDecl); - bool ExpectSemi = Context != Declarator::ForContext; + 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. @@ -2070,7 +2072,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, *DeclEnd = Tok.getLocation(); if (ExpectSemi && - ExpectAndConsumeSemi(Context == Declarator::FileContext + ExpectAndConsumeSemi(Context == DeclaratorContext::FileContext ? 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 @@ -2273,8 +2275,8 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes( if (Init.isInvalid()) { SmallVector StopTokens; StopTokens.push_back(tok::comma); - if (D.getContext() == Declarator::ForContext || - D.getContext() == Declarator::InitStmtContext) + if (D.getContext() == DeclaratorContext::ForContext || + D.getContext() == DeclaratorContext::InitStmtContext) StopTokens.push_back(tok::r_paren); SkipUntil(StopTokens, StopAtSemi | StopBeforeMatch); Actions.ActOnInitializerError(ThisDecl); @@ -2655,21 +2657,21 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, /// context. /// /// \param Context the declarator context, which is one of the -/// Declarator::TheContext enumerator values. +/// DeclaratorContext enumerator values. Parser::DeclSpecContext -Parser::getDeclSpecContextFromDeclaratorContext(unsigned Context) { - if (Context == Declarator::MemberContext) +Parser::getDeclSpecContextFromDeclaratorContext(DeclaratorContext Context) { + if (Context == DeclaratorContext::MemberContext) return DSC_class; - if (Context == Declarator::FileContext) + if (Context == DeclaratorContext::FileContext) return DSC_top_level; - if (Context == Declarator::TemplateParamContext) + if (Context == DeclaratorContext::TemplateParamContext) return DSC_template_param; - if (Context == Declarator::TemplateTypeArgContext) + if (Context == DeclaratorContext::TemplateTypeArgContext) return DSC_template_type_arg; - if (Context == Declarator::TrailingReturnContext) + if (Context == DeclaratorContext::TrailingReturnContext) return DSC_trailing; - if (Context == Declarator::AliasDeclContext || - Context == Declarator::AliasTemplateContext) + if (Context == DeclaratorContext::AliasDeclContext || + Context == DeclaratorContext::AliasTemplateContext) return DSC_alias_declaration; return DSC_normal; } @@ -5175,7 +5177,7 @@ void Parser::ParseDeclarator(Declarator &D) { } static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang, - unsigned TheContext) { + DeclaratorContext TheContext) { if (Kind == tok::star || Kind == tok::caret) return true; @@ -5194,8 +5196,9 @@ 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 != Declarator::ConversionIdContext && - TheContext != Declarator::CXXNewContext); + return Lang.CPlusPlus11 || + (TheContext != DeclaratorContext::ConversionIdContext && + TheContext != DeclaratorContext::CXXNewContext); return false; } @@ -5249,8 +5252,9 @@ 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() == Declarator::FileContext || - D.getContext() == Declarator::MemberContext; + bool EnteringContext = + D.getContext() == DeclaratorContext::FileContext || + D.getContext() == DeclaratorContext::MemberContext; CXXScopeSpec SS; ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext); @@ -5316,9 +5320,9 @@ 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() != Declarator::CXXNewContext) - ? AR_GNUAttributesParsed - : AR_GNUAttributesParsedAndRejected); + ((D.getContext() != DeclaratorContext::CXXNewContext) + ? AR_GNUAttributesParsed + : AR_GNUAttributesParsedAndRejected); ParseTypeQualifierListOpt(DS, Reqs, true, !D.mayOmitIdentifier()); D.ExtendWithDeclSpec(DS); @@ -5470,15 +5474,16 @@ void Parser::ParseDirectDeclarator(Declarator &D) { // Don't parse FOO:BAR as if it were a typo for FOO::BAR inside a class, in // this context it is a bitfield. Also in range-based for statement colon // may delimit for-range-declaration. - ColonProtectionRAIIObject X(*this, - D.getContext() == Declarator::MemberContext || - (D.getContext() == Declarator::ForContext && - getLangOpts().CPlusPlus11)); + ColonProtectionRAIIObject X( + *this, D.getContext() == DeclaratorContext::MemberContext || + (D.getContext() == DeclaratorContext::ForContext && + getLangOpts().CPlusPlus11)); // ParseDeclaratorInternal might already have parsed the scope. if (D.getCXXScopeSpec().isEmpty()) { - bool EnteringContext = D.getContext() == Declarator::FileContext || - D.getContext() == Declarator::MemberContext; + bool EnteringContext = + D.getContext() == DeclaratorContext::FileContext || + D.getContext() == DeclaratorContext::MemberContext; ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), nullptr, EnteringContext); } @@ -5507,9 +5512,9 @@ 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() == Declarator::PrototypeContext || - D.getContext() == Declarator::LambdaExprParameterContext || - D.getContext() == Declarator::BlockLiteralContext) && + !((D.getContext() == DeclaratorContext::PrototypeContext || + D.getContext() == DeclaratorContext::LambdaExprParameterContext || + D.getContext() == DeclaratorContext::BlockLiteralContext) && NextToken().is(tok::r_paren) && !D.hasGroupingParens() && !Actions.containsUnexpandedParameterPacks(D) && @@ -5541,14 +5546,15 @@ void Parser::ParseDirectDeclarator(Declarator &D) { AllowDeductionGuide = false; } else if (D.getCXXScopeSpec().isSet()) { AllowConstructorName = - (D.getContext() == Declarator::FileContext || - D.getContext() == Declarator::MemberContext); + (D.getContext() == DeclaratorContext::FileContext || + D.getContext() == DeclaratorContext::MemberContext); AllowDeductionGuide = false; } else { - AllowConstructorName = (D.getContext() == Declarator::MemberContext); + AllowConstructorName = + (D.getContext() == DeclaratorContext::MemberContext); AllowDeductionGuide = - (D.getContext() == Declarator::FileContext || - D.getContext() == Declarator::MemberContext); + (D.getContext() == DeclaratorContext::FileContext || + D.getContext() == DeclaratorContext::MemberContext); } SourceLocation TemplateKWLoc; @@ -5604,15 +5610,15 @@ 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() == Declarator::TemplateTypeArgContext) + else if (D.getContext() == DeclaratorContext::TemplateTypeArgContext) // T is an accidental identifier; T'. DiagnoseIdentifier = NextToken().isOneOf(tok::comma, tok::greater, tok::greatergreater); - else if (D.getContext() == Declarator::AliasDeclContext || - D.getContext() == Declarator::AliasTemplateContext) + else if (D.getContext() == DeclaratorContext::AliasDeclContext || + D.getContext() == DeclaratorContext::AliasTemplateContext) // The most likely error is that the ';' was forgotten. DiagnoseIdentifier = NextToken().isOneOf(tok::comma, tok::semi); - else if (D.getContext() == Declarator::TrailingReturnContext && + else if (D.getContext() == DeclaratorContext::TrailingReturnContext && !isCXX11VirtSpecifier(Tok)) DiagnoseIdentifier = NextToken().isOneOf( tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try); @@ -5659,7 +5665,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { LLVM_BUILTIN_TRAP; if (Tok.is(tok::l_square)) return ParseMisplacedBracketDeclarator(D); - if (D.getContext() == Declarator::MemberContext) { + if (D.getContext() == DeclaratorContext::MemberContext) { // Objective-C++: Detect C++ keywords and try to prevent further errors by // treating these keyword as valid member names. if (getLangOpts().ObjC1 && getLangOpts().CPlusPlus && @@ -6042,9 +6048,9 @@ void Parser::ParseFunctionDeclarator(Declarator &D, bool IsCXX11MemberFunction = getLangOpts().CPlusPlus11 && D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_typedef && - (D.getContext() == Declarator::MemberContext + (D.getContext() == DeclaratorContext::MemberContext ? !D.getDeclSpec().isFriendSpecified() - : D.getContext() == Declarator::FileContext && + : D.getContext() == DeclaratorContext::FileContext && D.getCXXScopeSpec().isValid() && Actions.CurContext->isRecord()); Sema::CXXThisScopeRAII ThisScope(Actions, @@ -6309,10 +6315,10 @@ void Parser::ParseParameterDeclarationClause( // Parse the declarator. This is "PrototypeContext" or // "LambdaExprParameterContext", because we must accept either // 'declarator' or 'abstract-declarator' here. - Declarator ParmDeclarator(DS, - D.getContext() == Declarator::LambdaExprContext ? - Declarator::LambdaExprParameterContext : - Declarator::PrototypeContext); + Declarator ParmDeclarator( + DS, D.getContext() == DeclaratorContext::LambdaExprContext + ? DeclaratorContext::LambdaExprParameterContext + : DeclaratorContext::PrototypeContext); ParseDeclarator(ParmDeclarator); // Parse GNU attributes, if present. @@ -6355,7 +6361,7 @@ void Parser::ParseParameterDeclarationClause( SourceLocation EqualLoc = Tok.getLocation(); // Parse the default argument - if (D.getContext() == Declarator::MemberContext) { + if (D.getContext() == DeclaratorContext::MemberContext) { // 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 44e7a3512098..c62580f4e24f 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -55,7 +55,7 @@ using namespace clang; /// namespace-alias-definition: [C++ 7.3.2: namespace.alias] /// 'namespace' identifier '=' qualified-namespace-specifier ';' /// -Parser::DeclGroupPtrTy Parser::ParseNamespace(unsigned Context, +Parser::DeclGroupPtrTy Parser::ParseNamespace(DeclaratorContext Context, SourceLocation &DeclEnd, SourceLocation InlineLoc) { assert(Tok.is(tok::kw_namespace) && "Not a namespace!"); @@ -307,7 +307,7 @@ Decl *Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc, /// 'extern' string-literal '{' declaration-seq[opt] '}' /// 'extern' string-literal declaration /// -Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, unsigned Context) { +Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, DeclaratorContext Context) { assert(isTokenStringLiteral() && "Not a string literal!"); ExprResult Lang = ParseStringLiteralExpression(false); @@ -434,7 +434,7 @@ Decl *Parser::ParseExportDeclaration() { /// ParseUsingDirectiveOrDeclaration - Parse C++ using using-declaration or /// using-directive. Assumes that current token is 'using'. Parser::DeclGroupPtrTy -Parser::ParseUsingDirectiveOrDeclaration(unsigned Context, +Parser::ParseUsingDirectiveOrDeclaration(DeclaratorContext Context, const ParsedTemplateInfo &TemplateInfo, SourceLocation &DeclEnd, ParsedAttributesWithRange &attrs) { @@ -482,7 +482,7 @@ Parser::ParseUsingDirectiveOrDeclaration(unsigned Context, /// 'using' 'namespace' ::[opt] nested-name-specifier[opt] /// namespace-name attributes[opt] ; /// -Decl *Parser::ParseUsingDirective(unsigned Context, +Decl *Parser::ParseUsingDirective(DeclaratorContext Context, SourceLocation UsingLoc, SourceLocation &DeclEnd, ParsedAttributes &attrs) { @@ -551,7 +551,8 @@ Decl *Parser::ParseUsingDirective(unsigned Context, /// using-declarator: /// 'typename'[opt] nested-name-specifier unqualified-id /// -bool Parser::ParseUsingDeclarator(unsigned Context, UsingDeclarator &D) { +bool Parser::ParseUsingDeclarator(DeclaratorContext Context, + UsingDeclarator &D) { D.clear(); // Ignore optional 'typename'. @@ -582,7 +583,8 @@ bool Parser::ParseUsingDeclarator(unsigned Context, UsingDeclarator &D) { // 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 == Declarator::MemberContext && + if (getLangOpts().CPlusPlus11 && + Context == DeclaratorContext::MemberContext && Tok.is(tok::identifier) && (NextToken().is(tok::semi) || NextToken().is(tok::comma) || NextToken().is(tok::ellipsis)) && @@ -629,7 +631,7 @@ bool Parser::ParseUsingDeclarator(unsigned Context, UsingDeclarator &D) { /// 'using' identifier attribute-specifier-seq[opt] = type-id ; /// Parser::DeclGroupPtrTy -Parser::ParseUsingDeclaration(unsigned Context, +Parser::ParseUsingDeclaration(DeclaratorContext Context, const ParsedTemplateInfo &TemplateInfo, SourceLocation UsingLoc, SourceLocation &DeclEnd, AccessSpecifier AS) { @@ -791,11 +793,11 @@ Decl *Parser::ParseAliasDeclarationAfterDeclarator( << FixItHint::CreateRemoval(SourceRange(D.EllipsisLoc)); Decl *DeclFromDeclSpec = nullptr; - TypeResult TypeAlias = - ParseTypeName(nullptr, - TemplateInfo.Kind ? Declarator::AliasTemplateContext - : Declarator::AliasDeclContext, - AS, &DeclFromDeclSpec, &Attrs); + TypeResult TypeAlias = ParseTypeName( + nullptr, + TemplateInfo.Kind ? DeclaratorContext::AliasTemplateContext + : DeclaratorContext::AliasDeclContext, + AS, &DeclFromDeclSpec, &Attrs); if (OwnedType) *OwnedType = DeclFromDeclSpec; @@ -1094,7 +1096,7 @@ TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc, EndLocation = ParseDecltypeSpecifier(DS); - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); } @@ -1195,7 +1197,7 @@ TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc, DS.SetTypeSpecType(TST_typename, IdLoc, PrevSpec, DiagID, Type, Actions.getASTContext().getPrintingPolicy()); - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); } @@ -2509,7 +2511,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, SourceLocation DeclEnd; return DeclGroupPtrTy::make( DeclGroupRef(ParseTemplateDeclarationOrSpecialization( - Declarator::MemberContext, DeclEnd, AS, AccessAttrs))); + DeclaratorContext::MemberContext, DeclEnd, AS, AccessAttrs))); } // Handle: member-declaration ::= '__extension__' member-declaration @@ -2545,7 +2547,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, } SourceLocation DeclEnd; // Otherwise, it must be a using-declaration or an alias-declaration. - return ParseUsingDeclaration(Declarator::MemberContext, TemplateInfo, + return ParseUsingDeclaration(DeclaratorContext::MemberContext, TemplateInfo, UsingLoc, DeclEnd, AS); } @@ -2593,7 +2595,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, return Actions.ConvertDeclToDeclGroup(TheDecl); } - ParsingDeclarator DeclaratorInfo(*this, DS, Declarator::MemberContext); + ParsingDeclarator DeclaratorInfo(*this, DS, DeclaratorContext::MemberContext); VirtSpecifiers VS; // Hold late-parsed attributes so we can attach a Decl to them later. @@ -2852,7 +2854,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, break; if (Tok.isAtStartOfLine() && - !MightBeDeclarator(Declarator::MemberContext)) { + !MightBeDeclarator(DeclaratorContext::MemberContext)) { // 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. @@ -3709,7 +3711,7 @@ TypeResult Parser::ParseTrailingReturnType(SourceRange &Range) { ConsumeToken(); - return ParseTypeName(&Range, Declarator::TrailingReturnContext); + return ParseTypeName(&Range, DeclaratorContext::TrailingReturnContext); } /// \brief We have just started parsing the definition of a new class, diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index bc587628c954..1b8865edb79a 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1000,7 +1000,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ, Actions.getASTContext().getPrintingPolicy()); - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); if (Ty.isInvalid()) @@ -1209,7 +1209,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, PrevSpec, DiagID, Type, Actions.getASTContext().getPrintingPolicy()); - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); if (Ty.isInvalid()) break; @@ -1824,7 +1824,7 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok, if (isTypeIdUnambiguously()) { DeclSpec DS(AttrFactory); ParseSpecifierQualifierList(DS); - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); ParseDeclarator(DeclaratorInfo); SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.getLocation()); @@ -2381,7 +2381,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, // Parse the type declarator. DeclSpec DS(AttrFactory); ParseSpecifierQualifierList(DS); - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); ParseDeclarator(DeclaratorInfo); // If our type is followed by an identifier and either ':' or ']', then @@ -2858,7 +2858,7 @@ void Parser::ParseBlockId(SourceLocation CaretLoc) { ParseSpecifierQualifierList(DS); // Parse the block-declarator. - Declarator DeclaratorInfo(DS, Declarator::BlockLiteralContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::BlockLiteralContext); DeclaratorInfo.setFunctionDefinitionKind(FDK_Definition); ParseDeclarator(DeclaratorInfo); @@ -2897,7 +2897,7 @@ ExprResult Parser::ParseBlockLiteralExpression() { // Parse the return type if present. DeclSpec DS(AttrFactory); - Declarator ParamInfo(DS, Declarator::BlockLiteralContext); + Declarator ParamInfo(DS, DeclaratorContext::BlockLiteralContext); 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 959cb7a61d3a..f11a6c3b043b 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -1090,7 +1090,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( // Parse lambda-declarator[opt]. DeclSpec DS(AttrFactory); - Declarator D(DS, Declarator::LambdaExprContext); + Declarator D(DS, DeclaratorContext::LambdaExprContext); TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth); Actions.PushLambdaScope(); @@ -1353,7 +1353,7 @@ ExprResult Parser::ParseCXXCasts() { ParseSpecifierQualifierList(DS); // Parse the abstract-declarator, if present. - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); ParseDeclarator(DeclaratorInfo); SourceLocation RAngleBracketLoc = Tok.getLocation(); @@ -1660,7 +1660,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, Declarator::FunctionalCastContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::FunctionalCastContext); ParsedType TypeRep = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get(); assert((Tok.is(tok::l_paren) || @@ -1767,8 +1767,9 @@ Sema::ConditionResult Parser::ParseCXXCondition(StmtResult *InitStmt, : diag::ext_init_statement) << (CK == Sema::ConditionKind::Switch); SourceLocation DeclStart = Tok.getLocation(), DeclEnd; - DeclGroupPtrTy DG = ParseSimpleDeclaration( - Declarator::InitStmtContext, DeclEnd, attrs, /*RequireSemi=*/true); + DeclGroupPtrTy DG = + ParseSimpleDeclaration(DeclaratorContext::InitStmtContext, DeclEnd, + attrs, /*RequireSemi=*/true); *InitStmt = Actions.ActOnDeclStmt(DG, DeclStart, DeclEnd); return ParseCXXCondition(nullptr, Loc, CK); } @@ -1784,7 +1785,7 @@ Sema::ConditionResult Parser::ParseCXXCondition(StmtResult *InitStmt, ParseSpecifierQualifierList(DS, AS_none, DSC_condition); // declarator - Declarator DeclaratorInfo(DS, Declarator::ConditionContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::ConditionContext); ParseDeclarator(DeclaratorInfo); // simple-asm-expr[opt] @@ -2395,7 +2396,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, // Parse the conversion-declarator, which is merely a sequence of // ptr-operators. - Declarator D(DS, Declarator::ConversionIdContext); + Declarator D(DS, DeclaratorContext::ConversionIdContext); ParseDeclaratorInternal(D, /*DirectDeclParser=*/nullptr); // Finish up the type. @@ -2696,7 +2697,7 @@ Parser::ParseCXXNewExpression(bool UseGlobal, SourceLocation Start) { SourceRange TypeIdParens; DeclSpec DS(AttrFactory); - Declarator DeclaratorInfo(DS, Declarator::CXXNewContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::CXXNewContext); 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); @@ -3172,7 +3173,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, if (ParseAs >= CompoundLiteral) { // Parse the type declarator. DeclSpec DS(AttrFactory); - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); { ColonProtectionRAIIObject InnerColonProtection(*this); ParseSpecifierQualifierList(DS); diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index fb8624a324b9..a446fd7aa127 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -1140,14 +1140,14 @@ bool Parser::isTokIdentifier_in() const { /// 'null_unspecified' /// void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS, - Declarator::TheContext Context) { - assert(Context == Declarator::ObjCParameterContext || - Context == Declarator::ObjCResultContext); + DeclaratorContext Context) { + assert(Context == DeclaratorContext::ObjCParameterContext || + Context == DeclaratorContext::ObjCResultContext); while (1) { if (Tok.is(tok::code_completion)) { Actions.CodeCompleteObjCPassingType(getCurScope(), DS, - Context == Declarator::ObjCParameterContext); + Context == DeclaratorContext::ObjCParameterContext); return cutOffParsing(); } @@ -1242,12 +1242,12 @@ static void takeDeclAttributes(ParsedAttributes &attrs, /// '(' objc-type-qualifiers[opt] ')' /// ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, - Declarator::TheContext context, + DeclaratorContext context, ParsedAttributes *paramAttrs) { - assert(context == Declarator::ObjCParameterContext || - context == Declarator::ObjCResultContext); + assert(context == DeclaratorContext::ObjCParameterContext || + context == DeclaratorContext::ObjCResultContext); assert((paramAttrs != nullptr) == - (context == Declarator::ObjCParameterContext)); + (context == DeclaratorContext::ObjCParameterContext)); assert(Tok.is(tok::l_paren) && "expected ("); @@ -1266,7 +1266,7 @@ ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, DeclSpec declSpec(AttrFactory); declSpec.setObjCQualifiers(&DS); DeclSpecContext dsContext = DSC_normal; - if (context == Declarator::ObjCResultContext) + if (context == DeclaratorContext::ObjCResultContext) dsContext = DSC_objc_method_result; ParseSpecifierQualifierList(declSpec, AS_none, dsContext); Declarator declarator(declSpec, context); @@ -1288,7 +1288,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 == Declarator::ObjCParameterContext) + if (context == DeclaratorContext::ObjCParameterContext) takeDeclAttributes(*paramAttrs, declarator); } } @@ -1352,7 +1352,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, ParsedType ReturnType; ObjCDeclSpec DSRet; if (Tok.is(tok::l_paren)) - ReturnType = ParseObjCTypeName(DSRet, Declarator::ObjCResultContext, + ReturnType = ParseObjCTypeName(DSRet, DeclaratorContext::ObjCResultContext, nullptr); // If attributes exist before the method, parse them. @@ -1416,7 +1416,7 @@ 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, - Declarator::ObjCParameterContext, + DeclaratorContext::ObjCParameterContext, ¶mAttrs); // If attributes exist before the argument name, parse them. @@ -1494,7 +1494,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc, DeclSpec DS(AttrFactory); ParseDeclarationSpecifiers(DS); // Parse the declarator. - Declarator ParmDecl(DS, Declarator::PrototypeContext); + Declarator ParmDecl(DS, DeclaratorContext::PrototypeContext); ParseDeclarator(ParmDecl); IdentifierInfo *ParmII = ParmDecl.getIdentifier(); Decl *Param = Actions.ActOnParamDeclarator(getCurScope(), ParmDecl); @@ -1703,7 +1703,7 @@ void Parser::parseObjCTypeArgsOrProtocolQualifiers( typeArg, Actions.getASTContext().getPrintingPolicy()); // Form a declarator to turn this into a type. - Declarator D(DS, Declarator::TypeNameContext); + Declarator D(DS, DeclaratorContext::TypeNameContext); TypeResult fullTypeArg = Actions.ActOnTypeName(getCurScope(), D); if (fullTypeArg.isUsable()) { typeArgs.push_back(fullTypeArg.get()); @@ -2543,7 +2543,7 @@ StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { if (Tok.isNot(tok::ellipsis)) { DeclSpec DS(AttrFactory); ParseDeclarationSpecifiers(DS); - Declarator ParmDecl(DS, Declarator::ObjCCatchContext); + Declarator ParmDecl(DS, DeclaratorContext::ObjCCatchContext); ParseDeclarator(ParmDecl); // Inform the actions module about the declarator, so it @@ -2945,7 +2945,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, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); 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 a67a5bbe0dea..628c1f134ac5 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -250,7 +250,8 @@ Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) { do { ColonProtectionRAIIObject ColonRAII(*this); SourceRange Range; - TypeResult TR = ParseTypeName(&Range, Declarator::PrototypeContext, AS); + TypeResult TR = + ParseTypeName(&Range, DeclaratorContext::PrototypeContext, AS); if (TR.isUsable()) { auto ReductionType = Actions.ActOnOpenMPDeclareReductionType(Range.getBegin(), TR); diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 3f25610f4471..09ae9d7f22f6 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -211,7 +211,7 @@ Retry: Allowed == ACK_Any) && isDeclarationStatement()) { SourceLocation DeclStart = Tok.getLocation(), DeclEnd; - DeclGroupPtrTy Decl = ParseDeclaration(Declarator::BlockContext, + DeclGroupPtrTy Decl = ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, Attrs); return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd); } @@ -1021,8 +1021,8 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { ExtensionRAIIObject O(Diags); SourceLocation DeclStart = Tok.getLocation(), DeclEnd; - DeclGroupPtrTy Res = ParseDeclaration(Declarator::BlockContext, DeclEnd, - attrs); + DeclGroupPtrTy Res = + ParseDeclaration(DeclaratorContext::BlockContext, DeclEnd, attrs); R = Actions.ActOnDeclStmt(Res, DeclStart, DeclEnd); } else { // Otherwise this was a unary __extension__ marker. @@ -1631,7 +1631,7 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) { SourceLocation DeclStart = Tok.getLocation(), DeclEnd; DeclGroupPtrTy DG = ParseSimpleDeclaration( - Declarator::ForContext, DeclEnd, attrs, false, + DeclaratorContext::ForContext, DeclEnd, attrs, false, MightBeForRangeStmt ? &ForRangeInit : nullptr); FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation()); if (ForRangeInit.ParsedForRangeDecl()) { @@ -2181,7 +2181,7 @@ StmtResult Parser::ParseCXXCatchBlock(bool FnCatch) { if (ParseCXXTypeSpecifierSeq(DS)) return StmtError(); - Declarator ExDecl(DS, Declarator::CXXCatchContext); + Declarator ExDecl(DS, DeclaratorContext::CXXCatchContext); ParseDeclarator(ExDecl); ExceptionDecl = Actions.ActOnExceptionDeclarator(getCurScope(), ExDecl); } else diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp index 56a16b9e0271..6c3018aa9a84 100644 --- a/clang/lib/Parse/ParseTemplate.cpp +++ b/clang/lib/Parse/ParseTemplate.cpp @@ -24,7 +24,7 @@ using namespace clang; /// \brief Parse a template declaration, explicit instantiation, or /// explicit specialization. Decl * -Parser::ParseDeclarationStartingWithTemplate(unsigned Context, +Parser::ParseDeclarationStartingWithTemplate(DeclaratorContext Context, SourceLocation &DeclEnd, AccessSpecifier AS, AttributeList *AccessAttrs) { @@ -57,7 +57,7 @@ Parser::ParseDeclarationStartingWithTemplate(unsigned Context, /// explicit-specialization: [ C++ temp.expl.spec] /// 'template' '<' '>' declaration Decl * -Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context, +Parser::ParseTemplateDeclarationOrSpecialization(DeclaratorContext Context, SourceLocation &DeclEnd, AccessSpecifier AS, AttributeList *AccessAttrs) { @@ -169,7 +169,7 @@ Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context, /// \returns the new declaration. Decl * Parser::ParseSingleDeclarationAfterTemplate( - unsigned Context, + DeclaratorContext Context, const ParsedTemplateInfo &TemplateInfo, ParsingDeclRAIIObject &DiagsFromTParams, SourceLocation &DeclEnd, @@ -186,7 +186,7 @@ Parser::ParseSingleDeclarationAfterTemplate( return ParseStaticAssertDeclaration(DeclEnd); } - if (Context == Declarator::MemberContext) { + if (Context == DeclaratorContext::MemberContext) { // We are parsing a member template. ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo, &DiagsFromTParams); @@ -234,7 +234,7 @@ Parser::ParseSingleDeclarationAfterTemplate( DS.takeAttributesFrom(prefixAttrs); // Parse the declarator. - ParsingDeclarator DeclaratorInfo(*this, DS, (Declarator::TheContext)Context); + ParsingDeclarator DeclaratorInfo(*this, DS, (DeclaratorContext)Context); ParseDeclarator(DeclaratorInfo); // Error parsing the declarator? if (!DeclaratorInfo.hasName()) { @@ -255,7 +255,7 @@ 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 != Declarator::FileContext) { + if (Context != DeclaratorContext::FileContext) { Diag(Tok, diag::err_function_definition_not_allowed); SkipMalformedDecl(); return nullptr; @@ -369,7 +369,7 @@ bool Parser::ParseTemplateParameters( /// template-parameter /// template-parameter-list ',' template-parameter bool -Parser::ParseTemplateParameterList(unsigned Depth, +Parser::ParseTemplateParameterList(const unsigned Depth, SmallVectorImpl &TemplateParams) { while (1) { @@ -546,7 +546,7 @@ NamedDecl *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) { ParsedType DefaultArg; if (TryConsumeToken(tok::equal, EqualLoc)) DefaultArg = ParseTypeName(/*Range=*/nullptr, - Declarator::TemplateTypeArgContext).get(); + DeclaratorContext::TemplateTypeArgContext).get(); return Actions.ActOnTypeParameter(getCurScope(), TypenameKeyword, EllipsisLoc, KeyLoc, ParamName, NameLoc, Depth, Position, @@ -679,7 +679,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) { DSC_template_param); // Parse this as a typename. - Declarator ParamDecl(DS, Declarator::TemplateParamContext); + Declarator ParamDecl(DS, DeclaratorContext::TemplateParamContext); ParseDeclarator(ParamDecl); if (DS.getTypeSpecType() == DeclSpec::TST_unspecified) { Diag(Tok.getLocation(), diag::err_expected_template_parameter); @@ -1193,8 +1193,8 @@ ParsedTemplateArgument Parser::ParseTemplateArgument() { Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated); if (isCXXTypeId(TypeIdAsTemplateArgument)) { SourceLocation Loc = Tok.getLocation(); - TypeResult TypeArg = ParseTypeName(/*Range=*/nullptr, - Declarator::TemplateTypeArgContext); + TypeResult TypeArg = ParseTypeName( + /*Range=*/nullptr, DeclaratorContext::TemplateTypeArgContext); if (TypeArg.isInvalid()) return ParsedTemplateArgument(); @@ -1297,7 +1297,7 @@ Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs) { /// 'extern' [opt] 'template' declaration /// /// Note that the 'extern' is a GNU extension and C++11 feature. -Decl *Parser::ParseExplicitInstantiation(unsigned Context, +Decl *Parser::ParseExplicitInstantiation(DeclaratorContext Context, SourceLocation ExternLoc, SourceLocation TemplateLoc, SourceLocation &DeclEnd, diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 8aa50a2c7f2a..8b62f1211253 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -783,7 +783,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, // A function definition cannot start with any of these keywords. { SourceLocation DeclEnd; - return ParseDeclaration(Declarator::FileContext, DeclEnd, attrs); + return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); } case tok::kw_static: @@ -793,7 +793,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, Diag(ConsumeToken(), diag::warn_static_inline_explicit_inst_ignored) << 0; SourceLocation DeclEnd; - return ParseDeclaration(Declarator::FileContext, DeclEnd, attrs); + return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); } goto dont_know; @@ -804,7 +804,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, // Inline namespaces. Allowed as an extension even in C++03. if (NextKind == tok::kw_namespace) { SourceLocation DeclEnd; - return ParseDeclaration(Declarator::FileContext, DeclEnd, attrs); + return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); } // Parse (then ignore) 'inline' prior to a template instantiation. This is @@ -813,7 +813,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, Diag(ConsumeToken(), diag::warn_static_inline_explicit_inst_ignored) << 1; SourceLocation DeclEnd; - return ParseDeclaration(Declarator::FileContext, DeclEnd, attrs); + return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); } } goto dont_know; @@ -828,7 +828,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs, diag::ext_extern_template) << SourceRange(ExternLoc, TemplateLoc); SourceLocation DeclEnd; return Actions.ConvertDeclToDeclGroup( - ParseExplicitInstantiation(Declarator::FileContext, + ParseExplicitInstantiation(DeclaratorContext::FileContext, ExternLoc, TemplateLoc, DeclEnd)); } goto dont_know; @@ -1004,11 +1004,11 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs, if (getLangOpts().CPlusPlus && isTokenStringLiteral() && DS.getStorageClassSpec() == DeclSpec::SCS_extern && DS.getParsedSpecifiers() == DeclSpec::PQ_StorageClassSpecifier) { - Decl *TheDecl = ParseLinkage(DS, Declarator::FileContext); + Decl *TheDecl = ParseLinkage(DS, DeclaratorContext::FileContext); return Actions.ConvertDeclToDeclGroup(TheDecl); } - return ParseDeclGroup(DS, Declarator::FileContext); + return ParseDeclGroup(DS, DeclaratorContext::FileContext); } Parser::DeclGroupPtrTy @@ -1313,7 +1313,7 @@ void Parser::ParseKNRParamDeclarations(Declarator &D) { } // Parse the first declarator attached to this declspec. - Declarator ParmDeclarator(DS, Declarator::KNRTypeListContext); + Declarator ParmDeclarator(DS, DeclaratorContext::KNRTypeListContext); ParseDeclarator(ParmDeclarator); // Handle the full declarator list. diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 6fe2dcc9895f..b537b95baf22 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -387,7 +387,7 @@ bool Declarator::isDeclarationOfFunction() const { } bool Declarator::isStaticMember() { - assert(getContext() == MemberContext); + assert(getContext() == DeclaratorContext::MemberContext); return getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static || (getName().Kind == UnqualifiedId::IK_OperatorFunctionId && CXXMethodDecl::isStaticOverloadedOperator( diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 9aed178763dc..2acc896d53d7 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -4171,8 +4171,8 @@ void Sema::CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, AddTypeQualifierResults(DS, Results, LangOpts); if (LangOpts.CPlusPlus11) { Results.AddResult("noexcept"); - if (D.getContext() == Declarator::MemberContext && !D.isCtorOrDtor() && - !D.isStaticMember()) { + if (D.getContext() == DeclaratorContext::MemberContext && + !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 a1fc725f8df4..86555907438e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4746,7 +4746,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, } // Mock up a declarator. - Declarator Dc(DS, Declarator::MemberContext); + Declarator Dc(DS, DeclaratorContext::MemberContext); TypeSourceInfo *TInfo = GetTypeForDeclarator(Dc, S); assert(TInfo && "couldn't build declarator info for anonymous struct/union"); @@ -4843,7 +4843,7 @@ Decl *Sema::BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, assert(Record && "expected a record!"); // Mock up a declarator. - Declarator Dc(DS, Declarator::TypeNameContext); + Declarator Dc(DS, DeclaratorContext::TypeNameContext); TypeSourceInfo *TInfo = GetTypeForDeclarator(Dc, S); assert(TInfo && "couldn't build declarator info for anonymous struct"); @@ -10893,7 +10893,7 @@ Sema::ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, DS.SetTypeSpecType(DeclSpec::TST_auto, IdentLoc, PrevSpec, DiagID, getPrintingPolicy()); - Declarator D(DS, Declarator::ForContext); + Declarator D(DS, DeclaratorContext::ForContext); D.SetIdentifier(Ident, IdentLoc); D.takeAttributes(Attrs, AttrEnd); @@ -11809,7 +11809,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, Declarator::KNRTypeListContext); + Declarator ParamD(DS, DeclaratorContext::KNRTypeListContext); ParamD.SetIdentifier(FTI.Params[i].Ident, FTI.Params[i].IdentLoc); FTI.Params[i].Param = ActOnParamDeclarator(S, ParamD); } @@ -12574,7 +12574,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, (void)Error; // Silence warning. assert(!Error && "Error setting up implicit decl!"); SourceLocation NoLoc; - Declarator D(DS, Declarator::BlockContext); + Declarator D(DS, DeclaratorContext::BlockContext); 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 aa26b37f444d..1be187803063 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -712,7 +712,7 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, Diag(Decomp.getLSquareLoc(), !getLangOpts().CPlusPlus17 ? diag::ext_decomp_decl - : D.getContext() == Declarator::ConditionContext + : D.getContext() == DeclaratorContext::ConditionContext ? diag::ext_decomp_decl_cond : diag::warn_cxx14_compat_decomp_decl) << Decomp.getSourceRange(); @@ -13625,7 +13625,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, Declarator::MemberContext); + Declarator TheDeclarator(DS, DeclaratorContext::MemberContext); 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 abbdc9574b8c..ff3c07e938a8 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1538,7 +1538,7 @@ void Sema::actOnObjCTypeArgsOrProtocolQualifiers( DS.SetRangeEnd(loc); // Form the declarator. - Declarator D(DS, Declarator::TypeNameContext); + Declarator D(DS, DeclaratorContext::TypeNameContext); // 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 4746355e9800..3812bc67448e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -12834,7 +12834,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope) { assert(ParamInfo.getIdentifier() == nullptr && "block-id should have no identifier!"); - assert(ParamInfo.getContext() == Declarator::BlockLiteralContext); + assert(ParamInfo.getContext() == DeclaratorContext::BlockLiteralContext); BlockScopeInfo *CurBlock = getCurBlock(); TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 2530b766f5f7..65c37c4a068b 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -47,7 +47,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() != Declarator::BlockLiteralContext || + if (D.getContext() != DeclaratorContext::BlockLiteralContext || D.getDeclSpec().hasTypeSpecifier()) return false; @@ -1291,11 +1291,12 @@ 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() == Declarator::LambdaExprContext) { + declarator.getContext() == DeclaratorContext::LambdaExprContext) { // In C++1y, a lambda's implicit return type is 'auto'. Result = Context.getAutoDeductType(); break; - } else if (declarator.getContext() == Declarator::LambdaExprContext || + } else if (declarator.getContext() == + DeclaratorContext::LambdaExprContext || checkOmittedBlockReturnType(S, declarator, Context.DependentTy)) { Result = Context.DependentTy; @@ -1572,7 +1573,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { // Before we process any type attributes, synthesize a block literal // function declarator if necessary. - if (declarator.getContext() == Declarator::BlockLiteralContext) + if (declarator.getContext() == DeclaratorContext::BlockLiteralContext) maybeSynthesizeBlockSignature(state, Result); // Apply any type attributes from the decl spec. This may cause the @@ -2780,16 +2781,16 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, (Auto && Auto->getKeyword() != AutoTypeKeyword::GNUAutoType); switch (D.getContext()) { - case Declarator::LambdaExprContext: + case DeclaratorContext::LambdaExprContext: // Declared return type of a lambda-declarator is implicit and is always // 'auto'. break; - case Declarator::ObjCParameterContext: - case Declarator::ObjCResultContext: - case Declarator::PrototypeContext: + case DeclaratorContext::ObjCParameterContext: + case DeclaratorContext::ObjCResultContext: + case DeclaratorContext::PrototypeContext: Error = 0; break; - case Declarator::LambdaExprParameterContext: + case DeclaratorContext::LambdaExprParameterContext: // In C++14, generic lambdas allow 'auto' in their parameters. if (!SemaRef.getLangOpts().CPlusPlus14 || !Auto || Auto->getKeyword() != AutoTypeKeyword::Auto) @@ -2821,7 +2822,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, T, QualType(CorrespondingTemplateParam->getTypeForDecl(), 0)); } break; - case Declarator::MemberContext: { + case DeclaratorContext::MemberContext: { if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static || D.isFunctionDeclarator()) break; @@ -2837,57 +2838,57 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, Error = 20; // Friend type break; } - case Declarator::CXXCatchContext: - case Declarator::ObjCCatchContext: + case DeclaratorContext::CXXCatchContext: + case DeclaratorContext::ObjCCatchContext: Error = 7; // Exception declaration break; - case Declarator::TemplateParamContext: + case DeclaratorContext::TemplateParamContext: if (isa(Deduced)) Error = 19; // Template parameter else if (!SemaRef.getLangOpts().CPlusPlus17) Error = 8; // Template parameter (until C++17) break; - case Declarator::BlockLiteralContext: + case DeclaratorContext::BlockLiteralContext: Error = 9; // Block literal break; - case Declarator::TemplateTypeArgContext: + case DeclaratorContext::TemplateTypeArgContext: Error = 10; // Template type argument break; - case Declarator::AliasDeclContext: - case Declarator::AliasTemplateContext: + case DeclaratorContext::AliasDeclContext: + case DeclaratorContext::AliasTemplateContext: Error = 12; // Type alias break; - case Declarator::TrailingReturnContext: + case DeclaratorContext::TrailingReturnContext: if (!SemaRef.getLangOpts().CPlusPlus14 || !IsCXXAutoType) Error = 13; // Function return type break; - case Declarator::ConversionIdContext: + case DeclaratorContext::ConversionIdContext: if (!SemaRef.getLangOpts().CPlusPlus14 || !IsCXXAutoType) Error = 14; // conversion-type-id break; - case Declarator::FunctionalCastContext: + case DeclaratorContext::FunctionalCastContext: if (isa(Deduced)) break; LLVM_FALLTHROUGH; - case Declarator::TypeNameContext: + case DeclaratorContext::TypeNameContext: Error = 15; // Generic break; - case Declarator::FileContext: - case Declarator::BlockContext: - case Declarator::ForContext: - case Declarator::InitStmtContext: - case Declarator::ConditionContext: + case DeclaratorContext::FileContext: + case DeclaratorContext::BlockContext: + case DeclaratorContext::ForContext: + case DeclaratorContext::InitStmtContext: + case DeclaratorContext::ConditionContext: // 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 Declarator::CXXNewContext: + case DeclaratorContext::CXXNewContext: // 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 Declarator::KNRTypeListContext: + case DeclaratorContext::KNRTypeListContext: Error = 18; // K&R function parameter break; } @@ -2959,47 +2960,47 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, // or enumeration in a type-specifier-seq. unsigned DiagID = 0; switch (D.getContext()) { - case Declarator::TrailingReturnContext: + case DeclaratorContext::TrailingReturnContext: // Class and enumeration definitions are syntactically not allowed in // trailing return types. llvm_unreachable("parser should not have allowed this"); break; - case Declarator::FileContext: - case Declarator::MemberContext: - case Declarator::BlockContext: - case Declarator::ForContext: - case Declarator::InitStmtContext: - case Declarator::BlockLiteralContext: - case Declarator::LambdaExprContext: + case DeclaratorContext::FileContext: + case DeclaratorContext::MemberContext: + case DeclaratorContext::BlockContext: + case DeclaratorContext::ForContext: + case DeclaratorContext::InitStmtContext: + case DeclaratorContext::BlockLiteralContext: + case DeclaratorContext::LambdaExprContext: // 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 Declarator::AliasDeclContext: + case DeclaratorContext::AliasDeclContext: break; - case Declarator::AliasTemplateContext: + case DeclaratorContext::AliasTemplateContext: DiagID = diag::err_type_defined_in_alias_template; break; - case Declarator::TypeNameContext: - case Declarator::FunctionalCastContext: - case Declarator::ConversionIdContext: - case Declarator::TemplateParamContext: - case Declarator::CXXNewContext: - case Declarator::CXXCatchContext: - case Declarator::ObjCCatchContext: - case Declarator::TemplateTypeArgContext: + case DeclaratorContext::TypeNameContext: + case DeclaratorContext::FunctionalCastContext: + case DeclaratorContext::ConversionIdContext: + case DeclaratorContext::TemplateParamContext: + case DeclaratorContext::CXXNewContext: + case DeclaratorContext::CXXCatchContext: + case DeclaratorContext::ObjCCatchContext: + case DeclaratorContext::TemplateTypeArgContext: DiagID = diag::err_type_defined_in_type_specifier; break; - case Declarator::PrototypeContext: - case Declarator::LambdaExprParameterContext: - case Declarator::ObjCParameterContext: - case Declarator::ObjCResultContext: - case Declarator::KNRTypeListContext: + case DeclaratorContext::PrototypeContext: + case DeclaratorContext::LambdaExprParameterContext: + case DeclaratorContext::ObjCParameterContext: + case DeclaratorContext::ObjCResultContext: + case DeclaratorContext::KNRTypeListContext: // C++ [dcl.fct]p6: // Types shall not be defined in return or parameter types. DiagID = diag::err_type_defined_in_param_type; break; - case Declarator::ConditionContext: + case DeclaratorContext::ConditionContext: // C++ 6.4p2: // The type-specifier-seq shall not contain typedef and shall not declare // a new class or enumeration. @@ -3048,7 +3049,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() == Declarator::ConditionContext) + if (D.getContext() == DeclaratorContext::ConditionContext) return; SourceRange ParenRange(DeclType.Loc, DeclType.EndLoc); @@ -3164,7 +3165,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() == Declarator::CXXNewContext) + if (D.getContext() == DeclaratorContext::CXXNewContext) return; // FIXME: "A(f())" deserves a vexing-parse warning, not just a // redundant-parens warning, but we don't know whether the function @@ -3282,7 +3283,7 @@ getCCForDeclaratorChunk(Sema &S, Declarator &D, // in a member pointer. IsCXXInstanceMethod = D.getTypeObject(I).Kind == DeclaratorChunk::MemberPointer; - } else if (D.getContext() == Declarator::LambdaExprContext) { + } else if (D.getContext() == DeclaratorContext::LambdaExprContext) { // This can only be a call operator for a lambda, which is an instance // method. IsCXXInstanceMethod = true; @@ -3779,8 +3780,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // Does this declaration declare a typedef-name? bool IsTypedefName = D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef || - D.getContext() == Declarator::AliasDeclContext || - D.getContext() == Declarator::AliasTemplateContext; + D.getContext() == DeclaratorContext::AliasDeclContext || + D.getContext() == DeclaratorContext::AliasTemplateContext; // Does T refer to a function type with a cv-qualifier or a ref-qualifier? bool IsQualifiedFunction = T->isFunctionProtoType() && @@ -3909,14 +3910,14 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, } else { bool isFunctionOrMethod = false; switch (auto context = state.getDeclarator().getContext()) { - case Declarator::ObjCParameterContext: - case Declarator::ObjCResultContext: - case Declarator::PrototypeContext: - case Declarator::TrailingReturnContext: + case DeclaratorContext::ObjCParameterContext: + case DeclaratorContext::ObjCResultContext: + case DeclaratorContext::PrototypeContext: + case DeclaratorContext::TrailingReturnContext: isFunctionOrMethod = true; LLVM_FALLTHROUGH; - case Declarator::MemberContext: + case DeclaratorContext::MemberContext: if (state.getDeclarator().isObjCIvar() && !isFunctionOrMethod) { complainAboutMissingNullability = CAMN_No; break; @@ -3930,8 +3931,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, LLVM_FALLTHROUGH; - case Declarator::FileContext: - case Declarator::KNRTypeListContext: { + case DeclaratorContext::FileContext: + case DeclaratorContext::KNRTypeListContext: { complainAboutMissingNullability = CAMN_Yes; // Nullability inference depends on the type and declarator. @@ -3947,8 +3948,9 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (inAssumeNonNullRegion) { complainAboutInferringWithinChunk = wrappingKind; inferNullability = NullabilityKind::NonNull; - inferNullabilityCS = (context == Declarator::ObjCParameterContext || - context == Declarator::ObjCResultContext); + inferNullabilityCS = + (context == DeclaratorContext::ObjCParameterContext || + context == DeclaratorContext::ObjCResultContext); } break; @@ -3988,26 +3990,26 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, break; } - case Declarator::ConversionIdContext: + case DeclaratorContext::ConversionIdContext: complainAboutMissingNullability = CAMN_Yes; break; - case Declarator::AliasDeclContext: - case Declarator::AliasTemplateContext: - case Declarator::BlockContext: - case Declarator::BlockLiteralContext: - case Declarator::ConditionContext: - case Declarator::CXXCatchContext: - case Declarator::CXXNewContext: - case Declarator::ForContext: - case Declarator::InitStmtContext: - case Declarator::LambdaExprContext: - case Declarator::LambdaExprParameterContext: - case Declarator::ObjCCatchContext: - case Declarator::TemplateParamContext: - case Declarator::TemplateTypeArgContext: - case Declarator::TypeNameContext: - case Declarator::FunctionalCastContext: + 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::TemplateTypeArgContext: + case DeclaratorContext::TypeNameContext: + case DeclaratorContext::FunctionalCastContext: // Don't infer in these contexts. break; } @@ -4243,7 +4245,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // array type, ... if (ASM == ArrayType::Static || ATI.TypeQuals) { if (!(D.isPrototypeContext() || - D.getContext() == Declarator::KNRTypeListContext)) { + D.getContext() == DeclaratorContext::KNRTypeListContext)) { S.Diag(DeclType.Loc, diag::err_array_static_outside_prototype) << (ASM == ArrayType::Static ? "'static'" : "type qualifier"); // Remove the 'static' and the type qualifiers. @@ -4267,7 +4269,8 @@ 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() != Declarator::LambdaExprParameterContext) { + if (AT && + D.getContext() != DeclaratorContext::LambdaExprParameterContext) { // We've already diagnosed this for decltype(auto). if (!AT->isDecltypeAuto()) S.Diag(DeclType.Loc, diag::err_illegal_decl_array_of_auto) @@ -4326,7 +4329,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, << D.getSourceRange(); D.setInvalidType(true); } - } else if (D.getContext() != Declarator::LambdaExprContext && + } else if (D.getContext() != DeclaratorContext::LambdaExprContext && (T.hasQualifiers() || !isa(T) || cast(T)->getKeyword() != AutoTypeKeyword::Auto)) { @@ -4352,7 +4355,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // Last processing chunk in block context means this function chunk // represents the block. if (chunkIndex == 0 && - D.getContext() == Declarator::BlockLiteralContext) + D.getContext() == DeclaratorContext::BlockLiteralContext) diagID = diag::err_block_returning_array_function; S.Diag(DeclType.Loc, diagID) << T->isFunctionType() << T; T = Context.IntTy; @@ -4490,8 +4493,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (IsTypedefName && FTI.getExceptionSpecType() && !LangOpts.CPlusPlus17) S.Diag(FTI.getExceptionSpecLocBeg(), diag::err_exception_spec_in_typedef) - << (D.getContext() == Declarator::AliasDeclContext || - D.getContext() == Declarator::AliasTemplateContext); + << (D.getContext() == DeclaratorContext::AliasDeclContext || + D.getContext() == DeclaratorContext::AliasTemplateContext); // 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. @@ -4794,8 +4797,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, if (D.getName().getKind() == UnqualifiedId::IK_DeductionGuideName) Kind = DeductionGuide; else if (!D.getCXXScopeSpec().isSet()) { - if ((D.getContext() == Declarator::MemberContext || - D.getContext() == Declarator::LambdaExprContext) && + if ((D.getContext() == DeclaratorContext::MemberContext || + D.getContext() == DeclaratorContext::LambdaExprContext) && !D.getDeclSpec().isFriendSpecified()) Kind = Member; } else { @@ -4824,7 +4827,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, !(Kind == Member && D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static) && !IsTypedefName && - D.getContext() != Declarator::TemplateTypeArgContext) { + D.getContext() != DeclaratorContext::TemplateTypeArgContext) { SourceLocation Loc = D.getLocStart(); SourceRange RemovalRange; unsigned I; @@ -4890,8 +4893,8 @@ 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 Declarator::PrototypeContext: - case Declarator::LambdaExprParameterContext: + case DeclaratorContext::PrototypeContext: + case DeclaratorContext::LambdaExprParameterContext: // 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 @@ -4910,7 +4913,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, T = Context.getPackExpansionType(T, None); } break; - case Declarator::TemplateParamContext: + case DeclaratorContext::TemplateParamContext: // 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 @@ -4928,27 +4931,29 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, : diag::ext_variadic_templates); break; - case Declarator::FileContext: - case Declarator::KNRTypeListContext: - case Declarator::ObjCParameterContext: // FIXME: special diagnostic here? - case Declarator::ObjCResultContext: // FIXME: special diagnostic here? - case Declarator::TypeNameContext: - case Declarator::FunctionalCastContext: - case Declarator::CXXNewContext: - case Declarator::AliasDeclContext: - case Declarator::AliasTemplateContext: - case Declarator::MemberContext: - case Declarator::BlockContext: - case Declarator::ForContext: - case Declarator::InitStmtContext: - case Declarator::ConditionContext: - case Declarator::CXXCatchContext: - case Declarator::ObjCCatchContext: - case Declarator::BlockLiteralContext: - case Declarator::LambdaExprContext: - case Declarator::ConversionIdContext: - case Declarator::TrailingReturnContext: - case Declarator::TemplateTypeArgContext: + 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::TemplateTypeArgContext: // FIXME: We may want to allow parameter packs in block-literal contexts // in the future. S.Diag(D.getEllipsisLoc(), @@ -5637,9 +5642,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() != Declarator::ObjCParameterContext && - D.getContext() != Declarator::AliasDeclContext && - D.getContext() != Declarator::AliasTemplateContext) + if (D.getContext() != DeclaratorContext::ObjCParameterContext && + D.getContext() != DeclaratorContext::AliasDeclContext && + D.getContext() != DeclaratorContext::AliasTemplateContext) checkUnusedDeclAttributes(D); if (getLangOpts().CPlusPlus) { @@ -7066,7 +7071,7 @@ static void deduceOpenCLImplicitAddrSpace(TypeProcessingState &State, IsFuncReturnType || IsFuncType || // Do not deduce addr space for member types of struct, except the pointee // type of a pointer member type. - (D.getContext() == Declarator::MemberContext && !IsPointee) || + (D.getContext() == DeclaratorContext::MemberContext && !IsPointee) || // Do not deduce addr space for types used to define a typedef and the // typedef itself, except the pointee type of a pointer type which is used // to define the typedef. @@ -7098,7 +7103,7 @@ static void deduceOpenCLImplicitAddrSpace(TypeProcessingState &State, if (IsPointee) { ImpAddr = LangAS::opencl_generic; } else { - if (D.getContext() == Declarator::FileContext) { + if (D.getContext() == DeclaratorContext::FileContext) { ImpAddr = LangAS::opencl_global; } else { if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||