Skip to content

Commit a319546

Browse files
committed
NFC: clean up formatting.
Re-apply `git clang-format`.
1 parent 2def6ee commit a319546

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,15 +1037,14 @@ bool Parser::parseDifferentiableAttributeArguments(
10371037
return false;
10381038
}
10391039

1040-
// Helper function that returns the accessorkind if a token is an accessor label.
1041-
static Optional<AccessorKind> isAccessorLabel(const Token& token) {
1040+
// Helper function that returns the accessor kind if a token is an accessor
1041+
// label.
1042+
static Optional<AccessorKind> isAccessorLabel(const Token &token) {
10421043
if (token.is(tok::identifier)) {
10431044
StringRef tokText = token.getText();
1044-
for (auto accessor : allAccessorKinds()) {
1045-
if (tokText == getAccessorLabel(accessor)) {
1046-
return accessor;
1047-
}
1048-
}
1045+
for (auto accessor : allAccessorKinds())
1046+
if (tokText == getAccessorLabel(accessor))
1047+
return accessor;
10491048
}
10501049
return None;
10511050
}
@@ -1077,9 +1076,9 @@ static bool parseBaseTypeForQualifiedDeclName(Parser &P, TypeRepr *&baseType) {
10771076
// property with an accessor, this could be a type with a function
10781077
// name like an accessor.
10791078
if (P.Tok.is(tok::period)) {
1080-
const Token &nextToken = P.peekToken();
1081-
if (isAccessorLabel(nextToken) != None)
1082-
return false;
1079+
const Token &nextToken = P.peekToken();
1080+
if (isAccessorLabel(nextToken).hasValue())
1081+
return false;
10831082
}
10841083

10851084
backtrack.cancelBacktrack();
@@ -1106,36 +1105,35 @@ static bool parseQualifiedDeclName(Parser &P, Diag<> nameParseError,
11061105
TypeRepr *&baseType,
11071106
DeclNameRefWithLoc &original) {
11081107
{
1109-
SyntaxParsingContext DeclNameContext(P.SyntaxContext,
1110-
SyntaxKind::QualifiedDeclName);
1111-
// Parse base type.
1112-
if (parseBaseTypeForQualifiedDeclName(P, baseType))
1113-
return true;
1114-
// Parse final declaration name.
1115-
original.Name = P.parseDeclNameRef(
1116-
original.Loc, nameParseError,
1117-
Parser::DeclNameFlag::AllowZeroArgCompoundNames |
1118-
Parser::DeclNameFlag::AllowKeywordsUsingSpecialNames |
1119-
Parser::DeclNameFlag::AllowOperators);
1120-
// The base type is optional, but the final unqualified declaration name is
1121-
// not. If name could not be parsed, return true for error.
1122-
if (!original.Name)
1123-
return true;
1108+
SyntaxParsingContext DeclNameContext(P.SyntaxContext,
1109+
SyntaxKind::QualifiedDeclName);
1110+
// Parse base type.
1111+
if (parseBaseTypeForQualifiedDeclName(P, baseType))
1112+
return true;
1113+
// Parse final declaration name.
1114+
original.Name = P.parseDeclNameRef(
1115+
original.Loc, nameParseError,
1116+
Parser::DeclNameFlag::AllowZeroArgCompoundNames |
1117+
Parser::DeclNameFlag::AllowKeywordsUsingSpecialNames |
1118+
Parser::DeclNameFlag::AllowOperators);
1119+
// The base type is optional, but the final unqualified declaration name is
1120+
// not. If name could not be parsed, return true for error.
1121+
if (!original.Name)
1122+
return true;
11241123
}
11251124

11261125
// Parse an optional accessor kind.
11271126
if (P.Tok.is(tok::period)) {
1128-
const Token &nextToken = P.peekToken();
1129-
Optional<AccessorKind> kind = isAccessorLabel(nextToken);
1130-
if (kind != None) {
1131-
original.AccessorKind = kind;
1132-
P.consumeIf(tok::period);
1133-
P.consumeIf(tok::identifier);
1134-
}
1127+
const Token &nextToken = P.peekToken();
1128+
Optional<AccessorKind> kind = isAccessorLabel(nextToken);
1129+
if (kind.hasValue()) {
1130+
original.AccessorKind = kind;
1131+
P.consumeIf(tok::period);
1132+
P.consumeIf(tok::identifier);
1133+
}
11351134
}
11361135

11371136
return false;
1138-
11391137
}
11401138

11411139
/// Parse a `@derivative(of:)` attribute, returning true on error.

0 commit comments

Comments
 (0)