Skip to content

Commit dfeb482

Browse files
committed
NFC: Rename isStartOfDecl -> isStartOfSwiftDecl
Make it clear that this function doesn't deal with SIL decls.
1 parent 849bd62 commit dfeb482

File tree

6 files changed

+23
-25
lines changed

6 files changed

+23
-25
lines changed

include/swift/Parse/Parser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,8 @@ class Parser {
880880
//===--------------------------------------------------------------------===//
881881
// Decl Parsing
882882

883-
/// Return true if parser is at the start of a decl or decl-import.
884-
bool isStartOfDecl();
883+
/// Return true if parser is at the start of a Swift decl or decl-import.
884+
bool isStartOfSwiftDecl();
885885

886886
void parseTopLevel();
887887

lib/Parse/ParseDecl.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,9 +3047,9 @@ bool Parser::parseDeclModifierList(DeclAttributes &Attributes,
30473047
// treat 'class' as a modifier; in the case of a following CC
30483048
// token, we cannot be sure there is no intention to override
30493049
// or witness something static.
3050-
if (isStartOfDecl() || (isa<ClassDecl>(CurDeclContext) &&
3051-
(Tok.is(tok::code_complete) ||
3052-
Tok.getRawText().equals("override")))) {
3050+
if (isStartOfSwiftDecl() || (isa<ClassDecl>(CurDeclContext) &&
3051+
(Tok.is(tok::code_complete) ||
3052+
Tok.getRawText().equals("override")))) {
30533053
/* We're OK */
30543054
} else {
30553055
// This 'class' is a real ClassDecl introducer.
@@ -3296,8 +3296,7 @@ static bool isParenthesizedUnowned(Parser &P) {
32963296
(P.Tok.getText() == "safe" || P.Tok.getText() == "unsafe");
32973297
}
32983298

3299-
3300-
bool Parser::isStartOfDecl() {
3299+
bool Parser::isStartOfSwiftDecl() {
33013300
// If this is obviously not the start of a decl, then we're done.
33023301
if (!isKeywordPossibleDeclStart(Tok)) return false;
33033302

@@ -3348,7 +3347,7 @@ bool Parser::isStartOfDecl() {
33483347
if (Tok.isAny(tok::r_brace, tok::eof, tok::pound_endif))
33493348
return true;
33503349

3351-
return isStartOfDecl();
3350+
return isStartOfSwiftDecl();
33523351
}
33533352

33543353
// Otherwise, the only hard case left is the identifier case.
@@ -3374,7 +3373,7 @@ bool Parser::isStartOfDecl() {
33743373
consumeToken(tok::l_paren);
33753374
consumeToken(tok::identifier);
33763375
consumeToken(tok::r_paren);
3377-
return isStartOfDecl();
3376+
return isStartOfSwiftDecl();
33783377
}
33793378

33803379
// If the next token is obviously not the start of a decl, bail early.
@@ -3384,7 +3383,7 @@ bool Parser::isStartOfDecl() {
33843383
// Otherwise, do a recursive parse.
33853384
Parser::BacktrackingScope Backtrack(*this);
33863385
consumeToken(tok::identifier);
3387-
return isStartOfDecl();
3386+
return isStartOfSwiftDecl();
33883387
}
33893388

33903389
void Parser::consumeDecl(ParserPosition BeginParserPosition,

lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3463,7 +3463,7 @@ ParserResult<Expr> Parser::parseExprCollection() {
34633463
// If The next token is at the beginning of a new line and can never start
34643464
// an element, break.
34653465
if (Tok.isAtStartOfLine() && (Tok.isAny(tok::r_brace, tok::pound_endif) ||
3466-
isStartOfDecl() || isStartOfStmt()))
3466+
isStartOfSwiftDecl() || isStartOfStmt()))
34673467
break;
34683468

34693469
diagnose(Tok, diag::expected_separator, ",")

lib/Parse/ParseStmt.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
401401
ParserStatus Status = parseLineDirective(false);
402402
BraceItemsStatus |= Status;
403403
NeedParseErrorRecovery = Status.isError();
404-
} else if (isStartOfDecl()) {
404+
} else if (isStartOfSwiftDecl()) {
405405
SmallVector<Decl*, 8> TmpDecls;
406406
ParserResult<Decl> DeclResult =
407407
parseDecl(IsTopLevel ? PD_AllowTopLevel : PD_Default,
@@ -703,7 +703,7 @@ ParserResult<Stmt> Parser::parseStmtBreak() {
703703
// since the expression after the break is dead, we don't feel bad eagerly
704704
// parsing this.
705705
if (Tok.is(tok::identifier) && !Tok.isAtStartOfLine() &&
706-
!isStartOfStmt() && !isStartOfDecl())
706+
!isStartOfStmt() && !isStartOfSwiftDecl())
707707
TargetLoc = consumeIdentifier(&Target);
708708

709709
return makeParserResult(new (Context) BreakStmt(Loc, Target, TargetLoc));
@@ -726,7 +726,7 @@ ParserResult<Stmt> Parser::parseStmtContinue() {
726726
// since the expression after the continue is dead, we don't feel bad eagerly
727727
// parsing this.
728728
if (Tok.is(tok::identifier) && !Tok.isAtStartOfLine() &&
729-
!isStartOfStmt() && !isStartOfDecl())
729+
!isStartOfStmt() && !isStartOfSwiftDecl())
730730
TargetLoc = consumeIdentifier(&Target);
731731

732732
return makeParserResult(new (Context) ContinueStmt(Loc, Target, TargetLoc));
@@ -759,7 +759,7 @@ ParserResult<Stmt> Parser::parseStmtReturn(SourceLoc tryLoc) {
759759
if (Tok.isNot(tok::r_brace, tok::semi, tok::eof, tok::pound_if,
760760
tok::pound_error, tok::pound_warning, tok::pound_endif,
761761
tok::pound_else, tok::pound_elseif) &&
762-
!isStartOfStmt() && !isStartOfDecl()) {
762+
!isStartOfStmt() && !isStartOfSwiftDecl()) {
763763
SourceLoc ExprLoc = Tok.getLoc();
764764

765765
// Issue a warning when the returned expression is on a different line than

lib/Parse/ParseType.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ bool Parser::canParseOldStyleProtocolComposition() {
16361636

16371637
bool Parser::canParseTypeTupleBody() {
16381638
if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::r_brace) &&
1639-
Tok.isNotEllipsis() && !isStartOfDecl()) {
1639+
Tok.isNotEllipsis() && !isStartOfSwiftDecl()) {
16401640
do {
16411641
// The contextual inout marker is part of argument lists.
16421642
consumeIf(tok::kw_inout);
@@ -1661,8 +1661,7 @@ bool Parser::canParseTypeTupleBody() {
16611661
if (consumeIf(tok::equal)) {
16621662
while (Tok.isNot(tok::eof) && Tok.isNot(tok::r_paren) &&
16631663
Tok.isNot(tok::r_brace) && Tok.isNotEllipsis() &&
1664-
Tok.isNot(tok::comma) &&
1665-
!isStartOfDecl()) {
1664+
Tok.isNot(tok::comma) && !isStartOfSwiftDecl()) {
16661665
skipSingle();
16671666
}
16681667
}

lib/Parse/Parser.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ SourceLoc Parser::skipUntilGreaterInTypeList(bool protocolComposition) {
713713
// 'Self' can appear in types, skip it.
714714
if (Tok.is(tok::kw_Self))
715715
break;
716-
if (isStartOfStmt() || isStartOfDecl() || Tok.is(tok::pound_endif))
716+
if (isStartOfStmt() || isStartOfSwiftDecl() || Tok.is(tok::pound_endif))
717717
return lastLoc;
718718
break;
719719

@@ -742,15 +742,15 @@ void Parser::skipUntilDeclRBrace() {
742742
while (Tok.isNot(tok::eof, tok::r_brace, tok::pound_endif,
743743
tok::pound_else, tok::pound_elseif,
744744
tok::code_complete) &&
745-
!isStartOfDecl())
745+
!isStartOfSwiftDecl())
746746
skipSingle();
747747
}
748748

749749
void Parser::skipUntilDeclStmtRBrace(tok T1) {
750750
while (Tok.isNot(T1, tok::eof, tok::r_brace, tok::pound_endif,
751751
tok::pound_else, tok::pound_elseif,
752752
tok::code_complete) &&
753-
!isStartOfStmt() && !isStartOfDecl()) {
753+
!isStartOfStmt() && !isStartOfSwiftDecl()) {
754754
skipSingle();
755755
}
756756
}
@@ -759,7 +759,7 @@ void Parser::skipUntilDeclStmtRBrace(tok T1, tok T2) {
759759
while (Tok.isNot(T1, T2, tok::eof, tok::r_brace, tok::pound_endif,
760760
tok::pound_else, tok::pound_elseif,
761761
tok::code_complete) &&
762-
!isStartOfStmt() && !isStartOfDecl()) {
762+
!isStartOfStmt() && !isStartOfSwiftDecl()) {
763763
skipSingle();
764764
}
765765
}
@@ -770,7 +770,7 @@ void Parser::skipListUntilDeclRBrace(SourceLoc startLoc, tok T1, tok T2) {
770770
bool hasDelimiter = Tok.getLoc() == startLoc || consumeIf(tok::comma);
771771
bool possibleDeclStartsLine = Tok.isAtStartOfLine();
772772

773-
if (isStartOfDecl()) {
773+
if (isStartOfSwiftDecl()) {
774774

775775
// Could have encountered something like `_ var:`
776776
// or `let foo:` or `var:`
@@ -800,7 +800,7 @@ void Parser::skipListUntilDeclRBrace(SourceLoc startLoc, tok T1, tok T2) {
800800
void Parser::skipUntilDeclRBrace(tok T1, tok T2) {
801801
while (Tok.isNot(T1, T2, tok::eof, tok::r_brace, tok::pound_endif,
802802
tok::pound_else, tok::pound_elseif) &&
803-
!isStartOfDecl()) {
803+
!isStartOfSwiftDecl()) {
804804
skipSingle();
805805
}
806806
}
@@ -1106,7 +1106,7 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
11061106
// If we're in a comma-separated list, the next token is at the
11071107
// beginning of a new line and can never start an element, break.
11081108
if (Tok.isAtStartOfLine() &&
1109-
(Tok.is(tok::r_brace) || isStartOfDecl() || isStartOfStmt())) {
1109+
(Tok.is(tok::r_brace) || isStartOfSwiftDecl() || isStartOfStmt())) {
11101110
break;
11111111
}
11121112
// If we found EOF or such, bailout.

0 commit comments

Comments
 (0)