Skip to content

Commit 301340a

Browse files
authored
[clang][NFC] Regroup declarations in Parser (#138511)
Following the steps of #82217, this patch reorganizes declarations in `Parse.h`. Highlights are: 1) Declarations are grouped in the same fashion as in `Sema.h`. Table of contents is provided at the beginning of `Parser` class. `public` declaration go first, then `private` ones, but unlike `Sema`, most of the stuff in `Parser` is private. 2) Documentation has been moved from `.cpp` files to the header. Grammar was consistently put in `\verbatim` blocks to render nicely in Doxygen. 3) File has been formatted with clang-format, except for the grammar, because clang-format butchers it.
1 parent bdf8c99 commit 301340a

16 files changed

+7903
-7098
lines changed

clang/include/clang/Parse/Parser.h

Lines changed: 7900 additions & 3011 deletions
Large diffs are not rendered by default.

clang/lib/Parse/ParseCXXInlineMethods.cpp

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
using namespace clang;
2323

24-
/// Parse the optional ("message") part of a deleted-function-body.
2524
StringLiteral *Parser::ParseCXXDeletedFunctionMessage() {
2625
if (!Tok.is(tok::l_paren))
2726
return nullptr;
@@ -48,9 +47,6 @@ StringLiteral *Parser::ParseCXXDeletedFunctionMessage() {
4847
return Message;
4948
}
5049

51-
/// If we've encountered '= delete' in a context where it is ill-formed, such
52-
/// as in the declaration of a non-function, also skip the ("message") part if
53-
/// it is present to avoid issuing further diagnostics.
5450
void Parser::SkipDeletedFunctionBody() {
5551
if (!Tok.is(tok::l_paren))
5652
return;
@@ -64,9 +60,6 @@ void Parser::SkipDeletedFunctionBody() {
6460
BT.consumeClose();
6561
}
6662

67-
/// ParseCXXInlineMethodDef - We parsed and verified that the specified
68-
/// Declarator is a well formed C++ inline method definition. Now lex its body
69-
/// and store its tokens for parsing after the C++ class is complete.
7063
NamedDecl *Parser::ParseCXXInlineMethodDef(
7164
AccessSpecifier AS, const ParsedAttributesView &AccessAttrs,
7265
ParsingDeclarator &D, const ParsedTemplateInfo &TemplateInfo,
@@ -238,10 +231,6 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(
238231
return FnD;
239232
}
240233

241-
/// ParseCXXNonStaticMemberInitializer - We parsed and verified that the
242-
/// specified Declarator is a well formed C++ non-static data member
243-
/// declaration. Now lex its initializer and store its tokens for parsing
244-
/// after the class is complete.
245234
void Parser::ParseCXXNonStaticMemberInitializer(Decl *VarD) {
246235
assert(Tok.isOneOf(tok::l_brace, tok::equal) &&
247236
"Current token not a '{' or '='!");
@@ -333,8 +322,6 @@ void Parser::LateParsedPragma::ParseLexedPragmas() {
333322
Self->ParseLexedPragma(*this);
334323
}
335324

336-
/// Utility to re-enter a possibly-templated scope while parsing its
337-
/// late-parsed components.
338325
struct Parser::ReenterTemplateScopeRAII {
339326
Parser &P;
340327
MultiParseScope Scopes;
@@ -349,7 +336,6 @@ struct Parser::ReenterTemplateScopeRAII {
349336
}
350337
};
351338

352-
/// Utility to re-enter a class scope while parsing its late-parsed components.
353339
struct Parser::ReenterClassScopeRAII : ReenterTemplateScopeRAII {
354340
ParsingClass &Class;
355341

@@ -375,10 +361,6 @@ struct Parser::ReenterClassScopeRAII : ReenterTemplateScopeRAII {
375361
}
376362
};
377363

378-
/// ParseLexedMethodDeclarations - We finished parsing the member
379-
/// specification of a top (non-nested) C++ class. Now go over the
380-
/// stack of method declarations with some parts for which parsing was
381-
/// delayed (such as default arguments) and parse them.
382364
void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
383365
ReenterClassScopeRAII InClassScope(*this, Class);
384366

@@ -583,9 +565,6 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
583565
Actions.ActOnFinishDelayedCXXMethodDeclaration(getCurScope(), LM.Method);
584566
}
585567

586-
/// ParseLexedMethodDefs - We finished parsing the member specification of a top
587-
/// (non-nested) C++ class. Now go over the stack of lexed methods that were
588-
/// collected during its parsing and parse them all.
589568
void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
590569
ReenterClassScopeRAII InClassScope(*this, Class);
591570

@@ -664,9 +643,6 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) {
664643
ParseFunctionStatementBody(LM.D, FnScope);
665644
}
666645

667-
/// ParseLexedMemberInitializers - We finished parsing the member specification
668-
/// of a top (non-nested) C++ class. Now go over the stack of lexed data member
669-
/// initializers that were collected during its parsing and parse them all.
670646
void Parser::ParseLexedMemberInitializers(ParsingClass &Class) {
671647
ReenterClassScopeRAII InClassScope(*this, Class);
672648

@@ -734,16 +710,13 @@ void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
734710
ConsumeAnyToken();
735711
}
736712

737-
/// Wrapper class which calls ParseLexedAttribute, after setting up the
738-
/// scope appropriately.
739713
void Parser::ParseLexedAttributes(ParsingClass &Class) {
740714
ReenterClassScopeRAII InClassScope(*this, Class);
741715

742716
for (LateParsedDeclaration *LateD : Class.LateParsedDeclarations)
743717
LateD->ParseLexedAttributes();
744718
}
745719

746-
/// Parse all attributes in LAs, and attach them to Decl D.
747720
void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
748721
bool EnterScope, bool OnDefinition) {
749722
assert(LAs.parseSoon() &&
@@ -757,11 +730,6 @@ void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
757730
LAs.clear();
758731
}
759732

760-
/// Finish parsing an attribute for which parsing was delayed.
761-
/// This will be called at the end of parsing a class declaration
762-
/// for each LateParsedAttribute. We consume the saved tokens and
763-
/// create an attribute with the arguments filled in. We add this
764-
/// to the Attribute list for the decl.
765733
void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
766734
bool EnterScope, bool OnDefinition) {
767735
// Create a fake EOF so that attribute parsing won't go off the end of the
@@ -865,12 +833,6 @@ void Parser::ParseLexedPragma(LateParsedPragma &LP) {
865833
}
866834
}
867835

868-
/// ConsumeAndStoreUntil - Consume and store the token at the passed token
869-
/// container until the token 'T' is reached (which gets
870-
/// consumed/stored too, if ConsumeFinalToken).
871-
/// If StopAtSemi is true, then we will stop early at a ';' character.
872-
/// Returns true if token 'T1' or 'T2' was found.
873-
/// NOTE: This is a specialized version of Parser::SkipUntil.
874836
bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
875837
CachedTokens &Toks,
876838
bool StopAtSemi, bool ConsumeFinalToken) {
@@ -953,12 +915,6 @@ bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
953915
}
954916
}
955917

956-
/// Consume tokens and store them in the passed token container until
957-
/// we've passed the try keyword and constructor initializers and have consumed
958-
/// the opening brace of the function body. The opening brace will be consumed
959-
/// if and only if there was no error.
960-
///
961-
/// \return True on error.
962918
bool Parser::ConsumeAndStoreFunctionPrologue(CachedTokens &Toks) {
963919
if (Tok.is(tok::kw_try)) {
964920
Toks.push_back(Tok);
@@ -1170,8 +1126,6 @@ bool Parser::ConsumeAndStoreFunctionPrologue(CachedTokens &Toks) {
11701126
}
11711127
}
11721128

1173-
/// Consume and store tokens from the '?' to the ':' in a conditional
1174-
/// expression.
11751129
bool Parser::ConsumeAndStoreConditional(CachedTokens &Toks) {
11761130
// Consume '?'.
11771131
assert(Tok.is(tok::question));
@@ -1195,12 +1149,6 @@ bool Parser::ConsumeAndStoreConditional(CachedTokens &Toks) {
11951149
return true;
11961150
}
11971151

1198-
/// ConsumeAndStoreInitializer - Consume and store the token at the passed token
1199-
/// container until the end of the current initializer expression (either a
1200-
/// default argument or an in-class initializer for a non-static data member).
1201-
///
1202-
/// Returns \c true if we reached the end of something initializer-shaped,
1203-
/// \c false if we bailed out.
12041152
bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks,
12051153
CachedInitKind CIK) {
12061154
// We always want this function to consume at least one token if not at EOF.

0 commit comments

Comments
 (0)