Skip to content

Commit 3882beb

Browse files
[NFC] Use consistent naming scheme for predicate methods. (swiftlang#33265)
bool throws() -> isThrowing(), bool async() -> isAsync()
1 parent ab04345 commit 3882beb

35 files changed

+87
-91
lines changed

include/swift/ABI/Metadata.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,8 +1634,8 @@ struct TargetFunctionTypeMetadata : public TargetMetadata<Runtime> {
16341634
FunctionMetadataConvention getConvention() const {
16351635
return Flags.getConvention();
16361636
}
1637-
bool async() const { return Flags.async(); }
1638-
bool throws() const { return Flags.throws(); }
1637+
bool isAsync() const { return Flags.isAsync(); }
1638+
bool isThrowing() const { return Flags.isThrowing(); }
16391639
bool hasParameterFlags() const { return Flags.hasParameterFlags(); }
16401640
bool isEscaping() const { return Flags.isEscaping(); }
16411641

include/swift/ABI/MetadataValues.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -855,13 +855,9 @@ class TargetFunctionTypeFlags {
855855
return FunctionMetadataConvention((Data&ConventionMask) >> ConventionShift);
856856
}
857857

858-
bool async() const {
859-
return bool(Data & AsyncMask);
860-
}
858+
bool isAsync() const { return bool(Data & AsyncMask); }
861859

862-
bool throws() const {
863-
return bool(Data & ThrowsMask);
864-
}
860+
bool isThrowing() const { return bool(Data & ThrowsMask); }
865861

866862
bool isEscaping() const {
867863
return bool (Data & EscapingMask);

include/swift/AST/ExtInfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ class ASTExtInfoBuilder {
240240

241241
constexpr bool isNoEscape() const { return bits & NoEscapeMask; }
242242

243-
constexpr bool async() const { return bits & AsyncMask; }
243+
constexpr bool isAsync() const { return bits & AsyncMask; }
244244

245-
constexpr bool throws() const { return bits & ThrowsMask; }
245+
constexpr bool isThrowing() const { return bits & ThrowsMask; }
246246

247247
constexpr DifferentiabilityKind getDifferentiabilityKind() const {
248248
return DifferentiabilityKind((bits & DifferentiabilityMask) >>
@@ -394,9 +394,9 @@ class ASTExtInfo {
394394

395395
constexpr bool isNoEscape() const { return builder.isNoEscape(); }
396396

397-
constexpr bool async() const { return builder.async(); }
397+
constexpr bool isAsync() const { return builder.isAsync(); }
398398

399-
constexpr bool throws() const { return builder.throws(); }
399+
constexpr bool isThrowing() const { return builder.isThrowing(); }
400400

401401
constexpr DifferentiabilityKind getDifferentiabilityKind() const {
402402
return builder.getDifferentiabilityKind();

include/swift/AST/TypeRepr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ class FunctionTypeRepr : public TypeRepr {
529529

530530
TupleTypeRepr *getArgsTypeRepr() const { return ArgsTy; }
531531
TypeRepr *getResultTypeRepr() const { return RetTy; }
532-
bool async() const { return AsyncLoc.isValid(); }
533-
bool throws() const { return ThrowsLoc.isValid(); }
532+
bool isAsync() const { return AsyncLoc.isValid(); }
533+
bool isThrowing() const { return ThrowsLoc.isValid(); }
534534

535535
SourceLoc getAsyncLoc() const { return AsyncLoc; }
536536
SourceLoc getThrowsLoc() const { return ThrowsLoc; }

include/swift/AST/Types.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,13 +3079,9 @@ class AnyFunctionType : public TypeBase {
30793079
return getExtInfo().isNoEscape();
30803080
}
30813081

3082-
bool async() const {
3083-
return getExtInfo().async();
3084-
}
3082+
bool isAsync() const { return getExtInfo().isAsync(); }
30853083

3086-
bool throws() const {
3087-
return getExtInfo().throws();
3088-
}
3084+
bool isThrowing() const { return getExtInfo().isThrowing(); }
30893085

30903086
bool isDifferentiable() const { return getExtInfo().isDifferentiable(); }
30913087
DifferentiabilityKind getDifferentiabilityKind() const {

include/swift/Remote/MetadataReader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,8 @@ class MetadataReader {
803803

804804
auto flags = FunctionTypeFlags()
805805
.withConvention(Function->getConvention())
806-
.withAsync(Function->async())
807-
.withThrows(Function->throws())
806+
.withAsync(Function->isAsync())
807+
.withThrows(Function->isThrowing())
808808
.withParameterFlags(Function->hasParameterFlags())
809809
.withEscaping(Function->isEscaping());
810810
auto BuiltFunction =

lib/AST/ASTDemangler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ Type ASTBuilder::createFunctionType(
406406
representation);
407407

408408
auto einfo =
409-
FunctionType::ExtInfoBuilder(representation, noescape, flags.throws(),
409+
FunctionType::ExtInfoBuilder(representation, noescape, flags.isThrowing(),
410410
diffKind, clangFunctionType)
411-
.withAsync(flags.async())
411+
.withAsync(flags.isAsync())
412412
.build();
413413

414414
return FunctionType::get(funcParams, output, einfo);

lib/AST/ASTDumper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,9 +2988,9 @@ class PrintTypeRepr : public TypeReprVisitor<PrintTypeRepr> {
29882988
void visitFunctionTypeRepr(FunctionTypeRepr *T) {
29892989
printCommon("type_function");
29902990
OS << '\n'; printRec(T->getArgsTypeRepr());
2991-
if (T->async())
2991+
if (T->isAsync())
29922992
OS << " async ";
2993-
if (T->throws())
2993+
if (T->isThrowing())
29942994
OS << " throws ";
29952995
OS << '\n'; printRec(T->getResultTypeRepr());
29962996
PrintWithColorRAII(OS, ParenthesisColor) << ')';
@@ -3760,8 +3760,8 @@ namespace {
37603760
getSILFunctionTypeRepresentationString(representation));
37613761

37623762
printFlag(!T->isNoEscape(), "escaping");
3763-
printFlag(T->async(), "async");
3764-
printFlag(T->throws(), "throws");
3763+
printFlag(T->isAsync(), "async");
3764+
printFlag(T->isThrowing(), "throws");
37653765

37663766
OS << "\n";
37673767
Indent += 2;

lib/AST/ASTMangler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,9 +2272,9 @@ void ASTMangler::appendFunctionSignature(AnyFunctionType *fn,
22722272
const ValueDecl *forDecl) {
22732273
appendFunctionResultType(fn->getResult(), forDecl);
22742274
appendFunctionInputType(fn->getParams(), forDecl);
2275-
if (fn->async())
2275+
if (fn->isAsync())
22762276
appendOperator("Y");
2277-
if (fn->throws())
2277+
if (fn->isThrowing())
22782278
appendOperator("K");
22792279
}
22802280

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4167,10 +4167,10 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
41674167
// If we're stripping argument labels from types, do it when printing.
41684168
visitAnyFunctionTypeParams(T->getParams(), /*printLabels*/false);
41694169

4170-
if (T->async())
4170+
if (T->isAsync())
41714171
Printer << " " << "async";
41724172

4173-
if (T->throws())
4173+
if (T->isThrowing())
41744174
Printer << " " << tok::kw_throws;
41754175

41764176
Printer << " -> ";
@@ -4210,10 +4210,10 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
42104210

42114211
visitAnyFunctionTypeParams(T->getParams(), /*printLabels*/true);
42124212

4213-
if (T->async())
4213+
if (T->isAsync())
42144214
Printer << " " << "async";
42154215

4216-
if (T->throws())
4216+
if (T->isThrowing())
42174217
Printer << " " << tok::kw_throws;
42184218

42194219
Printer << " -> ";

0 commit comments

Comments
 (0)