Skip to content

Commit f86aad9

Browse files
[NFC] Extract computation of SILExtInfoBuilder bits into new method.
1 parent fdbcd12 commit f86aad9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

include/swift/AST/ExtInfo.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,15 @@ class SILExtInfoBuilder {
505505
SILExtInfoBuilder(unsigned bits, ClangTypeInfo clangTypeInfo)
506506
: bits(bits), clangTypeInfo(clangTypeInfo) {}
507507

508+
static constexpr unsigned makeBits(Representation rep, bool isPseudogeneric,
509+
bool isNoEscape, bool isAsync,
510+
DifferentiabilityKind diffKind) {
511+
return ((unsigned)rep) | (isPseudogeneric ? PseudogenericMask : 0) |
512+
(isNoEscape ? NoEscapeMask : 0) | (isAsync ? AsyncMask : 0) |
513+
(((unsigned)diffKind << DifferentiabilityMaskOffset) &
514+
DifferentiabilityMask);
515+
}
516+
508517
public:
509518
// Constructor with all defaults.
510519
SILExtInfoBuilder() : bits(0), clangTypeInfo(ClangTypeInfo(nullptr)) {}
@@ -513,12 +522,9 @@ class SILExtInfoBuilder {
513522
SILExtInfoBuilder(Representation rep, bool isPseudogeneric, bool isNoEscape,
514523
bool isAsync, DifferentiabilityKind diffKind,
515524
const clang::Type *type)
516-
: SILExtInfoBuilder(
517-
((unsigned)rep) | (isPseudogeneric ? PseudogenericMask : 0) |
518-
(isNoEscape ? NoEscapeMask : 0) | (isAsync ? AsyncMask : 0) |
519-
(((unsigned)diffKind << DifferentiabilityMaskOffset) &
520-
DifferentiabilityMask),
521-
ClangTypeInfo(type)) {}
525+
: SILExtInfoBuilder(makeBits(rep, isPseudogeneric, isNoEscape, isAsync,
526+
diffKind),
527+
ClangTypeInfo(type)) {}
522528

523529
void checkInvariants() const;
524530

0 commit comments

Comments
 (0)