Author: Vlad Serebrennikov Date: 2025-04-30T05:49:29+03:00 New Revision: 44d8aa8139e02e7b1642f284b32757ee446a88e6
URL: https://github.com/llvm/llvm-project/commit/44d8aa8139e02e7b1642f284b32757ee446a88e6 DIFF: https://github.com/llvm/llvm-project/commit/44d8aa8139e02e7b1642f284b32757ee446a88e6.diff LOG: [clang][NFC] Convert `Parser::CachedInitKind` to scoped enum Added: Modified: clang/include/clang/Parse/Parser.h clang/lib/Parse/ParseCXXInlineMethods.cpp clang/lib/Parse/ParseDecl.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 4158712a258cc..28046993f847e 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -84,6 +84,8 @@ enum class ParsedTemplateKind { ExplicitInstantiation }; +enum class CachedInitKind { DefaultArgument, DefaultInitializer }; + /// Parser - This implements a parser for the C family of languages. After /// parsing units of the grammar, productions are invoked to handle whatever has /// been read. @@ -1646,11 +1648,6 @@ class Parser : public CodeCompletionHandler { void DeallocateParsedClasses(ParsingClass *Class); void PopParsingClass(Sema::ParsingClassState); - enum CachedInitKind { - CIK_DefaultArgument, - CIK_DefaultInitializer - }; - NamedDecl *ParseCXXInlineMethodDef(AccessSpecifier AS, const ParsedAttributesView &AccessAttrs, ParsingDeclarator &D, diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp index 78eddfa8b3530..e76435d0e9de7 100644 --- a/clang/lib/Parse/ParseCXXInlineMethods.cpp +++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp @@ -266,7 +266,7 @@ void Parser::ParseCXXNonStaticMemberInitializer(Decl *VarD) { ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/true); } else { // Consume everything up to (but excluding) the comma or semicolon. - ConsumeAndStoreInitializer(Toks, CIK_DefaultInitializer); + ConsumeAndStoreInitializer(Toks, CachedInitKind::DefaultInitializer); } // Store an artificial EOF token to ensure that we don't run off the end of @@ -1238,7 +1238,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks, TPResult Result = TPResult::Error; ConsumeToken(); switch (CIK) { - case CIK_DefaultInitializer: + case CachedInitKind::DefaultInitializer: Result = TryParseInitDeclaratorList(); // If we parsed a complete, ambiguous init-declarator-list, this // is only syntactically-valid if it's followed by a semicolon. @@ -1246,7 +1246,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks, Result = TPResult::False; break; - case CIK_DefaultArgument: + case CachedInitKind::DefaultArgument: bool InvalidAsDeclaration = false; Result = TryParseParameterDeclarationClause( &InvalidAsDeclaration, /*VersusTemplateArg=*/true); @@ -1372,7 +1372,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks, // and return it. Otherwise, this is a spurious RHS token, which we // consume and pass on to downstream code to diagnose. case tok::r_paren: - if (CIK == CIK_DefaultArgument) + if (CIK == CachedInitKind::DefaultArgument) return true; // End of the default argument. if (ParenCount && !IsFirstToken) return false; @@ -1406,7 +1406,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks, ConsumeStringToken(); break; case tok::semi: - if (CIK == CIK_DefaultInitializer) + if (CIK == CachedInitKind::DefaultInitializer) return true; // End of the default initializer. [[fallthrough]]; default: diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 5f521935447e7..ec3e3ca29c637 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -8156,7 +8156,8 @@ void Parser::ParseParameterDeclarationClause( DefArgToks.reset(new CachedTokens); SourceLocation ArgStartLoc = NextToken().getLocation(); - ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument); + ConsumeAndStoreInitializer(*DefArgToks, + CachedInitKind::DefaultArgument); Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc, ArgStartLoc); } else { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits