@@ -59,7 +59,7 @@ IntrinsicInfo::getOrCreateAttributes(ASTContext &Ctx) const {
59
59
Type swift::getBuiltinType(ASTContext &Context, StringRef Name) {
60
60
// Vectors are VecNxT, where "N" is the number of elements and
61
61
// T is the element type.
62
- if (Name.startswith ("Vec")) {
62
+ if (Name.starts_with ("Vec")) {
63
63
Name = Name.substr(3);
64
64
StringRef::size_type xPos = Name.find('x');
65
65
if (xPos == StringRef::npos)
@@ -2220,7 +2220,7 @@ llvm::Intrinsic::ID swift::getLLVMIntrinsicID(StringRef InName) {
2220
2220
using namespace llvm;
2221
2221
2222
2222
// Swift intrinsic names start with int_.
2223
- if (!InName.startswith ("int_"))
2223
+ if (!InName.starts_with ("int_"))
2224
2224
return llvm::Intrinsic::not_intrinsic;
2225
2225
InName = InName.drop_front(strlen("int_"));
2226
2226
@@ -2533,15 +2533,15 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
2533
2533
}
2534
2534
2535
2535
// If this starts with fence, we have special suffixes to handle.
2536
- if (OperationName.startswith ("ifdef_")) {
2536
+ if (OperationName.starts_with ("ifdef_")) {
2537
2537
OperationName = OperationName.drop_front(strlen("ifdef_"));
2538
2538
if (!Types.empty()) return nullptr;
2539
2539
if (OperationName.empty()) return nullptr;
2540
2540
return getIfdefOperation(Context, Id);
2541
2541
}
2542
2542
2543
2543
// If this starts with fence, we have special suffixes to handle.
2544
- if (OperationName.startswith ("fence_")) {
2544
+ if (OperationName.starts_with ("fence_")) {
2545
2545
OperationName = OperationName.drop_front(strlen("fence_"));
2546
2546
2547
2547
// Verify we have a single integer, floating point, or pointer type.
@@ -2554,7 +2554,7 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
2554
2554
OperationName = OperationName.substr(Underscore);
2555
2555
2556
2556
// Accept singlethread if present.
2557
- if (OperationName.startswith ("_singlethread"))
2557
+ if (OperationName.starts_with ("_singlethread"))
2558
2558
OperationName = OperationName.drop_front(strlen("_singlethread"));
2559
2559
// Nothing else is allowed in the name.
2560
2560
if (!OperationName.empty())
@@ -2563,7 +2563,7 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
2563
2563
}
2564
2564
2565
2565
// If this starts with cmpxchg, we have special suffixes to handle.
2566
- if (OperationName.startswith ("cmpxchg_")) {
2566
+ if (OperationName.starts_with ("cmpxchg_")) {
2567
2567
OperationName = OperationName.drop_front(strlen("cmpxchg_"));
2568
2568
2569
2569
// Verify we have a single integer, floating point, or pointer type.
@@ -2596,7 +2596,7 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
2596
2596
}
2597
2597
2598
2598
// If this starts with atomicrmw, we have special suffixes to handle.
2599
- if (OperationName.startswith ("atomicrmw_")) {
2599
+ if (OperationName.starts_with ("atomicrmw_")) {
2600
2600
OperationName = OperationName.drop_front(strlen("atomicrmw_"));
2601
2601
2602
2602
// Verify we have a single integer or pointer type.
@@ -2622,9 +2622,9 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
2622
2622
OperationName = OperationName.substr(Underscore);
2623
2623
2624
2624
// Accept volatile and singlethread if present.
2625
- if (OperationName.startswith ("_volatile"))
2625
+ if (OperationName.starts_with ("_volatile"))
2626
2626
OperationName = OperationName.drop_front(strlen("_volatile"));
2627
- if (OperationName.startswith ("_singlethread"))
2627
+ if (OperationName.starts_with ("_singlethread"))
2628
2628
OperationName = OperationName.drop_front(strlen("_singlethread"));
2629
2629
// Nothing else is allowed in the name.
2630
2630
if (!OperationName.empty())
@@ -2634,7 +2634,7 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
2634
2634
2635
2635
// If this starts with atomicload or atomicstore, we have special suffixes to
2636
2636
// handle.
2637
- if (OperationName.startswith ("atomicload_")) {
2637
+ if (OperationName.starts_with ("atomicload_")) {
2638
2638
OperationName = OperationName.drop_front(strlen("atomicload_"));
2639
2639
2640
2640
// Verify we have a single integer, floating point, or pointer type.
@@ -2651,16 +2651,16 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
2651
2651
OperationName = OperationName.substr(Underscore);
2652
2652
2653
2653
// Accept volatile and singlethread if present.
2654
- if (OperationName.startswith ("_volatile"))
2654
+ if (OperationName.starts_with ("_volatile"))
2655
2655
OperationName = OperationName.drop_front(strlen("_volatile"));
2656
- if (OperationName.startswith ("_singlethread"))
2656
+ if (OperationName.starts_with ("_singlethread"))
2657
2657
OperationName = OperationName.drop_front(strlen("_singlethread"));
2658
2658
// Nothing else is allowed in the name.
2659
2659
if (!OperationName.empty())
2660
2660
return nullptr;
2661
2661
return getAtomicLoadOperation(Context, Id, T);
2662
2662
}
2663
- if (OperationName.startswith ("atomicstore_")) {
2663
+ if (OperationName.starts_with ("atomicstore_")) {
2664
2664
OperationName = OperationName.drop_front(strlen("atomicstore_"));
2665
2665
2666
2666
// Verify we have a single integer, floating point, or pointer type.
@@ -2677,24 +2677,24 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
2677
2677
OperationName = OperationName.substr(Underscore);
2678
2678
2679
2679
// Accept volatile and singlethread if present.
2680
- if (OperationName.startswith ("_volatile"))
2680
+ if (OperationName.starts_with ("_volatile"))
2681
2681
OperationName = OperationName.drop_front(strlen("_volatile"));
2682
- if (OperationName.startswith ("_singlethread"))
2682
+ if (OperationName.starts_with ("_singlethread"))
2683
2683
OperationName = OperationName.drop_front(strlen("_singlethread"));
2684
2684
// Nothing else is allowed in the name.
2685
2685
if (!OperationName.empty())
2686
2686
return nullptr;
2687
2687
return getAtomicStoreOperation(Context, Id, T);
2688
2688
}
2689
- if (OperationName.startswith ("allocWithTailElems_")) {
2689
+ if (OperationName.starts_with ("allocWithTailElems_")) {
2690
2690
OperationName = OperationName.drop_front(strlen("allocWithTailElems_"));
2691
2691
int NumTailTypes = 0;
2692
2692
if (OperationName.getAsInteger(10, NumTailTypes))
2693
2693
return nullptr;
2694
2694
2695
2695
return getAllocWithTailElemsOperation(Context, Id, NumTailTypes);
2696
2696
}
2697
- if (OperationName.startswith ("applyDerivative_")) {
2697
+ if (OperationName.starts_with ("applyDerivative_")) {
2698
2698
AutoDiffDerivativeFunctionKind kind;
2699
2699
unsigned arity;
2700
2700
bool throws;
@@ -2704,7 +2704,7 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
2704
2704
return getAutoDiffApplyDerivativeFunction(Context, Id, kind, arity,
2705
2705
throws, /*thrownType=*/Type());
2706
2706
}
2707
- if (OperationName.startswith ("applyTranspose_")) {
2707
+ if (OperationName.starts_with ("applyTranspose_")) {
2708
2708
unsigned arity;
2709
2709
bool throws;
2710
2710
if (!autodiff::getBuiltinApplyTransposeConfig(
@@ -3317,7 +3317,7 @@ StringRef BuiltinType::getTypeName(SmallVectorImpl<char> &result,
3317
3317
llvm::raw_svector_ostream UnderlyingOS(UnderlyingStrVec);
3318
3318
t->getElementType().print(UnderlyingOS);
3319
3319
}
3320
- if (UnderlyingStrVec.startswith (BUILTIN_TYPE_NAME_PREFIX))
3320
+ if (UnderlyingStrVec.str().starts_with (BUILTIN_TYPE_NAME_PREFIX))
3321
3321
UnderlyingStr = UnderlyingStrVec.substr(8);
3322
3322
else
3323
3323
UnderlyingStr = UnderlyingStrVec;
0 commit comments