Skip to content

Commit 2a1ab7d

Browse files
authored
Merge pull request #19046 from rintaro/parse-refactor-getsetdecl
[Parse] refactor get/set block parsing
2 parents 71f2671 + 4df9fc1 commit 2a1ab7d

File tree

8 files changed

+143
-330
lines changed

8 files changed

+143
-330
lines changed

include/swift/Parse/Parser.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -377,25 +377,14 @@ class Parser {
377377

378378
void restoreParserPosition(ParserPosition PP, bool enableDiagnostics = false) {
379379
L->restoreState(PP.LS, enableDiagnostics);
380-
381-
// We might be at tok::eof now, so ensure that consumeToken() does not
382-
// assert about lexing past eof.
383-
Tok.setKind(tok::unknown);
384-
consumeTokenWithoutFeedingReceiver();
385-
380+
L->lex(Tok, LeadingTrivia, TrailingTrivia);
386381
PreviousLoc = PP.PreviousLoc;
387382
}
388383

389384
void backtrackToPosition(ParserPosition PP) {
390385
assert(PP.isValid());
391-
392386
L->backtrackToState(PP.LS);
393-
394-
// We might be at tok::eof now, so ensure that consumeToken() does not
395-
// assert about lexing past eof.
396-
Tok.setKind(tok::unknown);
397-
consumeTokenWithoutFeedingReceiver();
398-
387+
L->lex(Tok, LeadingTrivia, TrailingTrivia);
399388
PreviousLoc = PP.PreviousLoc;
400389
}
401390

@@ -894,8 +883,6 @@ class Parser {
894883

895884
void consumeGetSetBody(AbstractFunctionDecl *AFD, SourceLoc LBLoc);
896885

897-
void parseAccessorAttributes(DeclAttributes &Attributes);
898-
899886
struct ParsedAccessors;
900887
bool parseGetSetImpl(ParseDeclOptions Flags,
901888
GenericParamList *GenericParams,

include/swift/Parse/PersistentParserState.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,6 @@ class PersistentParserState {
5252
{}
5353
};
5454

55-
class AccessorBodyState {
56-
ParserPos BodyPos;
57-
SavedScope Scope;
58-
SourceLoc LBLoc;
59-
friend class Parser;
60-
61-
SavedScope takeScope() {
62-
return std::move(Scope);
63-
}
64-
65-
public:
66-
AccessorBodyState(SourceRange BodyRange, SourceLoc PreviousLoc,
67-
SavedScope &&Scope, SourceLoc LBLoc)
68-
: BodyPos{BodyRange.Start, PreviousLoc}, Scope(std::move(Scope)),
69-
LBLoc(LBLoc) {}
70-
};
71-
7255
enum class DelayedDeclKind {
7356
TopLevelCodeDecl,
7457
Decl,
@@ -109,11 +92,6 @@ class PersistentParserState {
10992
std::unique_ptr<FunctionBodyState>>;
11093
DelayedFunctionBodiesTy DelayedFunctionBodies;
11194

112-
using DelayedAccessorBodiesTy =
113-
llvm::DenseMap<AbstractFunctionDecl *,
114-
std::unique_ptr<AccessorBodyState>>;
115-
DelayedAccessorBodiesTy DelayedAccessorBodies;
116-
11795
/// \brief Parser sets this if it stopped parsing before the buffer ended.
11896
ParserPosition MarkedPos;
11997

@@ -133,13 +111,6 @@ class PersistentParserState {
133111

134112
bool hasFunctionBodyState(AbstractFunctionDecl *AFD);
135113

136-
void delayAccessorBodyParsing(AbstractFunctionDecl *AFD,
137-
SourceRange BodyRange,
138-
SourceLoc PreviousLoc,
139-
SourceLoc LBLoc);
140-
std::unique_ptr<AccessorBodyState>
141-
takeAccessorBodyState(AbstractFunctionDecl *AFD);
142-
143114
void delayDecl(DelayedDeclKind Kind, unsigned Flags,
144115
DeclContext *ParentContext,
145116
SourceRange BodyRange, SourceLoc PreviousLoc);

0 commit comments

Comments
 (0)