@@ -422,6 +422,7 @@ namespace llvm {
422
422
// / exceeds the number of characters remaining in the string, the string
423
423
// / suffix (starting with \p Start) will be returned.
424
424
LLVM_ATTRIBUTE_ALWAYS_INLINE
425
+ LLVM_ATTRIBUTE_UNUSED_RESULT
425
426
StringRef substr (size_t Start, size_t N = npos) const {
426
427
Start = std::min (Start, Length);
427
428
return StringRef (Data + Start, std::min (N, Length - Start));
@@ -430,6 +431,7 @@ namespace llvm {
430
431
// / Return a StringRef equal to 'this' but with the first \p N elements
431
432
// / dropped.
432
433
LLVM_ATTRIBUTE_ALWAYS_INLINE
434
+ LLVM_ATTRIBUTE_UNUSED_RESULT
433
435
StringRef drop_front (size_t N = 1 ) const {
434
436
assert (size () >= N && " Dropping more elements than exist" );
435
437
return substr (N);
@@ -438,6 +440,7 @@ namespace llvm {
438
440
// / Return a StringRef equal to 'this' but with the last \p N elements
439
441
// / dropped.
440
442
LLVM_ATTRIBUTE_ALWAYS_INLINE
443
+ LLVM_ATTRIBUTE_UNUSED_RESULT
441
444
StringRef drop_back (size_t N = 1 ) const {
442
445
assert (size () >= N && " Dropping more elements than exist" );
443
446
return substr (0 , size ()-N);
@@ -455,6 +458,7 @@ namespace llvm {
455
458
// / will be returned. If this is less than \p Start, an empty string will
456
459
// / be returned.
457
460
LLVM_ATTRIBUTE_ALWAYS_INLINE
461
+ LLVM_ATTRIBUTE_UNUSED_RESULT
458
462
StringRef slice (size_t Start, size_t End) const {
459
463
Start = std::min (Start, Length);
460
464
End = std::min (std::max (Start, End), Length);
@@ -549,36 +553,42 @@ namespace llvm {
549
553
550
554
// / Return string with consecutive \p Char characters starting from the
551
555
// / the left removed.
556
+ LLVM_ATTRIBUTE_UNUSED_RESULT
552
557
StringRef ltrim (char Char) const {
553
558
return drop_front (std::min (Length, find_first_not_of (Char)));
554
559
}
555
560
556
561
// / Return string with consecutive characters in \p Chars starting from
557
562
// / the left removed.
563
+ LLVM_ATTRIBUTE_UNUSED_RESULT
558
564
StringRef ltrim (StringRef Chars = " \t\n\v\f\r " ) const {
559
565
return drop_front (std::min (Length, find_first_not_of (Chars)));
560
566
}
561
567
562
568
// / Return string with consecutive \p Char characters starting from the
563
569
// / right removed.
570
+ LLVM_ATTRIBUTE_UNUSED_RESULT
564
571
StringRef rtrim (char Char) const {
565
572
return drop_back (Length - std::min (Length, find_last_not_of (Char) + 1 ));
566
573
}
567
574
568
575
// / Return string with consecutive characters in \p Chars starting from
569
576
// / the right removed.
577
+ LLVM_ATTRIBUTE_UNUSED_RESULT
570
578
StringRef rtrim (StringRef Chars = " \t\n\v\f\r " ) const {
571
579
return drop_back (Length - std::min (Length, find_last_not_of (Chars) + 1 ));
572
580
}
573
581
574
582
// / Return string with consecutive \p Char characters starting from the
575
583
// / left and right removed.
584
+ LLVM_ATTRIBUTE_UNUSED_RESULT
576
585
StringRef trim (char Char) const {
577
586
return ltrim (Char).rtrim (Char);
578
587
}
579
588
580
589
// / Return string with consecutive characters in \p Chars starting from
581
590
// / the left and right removed.
591
+ LLVM_ATTRIBUTE_UNUSED_RESULT
582
592
StringRef trim (StringRef Chars = " \t\n\v\f\r " ) const {
583
593
return ltrim (Chars).rtrim (Chars);
584
594
}
0 commit comments