@@ -104,6 +104,51 @@ enum class ObjCTypeQual {
104104// / TypeCastState - State whether an expression is or may be a type cast.
105105enum class TypeCastState { NotTypeCast = 0 , MaybeTypeCast, IsTypeCast };
106106
107+ // / Control what ParseCastExpression will parse.
108+ enum class CastParseKind { AnyCastExpr = 0 , UnaryExprOnly, PrimaryExprOnly };
109+
110+ // / ParenParseOption - Control what ParseParenExpression will parse.
111+ enum class ParenParseOption {
112+ SimpleExpr, // Only parse '(' expression ')'
113+ FoldExpr, // Also allow fold-expression <anything>
114+ CompoundStmt, // Also allow '(' compound-statement ')'
115+ CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}'
116+ CastExpr // Also allow '(' type-name ')' <anything>
117+ };
118+
119+ // / Describes the behavior that should be taken for an __if_exists
120+ // / block.
121+ enum class IfExistsBehavior {
122+ // / Parse the block; this code is always used.
123+ Parse,
124+ // / Skip the block entirely; this code is never used.
125+ Skip,
126+ // / Parse the block as a dependent block, which may be used in
127+ // / some template instantiations but not others.
128+ Dependent
129+ };
130+
131+ // / Specifies the context in which type-id/expression
132+ // / disambiguation will occur.
133+ enum class TentativeCXXTypeIdContext {
134+ InParens,
135+ Unambiguous,
136+ AsTemplateArgument,
137+ InTrailingReturnType,
138+ AsGenericSelectionArgument,
139+ };
140+
141+ // / The kind of attribute specifier we have found.
142+ enum class CXX11AttributeKind {
143+ // / This is not an attribute specifier.
144+ NotAttributeSpecifier,
145+ // / This should be treated as an attribute-specifier.
146+ AttributeSpecifier,
147+ // / The next tokens are '[[', but this is not an attribute-specifier. This
148+ // / is ill-formed by C++11 [dcl.attr.grammar]p6.
149+ InvalidAttributeSpecifier
150+ };
151+
107152// / Parser - This implements a parser for the C family of languages. After
108153// / parsing units of the grammar, productions are invoked to handle whatever has
109154// / been read.
@@ -1888,14 +1933,7 @@ class Parser : public CodeCompletionHandler {
18881933
18891934 ExprResult ParseExpressionWithLeadingExtension (SourceLocation ExtLoc);
18901935
1891- ExprResult ParseRHSOfBinaryExpression (ExprResult LHS,
1892- prec::Level MinPrec);
1893- // / Control what ParseCastExpression will parse.
1894- enum CastParseKind {
1895- AnyCastExpr = 0 ,
1896- UnaryExprOnly,
1897- PrimaryExprOnly
1898- };
1936+ ExprResult ParseRHSOfBinaryExpression (ExprResult LHS, prec::Level MinPrec);
18991937
19001938 bool isRevertibleTypeTrait (const IdentifierInfo *Id,
19011939 clang::tok::TokenKind *Kind = nullptr );
@@ -1955,14 +1993,6 @@ class Parser : public CodeCompletionHandler {
19551993 // / used for misc language extensions.
19561994 bool ParseSimpleExpressionList (SmallVectorImpl<Expr *> &Exprs);
19571995
1958- // / ParenParseOption - Control what ParseParenExpression will parse.
1959- enum ParenParseOption {
1960- SimpleExpr, // Only parse '(' expression ')'
1961- FoldExpr, // Also allow fold-expression <anything>
1962- CompoundStmt, // Also allow '(' compound-statement ')'
1963- CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}'
1964- CastExpr // Also allow '(' type-name ')' <anything>
1965- };
19661996 ExprResult ParseParenExpression (ParenParseOption &ExprType,
19671997 bool stopIfCastExpr,
19681998 bool isTypeCast,
@@ -2228,18 +2258,6 @@ class Parser : public CodeCompletionHandler {
22282258 SourceLocation *TrailingElseLoc,
22292259 ParsedAttributes &Attrs);
22302260
2231- // / Describes the behavior that should be taken for an __if_exists
2232- // / block.
2233- enum IfExistsBehavior {
2234- // / Parse the block; this code is always used.
2235- IEB_Parse,
2236- // / Skip the block entirely; this code is never used.
2237- IEB_Skip,
2238- // / Parse the block as a dependent block, which may be used in
2239- // / some template instantiations but not others.
2240- IEB_Dependent
2241- };
2242-
22432261 // / Describes the condition of a Microsoft __if_exists or
22442262 // / __if_not_exists block.
22452263 struct IfExistsCondition {
@@ -2631,22 +2649,12 @@ class Parser : public CodeCompletionHandler {
26312649 DeclSpec::FriendSpecified IsFriend = DeclSpec::FriendSpecified::No,
26322650 const ParsedTemplateInfo *TemplateInfo = nullptr );
26332651
2634- // / Specifies the context in which type-id/expression
2635- // / disambiguation will occur.
2636- enum TentativeCXXTypeIdContext {
2637- TypeIdInParens,
2638- TypeIdUnambiguous,
2639- TypeIdAsTemplateArgument,
2640- TypeIdInTrailingReturnType,
2641- TypeIdAsGenericSelectionArgument,
2642- };
2643-
26442652 // / isTypeIdInParens - Assumes that a '(' was parsed and now we want to know
26452653 // / whether the parens contain an expression or a type-id.
26462654 // / Returns true for a type-id and false for an expression.
26472655 bool isTypeIdInParens (bool &isAmbiguous) {
26482656 if (getLangOpts ().CPlusPlus )
2649- return isCXXTypeId (TypeIdInParens , isAmbiguous);
2657+ return isCXXTypeId (TentativeCXXTypeIdContext::InParens , isAmbiguous);
26502658 isAmbiguous = false ;
26512659 return isTypeSpecifierQualifier ();
26522660 }
@@ -2665,7 +2673,8 @@ class Parser : public CodeCompletionHandler {
26652673 bool isTypeIdForGenericSelection () {
26662674 if (getLangOpts ().CPlusPlus ) {
26672675 bool isAmbiguous;
2668- return isCXXTypeId (TypeIdAsGenericSelectionArgument, isAmbiguous);
2676+ return isCXXTypeId (TentativeCXXTypeIdContext::AsGenericSelectionArgument,
2677+ isAmbiguous);
26692678 }
26702679 return isTypeSpecifierQualifier ();
26712680 }
@@ -2676,7 +2685,7 @@ class Parser : public CodeCompletionHandler {
26762685 bool isTypeIdUnambiguously () {
26772686 if (getLangOpts ().CPlusPlus ) {
26782687 bool isAmbiguous;
2679- return isCXXTypeId (TypeIdUnambiguous , isAmbiguous);
2688+ return isCXXTypeId (TentativeCXXTypeIdContext::Unambiguous , isAmbiguous);
26802689 }
26812690 return isTypeSpecifierQualifier ();
26822691 }
@@ -2823,7 +2832,8 @@ class Parser : public CodeCompletionHandler {
28232832 bool isAllowedCXX11AttributeSpecifier (bool Disambiguate = false ,
28242833 bool OuterMightBeMessageSend = false ) {
28252834 return (Tok.isRegularKeywordAttribute () ||
2826- isCXX11AttributeSpecifier (Disambiguate, OuterMightBeMessageSend));
2835+ isCXX11AttributeSpecifier (Disambiguate, OuterMightBeMessageSend) !=
2836+ CXX11AttributeKind::NotAttributeSpecifier);
28272837 }
28282838
28292839 // Check for the start of an attribute-specifier-seq in a context where an
@@ -3282,16 +3292,6 @@ class Parser : public CodeCompletionHandler {
32823292 // ===--------------------------------------------------------------------===//
32833293 // C++ 7: Declarations [dcl.dcl]
32843294
3285- // / The kind of attribute specifier we have found.
3286- enum CXX11AttributeKind {
3287- // / This is not an attribute specifier.
3288- CAK_NotAttributeSpecifier,
3289- // / This should be treated as an attribute-specifier.
3290- CAK_AttributeSpecifier,
3291- // / The next tokens are '[[', but this is not an attribute-specifier. This
3292- // / is ill-formed by C++11 [dcl.attr.grammar]p6.
3293- CAK_InvalidAttributeSpecifier
3294- };
32953295 CXX11AttributeKind
32963296 isCXX11AttributeSpecifier (bool Disambiguate = false ,
32973297 bool OuterMightBeMessageSend = false );
0 commit comments