Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/ADT/StringRef.h
Line
Count
Source (jump to first uncovered line)
1
//===- StringRef.h - Constant String Reference Wrapper ----------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_ADT_STRINGREF_H
10
#define LLVM_ADT_STRINGREF_H
11
12
#include "llvm/ADT/STLExtras.h"
13
#include "llvm/ADT/iterator_range.h"
14
#include "llvm/Support/Compiler.h"
15
#include <algorithm>
16
#include <cassert>
17
#include <cstddef>
18
#include <cstring>
19
#include <limits>
20
#include <string>
21
#include <type_traits>
22
#include <utility>
23
24
namespace llvm {
25
26
  class APInt;
27
  class hash_code;
28
  template <typename T> class SmallVectorImpl;
29
  class StringRef;
30
31
  /// Helper functions for StringRef::getAsInteger.
32
  bool getAsUnsignedInteger(StringRef Str, unsigned Radix,
33
                            unsigned long long &Result);
34
35
  bool getAsSignedInteger(StringRef Str, unsigned Radix, long long &Result);
36
37
  bool consumeUnsignedInteger(StringRef &Str, unsigned Radix,
38
                              unsigned long long &Result);
39
  bool consumeSignedInteger(StringRef &Str, unsigned Radix, long long &Result);
40
41
  /// StringRef - Represent a constant reference to a string, i.e. a character
42
  /// array and a length, which need not be null terminated.
43
  ///
44
  /// This class does not own the string data, it is expected to be used in
45
  /// situations where the character data resides in some other buffer, whose
46
  /// lifetime extends past that of the StringRef. For this reason, it is not in
47
  /// general safe to store a StringRef.
48
  class StringRef {
49
  public:
50
    static const size_t npos = ~size_t(0);
51
52
    using iterator = const char *;
53
    using const_iterator = const char *;
54
    using size_type = size_t;
55
56
  private:
57
    /// The start of the string, in an external buffer.
58
    const char *Data = nullptr;
59
60
    /// The length of the string.
61
    size_t Length = 0;
62
63
    // Workaround memcmp issue with null pointers (undefined behavior)
64
    // by providing a specialized version
65
3.22G
    static int compareMemory(const char *Lhs, const char *Rhs, size_t Length) {
66
3.22G
      if (Length == 0) 
{ return 0; }15.9M
67
3.21G
      return ::memcmp(Lhs,Rhs,Length);
68
3.21G
    }
69
70
  public:
71
    /// @name Constructors
72
    /// @{
73
74
    /// Construct an empty string ref.
75
830M
    /*implicit*/ StringRef() = default;
76
77
    /// Disable conversion from nullptr.  This prevents things like
78
    /// if (S == nullptr)
79
    StringRef(std::nullptr_t) = delete;
80
81
    /// Construct a string ref from a cstring.
82
    /*implicit*/ StringRef(const char *Str)
83
6.53G
        : Data(Str), Length(Str ? ::strlen(Str) : 0) {}
84
85
    /// Construct a string ref from a pointer and length.
86
    /*implicit*/ constexpr StringRef(const char *data, size_t length)
87
4.89G
        : Data(data), Length(length) {}
88
89
    /// Construct a string ref from an std::string.
90
    /*implicit*/ StringRef(const std::string &Str)
91
3.33G
      : Data(Str.data()), Length(Str.length()) {}
92
93
0
    static StringRef withNullAsEmpty(const char *data) {
94
0
      return StringRef(data ? data : "");
95
0
    }
96
97
    /// @}
98
    /// @name Iterators
99
    /// @{
100
101
1.64G
    iterator begin() const { return Data; }
102
103
1.64G
    iterator end() const { return Data + Length; }
104
105
1.27G
    const unsigned char *bytes_begin() const {
106
1.27G
      return reinterpret_cast<const unsigned char *>(begin());
107
1.27G
    }
108
1.26G
    const unsigned char *bytes_end() const {
109
1.26G
      return reinterpret_cast<const unsigned char *>(end());
110
1.26G
    }
111
1.26G
    iterator_range<const unsigned char *> bytes() const {
112
1.26G
      return make_range(bytes_begin(), bytes_end());
113
1.26G
    }
114
115
    /// @}
116
    /// @name String Operations
117
    /// @{
118
119
    /// data - Get a pointer to the start of the string (which may not be null
120
    /// terminated).
121
    LLVM_NODISCARD
122
1.87G
    const char *data() const { return Data; }
123
124
    /// empty - Check if the string is empty.
125
    LLVM_NODISCARD
126
815M
    bool empty() const { return Length == 0; }
127
128
    /// size - Get the string size.
129
    LLVM_NODISCARD
130
2.62G
    size_t size() const { return Length; }
131
132
    /// front - Get the first character in the string.
133
    LLVM_NODISCARD
134
14.2M
    char front() const {
135
14.2M
      assert(!empty());
136
14.2M
      return Data[0];
137
14.2M
    }
138
139
    /// back - Get the last character in the string.
140
    LLVM_NODISCARD
141
7.26M
    char back() const {
142
7.26M
      assert(!empty());
143
7.26M
      return Data[Length-1];
144
7.26M
    }
145
146
    // copy - Allocate copy in Allocator and return StringRef to it.
147
    template <typename Allocator>
148
37.5k
    LLVM_NODISCARD StringRef copy(Allocator &A) const {
149
37.5k
      // Don't request a length 0 copy from the allocator.
150
37.5k
      if (empty())
151
124
        return StringRef();
152
37.4k
      char *S = A.template Allocate<char>(Length);
153
37.4k
      std::copy(begin(), end(), S);
154
37.4k
      return StringRef(S, Length);
155
37.4k
    }
llvm::StringRef llvm::StringRef::copy<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul> >(llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>&) const
Line
Count
Source
148
37.0k
    LLVM_NODISCARD StringRef copy(Allocator &A) const {
149
37.0k
      // Don't request a length 0 copy from the allocator.
150
37.0k
      if (empty())
151
113
        return StringRef();
152
36.9k
      char *S = A.template Allocate<char>(Length);
153
36.9k
      std::copy(begin(), end(), S);
154
36.9k
      return StringRef(S, Length);
155
36.9k
    }
llvm::StringRef llvm::StringRef::copy<clang::ASTContext>(clang::ASTContext&) const
Line
Count
Source
148
1
    LLVM_NODISCARD StringRef copy(Allocator &A) const {
149
1
      // Don't request a length 0 copy from the allocator.
150
1
      if (empty())
151
0
        return StringRef();
152
1
      char *S = A.template Allocate<char>(Length);
153
1
      std::copy(begin(), end(), S);
154
1
      return StringRef(S, Length);
155
1
    }
llvm::StringRef llvm::StringRef::copy<clang::ASTContext const>(clang::ASTContext const&) const
Line
Count
Source
148
581
    LLVM_NODISCARD StringRef copy(Allocator &A) const {
149
581
      // Don't request a length 0 copy from the allocator.
150
581
      if (empty())
151
11
        return StringRef();
152
570
      char *S = A.template Allocate<char>(Length);
153
570
      std::copy(begin(), end(), S);
154
570
      return StringRef(S, Length);
155
570
    }
156
157
    /// equals - Check for string equality, this is more efficient than
158
    /// compare() when the relative ordering of inequal strings isn't needed.
159
    LLVM_NODISCARD
160
20.1G
    bool equals(StringRef RHS) const {
161
20.1G
      return (Length == RHS.Length &&
162
20.1G
              
compareMemory(Data, RHS.Data, RHS.Length) == 01.89G
);
163
20.1G
    }
164
165
    /// equals_lower - Check for string equality, ignoring case.
166
    LLVM_NODISCARD
167
141M
    bool equals_lower(StringRef RHS) const {
168
141M
      return Length == RHS.Length && 
compare_lower(RHS) == 027.2M
;
169
141M
    }
170
171
    /// compare - Compare two strings; the result is -1, 0, or 1 if this string
172
    /// is lexicographically less than, equal to, or greater than the \p RHS.
173
    LLVM_NODISCARD
174
900M
    int compare(StringRef RHS) const {
175
900M
      // Check the prefix for a mismatch.
176
900M
      if (int Res = compareMemory(Data, RHS.Data, std::min(Length, RHS.Length)))
177
844M
        return Res < 0 ? 
-1463M
:
1381M
;
178
55.6M
179
55.6M
      // Otherwise the prefixes match, so we only need to check the lengths.
180
55.6M
      if (Length == RHS.Length)
181
35.9M
        return 0;
182
19.7M
      return Length < RHS.Length ? 
-16.69M
:
113.0M
;
183
19.7M
    }
184
185
    /// compare_lower - Compare two strings, ignoring case.
186
    LLVM_NODISCARD
187
    int compare_lower(StringRef RHS) const;
188
189
    /// compare_numeric - Compare two strings, treating sequences of digits as
190
    /// numbers.
191
    LLVM_NODISCARD
192
    int compare_numeric(StringRef RHS) const;
193
194
    /// Determine the edit distance between this string and another
195
    /// string.
196
    ///
197
    /// \param Other the string to compare this string against.
198
    ///
199
    /// \param AllowReplacements whether to allow character
200
    /// replacements (change one character into another) as a single
201
    /// operation, rather than as two operations (an insertion and a
202
    /// removal).
203
    ///
204
    /// \param MaxEditDistance If non-zero, the maximum edit distance that
205
    /// this routine is allowed to compute. If the edit distance will exceed
206
    /// that maximum, returns \c MaxEditDistance+1.
207
    ///
208
    /// \returns the minimum number of character insertions, removals,
209
    /// or (if \p AllowReplacements is \c true) replacements needed to
210
    /// transform one of the given strings into the other. If zero,
211
    /// the strings are identical.
212
    LLVM_NODISCARD
213
    unsigned edit_distance(StringRef Other, bool AllowReplacements = true,
214
                           unsigned MaxEditDistance = 0) const;
215
216
    /// str - Get the contents as an std::string.
217
    LLVM_NODISCARD
218
222M
    std::string str() const {
219
222M
      if (!Data) 
return std::string()1.28M
;
220
221M
      return std::string(Data, Length);
221
221M
    }
222
223
    /// @}
224
    /// @name Operator Overloads
225
    /// @{
226
227
    LLVM_NODISCARD
228
2.38G
    char operator[](size_t Index) const {
229
2.38G
      assert(Index < Length && "Invalid index!");
230
2.38G
      return Data[Index];
231
2.38G
    }
232
233
    /// Disallow accidental assignment from a temporary std::string.
234
    ///
235
    /// The declaration here is extra complicated so that `stringRef = {}`
236
    /// and `stringRef = "abc"` continue to select the move assignment operator.
237
    template <typename T>
238
    typename std::enable_if<std::is_same<T, std::string>::value,
239
                            StringRef>::type &
240
    operator=(T &&Str) = delete;
241
242
    /// @}
243
    /// @name Type Conversions
244
    /// @{
245
246
182M
    operator std::string() const {
247
182M
      return str();
248
182M
    }
249
250
    /// @}
251
    /// @name String Predicates
252
    /// @{
253
254
    /// Check if this string starts with the given \p Prefix.
255
    LLVM_NODISCARD
256
416M
    bool startswith(StringRef Prefix) const {
257
416M
      return Length >= Prefix.Length &&
258
416M
             
compareMemory(Data, Prefix.Data, Prefix.Length) == 0339M
;
259
416M
    }
260
261
    /// Check if this string starts with the given \p Prefix, ignoring case.
262
    LLVM_NODISCARD
263
    bool startswith_lower(StringRef Prefix) const;
264
265
    /// Check if this string ends with the given \p Suffix.
266
    LLVM_NODISCARD
267
109M
    bool endswith(StringRef Suffix) const {
268
109M
      return Length >= Suffix.Length &&
269
109M
        
compareMemory(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 092.9M
;
270
109M
    }
271
272
    /// Check if this string ends with the given \p Suffix, ignoring case.
273
    LLVM_NODISCARD
274
    bool endswith_lower(StringRef Suffix) const;
275
276
    /// @}
277
    /// @name String Searching
278
    /// @{
279
280
    /// Search for the first character \p C in the string.
281
    ///
282
    /// \returns The index of the first occurrence of \p C, or npos if not
283
    /// found.
284
    LLVM_NODISCARD
285
79.4M
    size_t find(char C, size_t From = 0) const {
286
79.4M
      size_t FindBegin = std::min(From, Length);
287
79.4M
      if (FindBegin < Length) { // Avoid calling memchr with nullptr.
288
77.3M
        // Just forward to memchr, which is faster than a hand-rolled loop.
289
77.3M
        if (const void *P = ::memchr(Data + FindBegin, C, Length - FindBegin))
290
10.6M
          return static_cast<const char *>(P) - Data;
291
68.8M
      }
292
68.8M
      return npos;
293
68.8M
    }
294
295
    /// Search for the first character \p C in the string, ignoring case.
296
    ///
297
    /// \returns The index of the first occurrence of \p C, or npos if not
298
    /// found.
299
    LLVM_NODISCARD
300
    size_t find_lower(char C, size_t From = 0) const;
301
302
    /// Search for the first character satisfying the predicate \p F
303
    ///
304
    /// \returns The index of the first character satisfying \p F starting from
305
    /// \p From, or npos if not found.
306
    LLVM_NODISCARD
307
154k
    size_t find_if(function_ref<bool(char)> F, size_t From = 0) const {
308
154k
      StringRef S = drop_front(From);
309
337k
      while (!S.empty()) {
310
336k
        if (F(S.front()))
311
153k
          return size() - S.size();
312
182k
        S = S.drop_front();
313
182k
      }
314
154k
      
return npos979
;
315
154k
    }
316
317
    /// Search for the first character not satisfying the predicate \p F
318
    ///
319
    /// \returns The index of the first character not satisfying \p F starting
320
    /// from \p From, or npos if not found.
321
    LLVM_NODISCARD
322
154k
    size_t find_if_not(function_ref<bool(char)> F, size_t From = 0) const {
323
335k
      return find_if([F](char c) { return !F(c); }, From);
324
154k
    }
325
326
    /// Search for the first string \p Str in the string.
327
    ///
328
    /// \returns The index of the first occurrence of \p Str, or npos if not
329
    /// found.
330
    LLVM_NODISCARD
331
    size_t find(StringRef Str, size_t From = 0) const;
332
333
    /// Search for the first string \p Str in the string, ignoring case.
334
    ///
335
    /// \returns The index of the first occurrence of \p Str, or npos if not
336
    /// found.
337
    LLVM_NODISCARD
338
    size_t find_lower(StringRef Str, size_t From = 0) const;
339
340
    /// Search for the last character \p C in the string.
341
    ///
342
    /// \returns The index of the last occurrence of \p C, or npos if not
343
    /// found.
344
    LLVM_NODISCARD
345
598k
    size_t rfind(char C, size_t From = npos) const {
346
598k
      From = std::min(From, Length);
347
598k
      size_t i = From;
348
3.62M
      while (i != 0) {
349
3.38M
        --i;
350
3.38M
        if (Data[i] == C)
351
353k
          return i;
352
3.38M
      }
353
598k
      
return npos245k
;
354
598k
    }
355
356
    /// Search for the last character \p C in the string, ignoring case.
357
    ///
358
    /// \returns The index of the last occurrence of \p C, or npos if not
359
    /// found.
360
    LLVM_NODISCARD
361
    size_t rfind_lower(char C, size_t From = npos) const;
362
363
    /// Search for the last string \p Str in the string.
364
    ///
365
    /// \returns The index of the last occurrence of \p Str, or npos if not
366
    /// found.
367
    LLVM_NODISCARD
368
    size_t rfind(StringRef Str) const;
369
370
    /// Search for the last string \p Str in the string, ignoring case.
371
    ///
372
    /// \returns The index of the last occurrence of \p Str, or npos if not
373
    /// found.
374
    LLVM_NODISCARD
375
    size_t rfind_lower(StringRef Str) const;
376
377
    /// Find the first character in the string that is \p C, or npos if not
378
    /// found. Same as find.
379
    LLVM_NODISCARD
380
8.74M
    size_t find_first_of(char C, size_t From = 0) const {
381
8.74M
      return find(C, From);
382
8.74M
    }
383
384
    /// Find the first character in the string that is in \p Chars, or npos if
385
    /// not found.
386
    ///
387
    /// Complexity: O(size() + Chars.size())
388
    LLVM_NODISCARD
389
    size_t find_first_of(StringRef Chars, size_t From = 0) const;
390
391
    /// Find the first character in the string that is not \p C or npos if not
392
    /// found.
393
    LLVM_NODISCARD
394
    size_t find_first_not_of(char C, size_t From = 0) const;
395
396
    /// Find the first character in the string that is not in the string
397
    /// \p Chars, or npos if not found.
398
    ///
399
    /// Complexity: O(size() + Chars.size())
400
    LLVM_NODISCARD
401
    size_t find_first_not_of(StringRef Chars, size_t From = 0) const;
402
403
    /// Find the last character in the string that is \p C, or npos if not
404
    /// found.
405
    LLVM_NODISCARD
406
345k
    size_t find_last_of(char C, size_t From = npos) const {
407
345k
      return rfind(C, From);
408
345k
    }
409
410
    /// Find the last character in the string that is in \p C, or npos if not
411
    /// found.
412
    ///
413
    /// Complexity: O(size() + Chars.size())
414
    LLVM_NODISCARD
415
    size_t find_last_of(StringRef Chars, size_t From = npos) const;
416
417
    /// Find the last character in the string that is not \p C, or npos if not
418
    /// found.
419
    LLVM_NODISCARD
420
    size_t find_last_not_of(char C, size_t From = npos) const;
421
422
    /// Find the last character in the string that is not in \p Chars, or
423
    /// npos if not found.
424
    ///
425
    /// Complexity: O(size() + Chars.size())
426
    LLVM_NODISCARD
427
    size_t find_last_not_of(StringRef Chars, size_t From = npos) const;
428
429
    /// Return true if the given string is a substring of *this, and false
430
    /// otherwise.
431
    LLVM_NODISCARD
432
115k
    bool contains(StringRef Other) const { return find(Other) != npos; }
433
434
    /// Return true if the given character is contained in *this, and false
435
    /// otherwise.
436
    LLVM_NODISCARD
437
5.50k
    bool contains(char C) const { return find_first_of(C) != npos; }
438
439
    /// Return true if the given string is a substring of *this, and false
440
    /// otherwise.
441
    LLVM_NODISCARD
442
3.23k
    bool contains_lower(StringRef Other) const {
443
3.23k
      return find_lower(Other) != npos;
444
3.23k
    }
445
446
    /// Return true if the given character is contained in *this, and false
447
    /// otherwise.
448
    LLVM_NODISCARD
449
0
    bool contains_lower(char C) const { return find_lower(C) != npos; }
450
451
    /// @}
452
    /// @name Helpful Algorithms
453
    /// @{
454
455
    /// Return the number of occurrences of \p C in the string.
456
    LLVM_NODISCARD
457
489k
    size_t count(char C) const {
458
489k
      size_t Count = 0;
459
11.4M
      for (size_t i = 0, e = Length; i != e; 
++i10.9M
)
460
10.9M
        if (Data[i] == C)
461
132k
          ++Count;
462
489k
      return Count;
463
489k
    }
464
465
    /// Return the number of non-overlapped occurrences of \p Str in
466
    /// the string.
467
    size_t count(StringRef Str) const;
468
469
    /// Parse the current string as an integer of the specified radix.  If
470
    /// \p Radix is specified as zero, this does radix autosensing using
471
    /// extended C rules: 0 is octal, 0x is hex, 0b is binary.
472
    ///
473
    /// If the string is invalid or if only a subset of the string is valid,
474
    /// this returns true to signify the error.  The string is considered
475
    /// erroneous if empty or if it overflows T.
476
    template <typename T>
477
    typename std::enable_if<std::numeric_limits<T>::is_signed, bool>::type
478
140k
    getAsInteger(unsigned Radix, T &Result) const {
479
140k
      long long LLVal;
480
140k
      if (getAsSignedInteger(*this, Radix, LLVal) ||
481
140k
            
static_cast<T>(LLVal) != LLVal140k
)
482
207
        return true;
483
140k
      Result = LLVal;
484
140k
      return false;
485
140k
    }
std::__1::enable_if<std::numeric_limits<long long>::is_signed, bool>::type llvm::StringRef::getAsInteger<long long>(unsigned int, long long&) const
Line
Count
Source
478
4.56k
    getAsInteger(unsigned Radix, T &Result) const {
479
4.56k
      long long LLVal;
480
4.56k
      if (getAsSignedInteger(*this, Radix, LLVal) ||
481
4.56k
            
static_cast<T>(LLVal) != LLVal4.51k
)
482
51
        return true;
483
4.51k
      Result = LLVal;
484
4.51k
      return false;
485
4.51k
    }
std::__1::enable_if<std::numeric_limits<int>::is_signed, bool>::type llvm::StringRef::getAsInteger<int>(unsigned int, int&) const
Line
Count
Source
478
136k
    getAsInteger(unsigned Radix, T &Result) const {
479
136k
      long long LLVal;
480
136k
      if (getAsSignedInteger(*this, Radix, LLVal) ||
481
136k
            
static_cast<T>(LLVal) != LLVal135k
)
482
156
        return true;
483
135k
      Result = LLVal;
484
135k
      return false;
485
135k
    }
486
487
    template <typename T>
488
    typename std::enable_if<!std::numeric_limits<T>::is_signed, bool>::type
489
8.74M
    getAsInteger(unsigned Radix, T &Result) const {
490
8.74M
      unsigned long long ULLVal;
491
8.74M
      // The additional cast to unsigned long long is required to avoid the
492
8.74M
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
8.74M
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
8.74M
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
8.74M
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal8.60M
)
496
140k
        return true;
497
8.60M
      Result = ULLVal;
498
8.60M
      return false;
499
8.60M
    }
std::__1::enable_if<!(std::numeric_limits<unsigned int>::is_signed), bool>::type llvm::StringRef::getAsInteger<unsigned int>(unsigned int, unsigned int&) const
Line
Count
Source
489
7.64M
    getAsInteger(unsigned Radix, T &Result) const {
490
7.64M
      unsigned long long ULLVal;
491
7.64M
      // The additional cast to unsigned long long is required to avoid the
492
7.64M
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
7.64M
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
7.64M
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
7.64M
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal7.50M
)
496
139k
        return true;
497
7.50M
      Result = ULLVal;
498
7.50M
      return false;
499
7.50M
    }
std::__1::enable_if<!(std::numeric_limits<unsigned long>::is_signed), bool>::type llvm::StringRef::getAsInteger<unsigned long>(unsigned int, unsigned long&) const
Line
Count
Source
489
1.44k
    getAsInteger(unsigned Radix, T &Result) const {
490
1.44k
      unsigned long long ULLVal;
491
1.44k
      // The additional cast to unsigned long long is required to avoid the
492
1.44k
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
1.44k
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
1.44k
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
1.44k
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal1.44k
)
496
2
        return true;
497
1.44k
      Result = ULLVal;
498
1.44k
      return false;
499
1.44k
    }
std::__1::enable_if<!(std::numeric_limits<unsigned char>::is_signed), bool>::type llvm::StringRef::getAsInteger<unsigned char>(unsigned int, unsigned char&) const
Line
Count
Source
489
2.30k
    getAsInteger(unsigned Radix, T &Result) const {
490
2.30k
      unsigned long long ULLVal;
491
2.30k
      // The additional cast to unsigned long long is required to avoid the
492
2.30k
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
2.30k
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
2.30k
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
2.30k
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal2.28k
)
496
22
        return true;
497
2.28k
      Result = ULLVal;
498
2.28k
      return false;
499
2.28k
    }
std::__1::enable_if<!(std::numeric_limits<unsigned long long>::is_signed), bool>::type llvm::StringRef::getAsInteger<unsigned long long>(unsigned int, unsigned long long&) const
Line
Count
Source
489
1.09M
    getAsInteger(unsigned Radix, T &Result) const {
490
1.09M
      unsigned long long ULLVal;
491
1.09M
      // The additional cast to unsigned long long is required to avoid the
492
1.09M
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
1.09M
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
1.09M
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
1.09M
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal1.09M
)
496
1.57k
        return true;
497
1.09M
      Result = ULLVal;
498
1.09M
      return false;
499
1.09M
    }
std::__1::enable_if<!(std::numeric_limits<unsigned short>::is_signed), bool>::type llvm::StringRef::getAsInteger<unsigned short>(unsigned int, unsigned short&) const
Line
Count
Source
489
80
    getAsInteger(unsigned Radix, T &Result) const {
490
80
      unsigned long long ULLVal;
491
80
      // The additional cast to unsigned long long is required to avoid the
492
80
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
80
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
80
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
80
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal75
)
496
9
        return true;
497
71
      Result = ULLVal;
498
71
      return false;
499
71
    }
std::__1::enable_if<!(std::numeric_limits<bool>::is_signed), bool>::type llvm::StringRef::getAsInteger<bool>(unsigned int, bool&) const
Line
Count
Source
489
16
    getAsInteger(unsigned Radix, T &Result) const {
490
16
      unsigned long long ULLVal;
491
16
      // The additional cast to unsigned long long is required to avoid the
492
16
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
16
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
16
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
16
          static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal)
496
0
        return true;
497
16
      Result = ULLVal;
498
16
      return false;
499
16
    }
500
501
    /// Parse the current string as an integer of the specified radix.  If
502
    /// \p Radix is specified as zero, this does radix autosensing using
503
    /// extended C rules: 0 is octal, 0x is hex, 0b is binary.
504
    ///
505
    /// If the string does not begin with a number of the specified radix,
506
    /// this returns true to signify the error. The string is considered
507
    /// erroneous if empty or if it overflows T.
508
    /// The portion of the string representing the discovered numeric value
509
    /// is removed from the beginning of the string.
510
    template <typename T>
511
    typename std::enable_if<std::numeric_limits<T>::is_signed, bool>::type
512
    consumeInteger(unsigned Radix, T &Result) {
513
      long long LLVal;
514
      if (consumeSignedInteger(*this, Radix, LLVal) ||
515
          static_cast<long long>(static_cast<T>(LLVal)) != LLVal)
516
        return true;
517
      Result = LLVal;
518
      return false;
519
    }
520
521
    template <typename T>
522
    typename std::enable_if<!std::numeric_limits<T>::is_signed, bool>::type
523
250k
    consumeInteger(unsigned Radix, T &Result) {
524
250k
      unsigned long long ULLVal;
525
250k
      if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
526
250k
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal228k
)
527
21.5k
        return true;
528
228k
      Result = ULLVal;
529
228k
      return false;
530
228k
    }
std::__1::enable_if<!(std::numeric_limits<unsigned long>::is_signed), bool>::type llvm::StringRef::consumeInteger<unsigned long>(unsigned int, unsigned long&)
Line
Count
Source
523
189k
    consumeInteger(unsigned Radix, T &Result) {
524
189k
      unsigned long long ULLVal;
525
189k
      if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
526
189k
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal167k
)
527
21.5k
        return true;
528
167k
      Result = ULLVal;
529
167k
      return false;
530
167k
    }
std::__1::enable_if<!(std::numeric_limits<unsigned int>::is_signed), bool>::type llvm::StringRef::consumeInteger<unsigned int>(unsigned int, unsigned int&)
Line
Count
Source
523
60.9k
    consumeInteger(unsigned Radix, T &Result) {
524
60.9k
      unsigned long long ULLVal;
525
60.9k
      if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
526
60.9k
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal60.9k
)
527
4
        return true;
528
60.9k
      Result = ULLVal;
529
60.9k
      return false;
530
60.9k
    }
std::__1::enable_if<!(std::numeric_limits<unsigned long long>::is_signed), bool>::type llvm::StringRef::consumeInteger<unsigned long long>(unsigned int, unsigned long long&)
Line
Count
Source
523
46
    consumeInteger(unsigned Radix, T &Result) {
524
46
      unsigned long long ULLVal;
525
46
      if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
526
46
          static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal)
527
0
        return true;
528
46
      Result = ULLVal;
529
46
      return false;
530
46
    }
std::__1::enable_if<!(std::numeric_limits<unsigned char>::is_signed), bool>::type llvm::StringRef::consumeInteger<unsigned char>(unsigned int, unsigned char&)
Line
Count
Source
523
26
    consumeInteger(unsigned Radix, T &Result) {
524
26
      unsigned long long ULLVal;
525
26
      if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
526
26
          static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal)
527
7
        return true;
528
19
      Result = ULLVal;
529
19
      return false;
530
19
    }
531
532
    /// Parse the current string as an integer of the specified \p Radix, or of
533
    /// an autosensed radix if the \p Radix given is 0.  The current value in
534
    /// \p Result is discarded, and the storage is changed to be wide enough to
535
    /// store the parsed integer.
536
    ///
537
    /// \returns true if the string does not solely consist of a valid
538
    /// non-empty number in the appropriate base.
539
    ///
540
    /// APInt::fromString is superficially similar but assumes the
541
    /// string is well-formed in the given radix.
542
    bool getAsInteger(unsigned Radix, APInt &Result) const;
543
544
    /// Parse the current string as an IEEE double-precision floating
545
    /// point value.  The string must be a well-formed double.
546
    ///
547
    /// If \p AllowInexact is false, the function will fail if the string
548
    /// cannot be represented exactly.  Otherwise, the function only fails
549
    /// in case of an overflow or underflow.
550
    bool getAsDouble(double &Result, bool AllowInexact = true) const;
551
552
    /// @}
553
    /// @name String Operations
554
    /// @{
555
556
    // Convert the given ASCII string to lowercase.
557
    LLVM_NODISCARD
558
    std::string lower() const;
559
560
    /// Convert the given ASCII string to uppercase.
561
    LLVM_NODISCARD
562
    std::string upper() const;
563
564
    /// @}
565
    /// @name Substring Operations
566
    /// @{
567
568
    /// Return a reference to the substring from [Start, Start + N).
569
    ///
570
    /// \param Start The index of the starting character in the substring; if
571
    /// the index is npos or greater than the length of the string then the
572
    /// empty substring will be returned.
573
    ///
574
    /// \param N The number of characters to included in the substring. If N
575
    /// exceeds the number of characters remaining in the string, the string
576
    /// suffix (starting with \p Start) will be returned.
577
    LLVM_NODISCARD
578
292M
    StringRef substr(size_t Start, size_t N = npos) const {
579
292M
      Start = std::min(Start, Length);
580
292M
      return StringRef(Data + Start, std::min(N, Length - Start));
581
292M
    }
582
583
    /// Return a StringRef equal to 'this' but with only the first \p N
584
    /// elements remaining.  If \p N is greater than the length of the
585
    /// string, the entire string is returned.
586
    LLVM_NODISCARD
587
27.0k
    StringRef take_front(size_t N = 1) const {
588
27.0k
      if (N >= size())
589
19.5k
        return *this;
590
7.50k
      return drop_back(size() - N);
591
7.50k
    }
592
593
    /// Return a StringRef equal to 'this' but with only the last \p N
594
    /// elements remaining.  If \p N is greater than the length of the
595
    /// string, the entire string is returned.
596
    LLVM_NODISCARD
597
7.56k
    StringRef take_back(size_t N = 1) const {
598
7.56k
      if (N >= size())
599
1
        return *this;
600
7.56k
      return drop_front(size() - N);
601
7.56k
    }
602
603
    /// Return the longest prefix of 'this' such that every character
604
    /// in the prefix satisfies the given predicate.
605
    LLVM_NODISCARD
606
153k
    StringRef take_while(function_ref<bool(char)> F) const {
607
153k
      return substr(0, find_if_not(F));
608
153k
    }
609
610
    /// Return the longest prefix of 'this' such that no character in
611
    /// the prefix satisfies the given predicate.
612
    LLVM_NODISCARD
613
6
    StringRef take_until(function_ref<bool(char)> F) const {
614
6
      return substr(0, find_if(F));
615
6
    }
616
617
    /// Return a StringRef equal to 'this' but with the first \p N elements
618
    /// dropped.
619
    LLVM_NODISCARD
620
44.1M
    StringRef drop_front(size_t N = 1) const {
621
44.1M
      assert(size() >= N && "Dropping more elements than exist");
622
44.1M
      return substr(N);
623
44.1M
    }
624
625
    /// Return a StringRef equal to 'this' but with the last \p N elements
626
    /// dropped.
627
    LLVM_NODISCARD
628
89.0M
    StringRef drop_back(size_t N = 1) const {
629
89.0M
      assert(size() >= N && "Dropping more elements than exist");
630
89.0M
      return substr(0, size()-N);
631
89.0M
    }
632
633
    /// Return a StringRef equal to 'this', but with all characters satisfying
634
    /// the given predicate dropped from the beginning of the string.
635
    LLVM_NODISCARD
636
    StringRef drop_while(function_ref<bool(char)> F) const {
637
      return substr(find_if_not(F));
638
    }
639
640
    /// Return a StringRef equal to 'this', but with all characters not
641
    /// satisfying the given predicate dropped from the beginning of the string.
642
    LLVM_NODISCARD
643
39
    StringRef drop_until(function_ref<bool(char)> F) const {
644
39
      return substr(find_if(F));
645
39
    }
646
647
    /// Returns true if this StringRef has the given prefix and removes that
648
    /// prefix.
649
23.7M
    bool consume_front(StringRef Prefix) {
650
23.7M
      if (!startswith(Prefix))
651
392k
        return false;
652
23.3M
653
23.3M
      *this = drop_front(Prefix.size());
654
23.3M
      return true;
655
23.3M
    }
656
657
    /// Returns true if this StringRef has the given suffix and removes that
658
    /// suffix.
659
91.2k
    bool consume_back(StringRef Suffix) {
660
91.2k
      if (!endswith(Suffix))
661
89.9k
        return false;
662
1.34k
663
1.34k
      *this = drop_back(Suffix.size());
664
1.34k
      return true;
665
1.34k
    }
666
667
    /// Return a reference to the substring from [Start, End).
668
    ///
669
    /// \param Start The index of the starting character in the substring; if
670
    /// the index is npos or greater than the length of the string then the
671
    /// empty substring will be returned.
672
    ///
673
    /// \param End The index following the last character to include in the
674
    /// substring. If this is npos or exceeds the number of characters
675
    /// remaining in the string, the string suffix (starting with \p Start)
676
    /// will be returned. If this is less than \p Start, an empty string will
677
    /// be returned.
678
    LLVM_NODISCARD
679
71.0M
    StringRef slice(size_t Start, size_t End) const {
680
71.0M
      Start = std::min(Start, Length);
681
71.0M
      End = std::min(std::max(Start, End), Length);
682
71.0M
      return StringRef(Data + Start, End - Start);
683
71.0M
    }
684
685
    /// Split into two substrings around the first occurrence of a separator
686
    /// character.
687
    ///
688
    /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
689
    /// such that (*this == LHS + Separator + RHS) is true and RHS is
690
    /// maximal. If \p Separator is not in the string, then the result is a
691
    /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
692
    ///
693
    /// \param Separator The character to split on.
694
    /// \returns The split substrings.
695
    LLVM_NODISCARD
696
6.31M
    std::pair<StringRef, StringRef> split(char Separator) const {
697
6.31M
      return split(StringRef(&Separator, 1));
698
6.31M
    }
699
700
    /// Split into two substrings around the first occurrence of a separator
701
    /// string.
702
    ///
703
    /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
704
    /// such that (*this == LHS + Separator + RHS) is true and RHS is
705
    /// maximal. If \p Separator is not in the string, then the result is a
706
    /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
707
    ///
708
    /// \param Separator - The string to split on.
709
    /// \return - The split substrings.
710
    LLVM_NODISCARD
711
6.37M
    std::pair<StringRef, StringRef> split(StringRef Separator) const {
712
6.37M
      size_t Idx = find(Separator);
713
6.37M
      if (Idx == npos)
714
2.43M
        return std::make_pair(*this, StringRef());
715
3.94M
      return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
716
3.94M
    }
717
718
    /// Split into two substrings around the last occurrence of a separator
719
    /// string.
720
    ///
721
    /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
722
    /// such that (*this == LHS + Separator + RHS) is true and RHS is
723
    /// minimal. If \p Separator is not in the string, then the result is a
724
    /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
725
    ///
726
    /// \param Separator - The string to split on.
727
    /// \return - The split substrings.
728
    LLVM_NODISCARD
729
460k
    std::pair<StringRef, StringRef> rsplit(StringRef Separator) const {
730
460k
      size_t Idx = rfind(Separator);
731
460k
      if (Idx == npos)
732
153k
        return std::make_pair(*this, StringRef());
733
307k
      return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
734
307k
    }
735
736
    /// Split into substrings around the occurrences of a separator string.
737
    ///
738
    /// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most
739
    /// \p MaxSplit splits are done and consequently <= \p MaxSplit + 1
740
    /// elements are added to A.
741
    /// If \p KeepEmpty is false, empty strings are not added to \p A. They
742
    /// still count when considering \p MaxSplit
743
    /// An useful invariant is that
744
    /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true
745
    ///
746
    /// \param A - Where to put the substrings.
747
    /// \param Separator - The string to split on.
748
    /// \param MaxSplit - The maximum number of times the string is split.
749
    /// \param KeepEmpty - True if empty substring should be added.
750
    void split(SmallVectorImpl<StringRef> &A,
751
               StringRef Separator, int MaxSplit = -1,
752
               bool KeepEmpty = true) const;
753
754
    /// Split into substrings around the occurrences of a separator character.
755
    ///
756
    /// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most
757
    /// \p MaxSplit splits are done and consequently <= \p MaxSplit + 1
758
    /// elements are added to A.
759
    /// If \p KeepEmpty is false, empty strings are not added to \p A. They
760
    /// still count when considering \p MaxSplit
761
    /// An useful invariant is that
762
    /// Separator.join(A) == *this if MaxSplit == -1 and KeepEmpty == true
763
    ///
764
    /// \param A - Where to put the substrings.
765
    /// \param Separator - The string to split on.
766
    /// \param MaxSplit - The maximum number of times the string is split.
767
    /// \param KeepEmpty - True if empty substring should be added.
768
    void split(SmallVectorImpl<StringRef> &A, char Separator, int MaxSplit = -1,
769
               bool KeepEmpty = true) const;
770
771
    /// Split into two substrings around the last occurrence of a separator
772
    /// character.
773
    ///
774
    /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
775
    /// such that (*this == LHS + Separator + RHS) is true and RHS is
776
    /// minimal. If \p Separator is not in the string, then the result is a
777
    /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
778
    ///
779
    /// \param Separator - The character to split on.
780
    /// \return - The split substrings.
781
    LLVM_NODISCARD
782
460k
    std::pair<StringRef, StringRef> rsplit(char Separator) const {
783
460k
      return rsplit(StringRef(&Separator, 1));
784
460k
    }
785
786
    /// Return string with consecutive \p Char characters starting from the
787
    /// the left removed.
788
    LLVM_NODISCARD
789
355
    StringRef ltrim(char Char) const {
790
355
      return drop_front(std::min(Length, find_first_not_of(Char)));
791
355
    }
792
793
    /// Return string with consecutive characters in \p Chars starting from
794
    /// the left removed.
795
    LLVM_NODISCARD
796
5.04M
    StringRef ltrim(StringRef Chars = " \t\n\v\f\r") const {
797
5.04M
      return drop_front(std::min(Length, find_first_not_of(Chars)));
798
5.04M
    }
799
800
    /// Return string with consecutive \p Char characters starting from the
801
    /// right removed.
802
    LLVM_NODISCARD
803
423k
    StringRef rtrim(char Char) const {
804
423k
      return drop_back(Length - std::min(Length, find_last_not_of(Char) + 1));
805
423k
    }
806
807
    /// Return string with consecutive characters in \p Chars starting from
808
    /// the right removed.
809
    LLVM_NODISCARD
810
1.97M
    StringRef rtrim(StringRef Chars = " \t\n\v\f\r") const {
811
1.97M
      return drop_back(Length - std::min(Length, find_last_not_of(Chars) + 1));
812
1.97M
    }
813
814
    /// Return string with consecutive \p Char characters starting from the
815
    /// left and right removed.
816
    LLVM_NODISCARD
817
15
    StringRef trim(char Char) const {
818
15
      return ltrim(Char).rtrim(Char);
819
15
    }
820
821
    /// Return string with consecutive characters in \p Chars starting from
822
    /// the left and right removed.
823
    LLVM_NODISCARD
824
1.88M
    StringRef trim(StringRef Chars = " \t\n\v\f\r") const {
825
1.88M
      return ltrim(Chars).rtrim(Chars);
826
1.88M
    }
827
828
    /// @}
829
  };
830
831
  /// A wrapper around a string literal that serves as a proxy for constructing
832
  /// global tables of StringRefs with the length computed at compile time.
833
  /// In order to avoid the invocation of a global constructor, StringLiteral
834
  /// should *only* be used in a constexpr context, as such:
835
  ///
836
  /// constexpr StringLiteral S("test");
837
  ///
838
  class StringLiteral : public StringRef {
839
  private:
840
1.09M
    constexpr StringLiteral(const char *Str, size_t N) : StringRef(Str, N) {
841
1.09M
    }
842
843
  public:
844
    template <size_t N>
845
    constexpr StringLiteral(const char (&Str)[N])
846
#if defined(__clang__) && __has_attribute(enable_if)
847
#pragma clang diagnostic push
848
#pragma clang diagnostic ignored "-Wgcc-compat"
849
        __attribute((enable_if(__builtin_strlen(Str) == N - 1,
850
                               "invalid string literal")))
851
#pragma clang diagnostic pop
852
#endif
853
1.48G
        : StringRef(Str, N - 1) {
854
1.48G
    }
llvm::StringLiteral::StringLiteral<5ul>(char const (&) [5ul]) [enable_if:(__builtin_strlen(fp)) == ((5ul) - (1))]
Line
Count
Source
853
177M
        : StringRef(Str, N - 1) {
854
177M
    }
llvm::StringLiteral::StringLiteral<9ul>(char const (&) [9ul]) [enable_if:(__builtin_strlen(fp)) == ((9ul) - (1))]
Line
Count
Source
853
71.8M
        : StringRef(Str, N - 1) {
854
71.8M
    }
llvm::StringLiteral::StringLiteral<4ul>(char const (&) [4ul]) [enable_if:(__builtin_strlen(fp)) == ((4ul) - (1))]
Line
Count
Source
853
230M
        : StringRef(Str, N - 1) {
854
230M
    }
llvm::StringLiteral::StringLiteral<8ul>(char const (&) [8ul]) [enable_if:(__builtin_strlen(fp)) == ((8ul) - (1))]
Line
Count
Source
853
115M
        : StringRef(Str, N - 1) {
854
115M
    }
llvm::StringLiteral::StringLiteral<7ul>(char const (&) [7ul]) [enable_if:(__builtin_strlen(fp)) == ((7ul) - (1))]
Line
Count
Source
853
132M
        : StringRef(Str, N - 1) {
854
132M
    }
llvm::StringLiteral::StringLiteral<3ul>(char const (&) [3ul]) [enable_if:(__builtin_strlen(fp)) == ((3ul) - (1))]
Line
Count
Source
853
49.9M
        : StringRef(Str, N - 1) {
854
49.9M
    }
llvm::StringLiteral::StringLiteral<1ul>(char const (&) [1ul]) [enable_if:(__builtin_strlen(fp)) == ((1ul) - (1))]
Line
Count
Source
853
166k
        : StringRef(Str, N - 1) {
854
166k
    }
llvm::StringLiteral::StringLiteral<6ul>(char const (&) [6ul]) [enable_if:(__builtin_strlen(fp)) == ((6ul) - (1))]
Line
Count
Source
853
135M
        : StringRef(Str, N - 1) {
854
135M
    }
llvm::StringLiteral::StringLiteral<10ul>(char const (&) [10ul]) [enable_if:(__builtin_strlen(fp)) == ((10ul) - (1))]
Line
Count
Source
853
30.8M
        : StringRef(Str, N - 1) {
854
30.8M
    }
llvm::StringLiteral::StringLiteral<11ul>(char const (&) [11ul]) [enable_if:(__builtin_strlen(fp)) == ((11ul) - (1))]
Line
Count
Source
853
61.9M
        : StringRef(Str, N - 1) {
854
61.9M
    }
llvm::StringLiteral::StringLiteral<13ul>(char const (&) [13ul]) [enable_if:(__builtin_strlen(fp)) == ((13ul) - (1))]
Line
Count
Source
853
17.7M
        : StringRef(Str, N - 1) {
854
17.7M
    }
llvm::StringLiteral::StringLiteral<12ul>(char const (&) [12ul]) [enable_if:(__builtin_strlen(fp)) == ((12ul) - (1))]
Line
Count
Source
853
30.8M
        : StringRef(Str, N - 1) {
854
30.8M
    }
llvm::StringLiteral::StringLiteral<15ul>(char const (&) [15ul]) [enable_if:(__builtin_strlen(fp)) == ((15ul) - (1))]
Line
Count
Source
853
31.4M
        : StringRef(Str, N - 1) {
854
31.4M
    }
llvm::StringLiteral::StringLiteral<14ul>(char const (&) [14ul]) [enable_if:(__builtin_strlen(fp)) == ((14ul) - (1))]
Line
Count
Source
853
33.9M
        : StringRef(Str, N - 1) {
854
33.9M
    }
llvm::StringLiteral::StringLiteral<16ul>(char const (&) [16ul]) [enable_if:(__builtin_strlen(fp)) == ((16ul) - (1))]
Line
Count
Source
853
31.2M
        : StringRef(Str, N - 1) {
854
31.2M
    }
llvm::StringLiteral::StringLiteral<17ul>(char const (&) [17ul]) [enable_if:(__builtin_strlen(fp)) == ((17ul) - (1))]
Line
Count
Source
853
21.1M
        : StringRef(Str, N - 1) {
854
21.1M
    }
llvm::StringLiteral::StringLiteral<22ul>(char const (&) [22ul]) [enable_if:(__builtin_strlen(fp)) == ((22ul) - (1))]
Line
Count
Source
853
30.9M
        : StringRef(Str, N - 1) {
854
30.9M
    }
llvm::StringLiteral::StringLiteral<21ul>(char const (&) [21ul]) [enable_if:(__builtin_strlen(fp)) == ((21ul) - (1))]
Line
Count
Source
853
15.2M
        : StringRef(Str, N - 1) {
854
15.2M
    }
llvm::StringLiteral::StringLiteral<27ul>(char const (&) [27ul]) [enable_if:(__builtin_strlen(fp)) == ((27ul) - (1))]
Line
Count
Source
853
29.0M
        : StringRef(Str, N - 1) {
854
29.0M
    }
llvm::StringLiteral::StringLiteral<18ul>(char const (&) [18ul]) [enable_if:(__builtin_strlen(fp)) == ((18ul) - (1))]
Line
Count
Source
853
30.3M
        : StringRef(Str, N - 1) {
854
30.3M
    }
llvm::StringLiteral::StringLiteral<25ul>(char const (&) [25ul]) [enable_if:(__builtin_strlen(fp)) == ((25ul) - (1))]
Line
Count
Source
853
15.0M
        : StringRef(Str, N - 1) {
854
15.0M
    }
llvm::StringLiteral::StringLiteral<2ul>(char const (&) [2ul]) [enable_if:(__builtin_strlen(fp)) == ((2ul) - (1))]
Line
Count
Source
853
1.25M
        : StringRef(Str, N - 1) {
854
1.25M
    }
llvm::StringLiteral::StringLiteral<20ul>(char const (&) [20ul]) [enable_if:(__builtin_strlen(fp)) == ((20ul) - (1))]
Line
Count
Source
853
28.1M
        : StringRef(Str, N - 1) {
854
28.1M
    }
llvm::StringLiteral::StringLiteral<23ul>(char const (&) [23ul]) [enable_if:(__builtin_strlen(fp)) == ((23ul) - (1))]
Line
Count
Source
853
23.3M
        : StringRef(Str, N - 1) {
854
23.3M
    }
llvm::StringLiteral::StringLiteral<19ul>(char const (&) [19ul]) [enable_if:(__builtin_strlen(fp)) == ((19ul) - (1))]
Line
Count
Source
853
31.3M
        : StringRef(Str, N - 1) {
854
31.3M
    }
llvm::StringLiteral::StringLiteral<28ul>(char const (&) [28ul]) [enable_if:(__builtin_strlen(fp)) == ((28ul) - (1))]
Line
Count
Source
853
8.87M
        : StringRef(Str, N - 1) {
854
8.87M
    }
llvm::StringLiteral::StringLiteral<26ul>(char const (&) [26ul]) [enable_if:(__builtin_strlen(fp)) == ((26ul) - (1))]
Line
Count
Source
853
17.8M
        : StringRef(Str, N - 1) {
854
17.8M
    }
llvm::StringLiteral::StringLiteral<24ul>(char const (&) [24ul]) [enable_if:(__builtin_strlen(fp)) == ((24ul) - (1))]
Line
Count
Source
853
22.2M
        : StringRef(Str, N - 1) {
854
22.2M
    }
llvm::StringLiteral::StringLiteral<36ul>(char const (&) [36ul]) [enable_if:(__builtin_strlen(fp)) == ((36ul) - (1))]
Line
Count
Source
853
4.04M
        : StringRef(Str, N - 1) {
854
4.04M
    }
llvm::StringLiteral::StringLiteral<29ul>(char const (&) [29ul]) [enable_if:(__builtin_strlen(fp)) == ((29ul) - (1))]
Line
Count
Source
853
10.9M
        : StringRef(Str, N - 1) {
854
10.9M
    }
llvm::StringLiteral::StringLiteral<30ul>(char const (&) [30ul]) [enable_if:(__builtin_strlen(fp)) == ((30ul) - (1))]
Line
Count
Source
853
12.6M
        : StringRef(Str, N - 1) {
854
12.6M
    }
llvm::StringLiteral::StringLiteral<32ul>(char const (&) [32ul]) [enable_if:(__builtin_strlen(fp)) == ((32ul) - (1))]
Line
Count
Source
853
140k
        : StringRef(Str, N - 1) {
854
140k
    }
llvm::StringLiteral::StringLiteral<47ul>(char const (&) [47ul]) [enable_if:(__builtin_strlen(fp)) == ((47ul) - (1))]
Line
Count
Source
853
48.2k
        : StringRef(Str, N - 1) {
854
48.2k
    }
llvm::StringLiteral::StringLiteral<35ul>(char const (&) [35ul]) [enable_if:(__builtin_strlen(fp)) == ((35ul) - (1))]
Line
Count
Source
853
10.4M
        : StringRef(Str, N - 1) {
854
10.4M
    }
llvm::StringLiteral::StringLiteral<37ul>(char const (&) [37ul]) [enable_if:(__builtin_strlen(fp)) == ((37ul) - (1))]
Line
Count
Source
853
4.43M
        : StringRef(Str, N - 1) {
854
4.43M
    }
llvm::StringLiteral::StringLiteral<42ul>(char const (&) [42ul]) [enable_if:(__builtin_strlen(fp)) == ((42ul) - (1))]
Line
Count
Source
853
483k
        : StringRef(Str, N - 1) {
854
483k
    }
llvm::StringLiteral::StringLiteral<41ul>(char const (&) [41ul]) [enable_if:(__builtin_strlen(fp)) == ((41ul) - (1))]
Line
Count
Source
853
10.0k
        : StringRef(Str, N - 1) {
854
10.0k
    }
llvm::StringLiteral::StringLiteral<31ul>(char const (&) [31ul]) [enable_if:(__builtin_strlen(fp)) == ((31ul) - (1))]
Line
Count
Source
853
3.97M
        : StringRef(Str, N - 1) {
854
3.97M
    }
llvm::StringLiteral::StringLiteral<34ul>(char const (&) [34ul]) [enable_if:(__builtin_strlen(fp)) == ((34ul) - (1))]
Line
Count
Source
853
7.89M
        : StringRef(Str, N - 1) {
854
7.89M
    }
llvm::StringLiteral::StringLiteral<33ul>(char const (&) [33ul]) [enable_if:(__builtin_strlen(fp)) == ((33ul) - (1))]
Line
Count
Source
853
1.97M
        : StringRef(Str, N - 1) {
854
1.97M
    }
llvm::StringLiteral::StringLiteral<38ul>(char const (&) [38ul]) [enable_if:(__builtin_strlen(fp)) == ((38ul) - (1))]
Line
Count
Source
853
1.97M
        : StringRef(Str, N - 1) {
854
1.97M
    }
llvm::StringLiteral::StringLiteral<54ul>(char const (&) [54ul]) [enable_if:(__builtin_strlen(fp)) == ((54ul) - (1))]
Line
Count
Source
853
8
        : StringRef(Str, N - 1) {
854
8
    }
llvm::StringLiteral::StringLiteral<58ul>(char const (&) [58ul]) [enable_if:(__builtin_strlen(fp)) == ((58ul) - (1))]
Line
Count
Source
853
8
        : StringRef(Str, N - 1) {
854
8
    }
llvm::StringLiteral::StringLiteral<63ul>(char const (&) [63ul]) [enable_if:(__builtin_strlen(fp)) == ((63ul) - (1))]
Line
Count
Source
853
8
        : StringRef(Str, N - 1) {
854
8
    }
llvm::StringLiteral::StringLiteral<45ul>(char const (&) [45ul]) [enable_if:(__builtin_strlen(fp)) == ((45ul) - (1))]
Line
Count
Source
853
8
        : StringRef(Str, N - 1) {
854
8
    }
llvm::StringLiteral::StringLiteral<57ul>(char const (&) [57ul]) [enable_if:(__builtin_strlen(fp)) == ((57ul) - (1))]
Line
Count
Source
853
8
        : StringRef(Str, N - 1) {
854
8
    }
llvm::StringLiteral::StringLiteral<40ul>(char const (&) [40ul]) [enable_if:(__builtin_strlen(fp)) == ((40ul) - (1))]
Line
Count
Source
853
1.97M
        : StringRef(Str, N - 1) {
854
1.97M
    }
llvm::StringLiteral::StringLiteral<49ul>(char const (&) [49ul]) [enable_if:(__builtin_strlen(fp)) == ((49ul) - (1))]
Line
Count
Source
853
8
        : StringRef(Str, N - 1) {
854
8
    }
llvm::StringLiteral::StringLiteral<51ul>(char const (&) [51ul]) [enable_if:(__builtin_strlen(fp)) == ((51ul) - (1))]
Line
Count
Source
853
8
        : StringRef(Str, N - 1) {
854
8
    }
llvm::StringLiteral::StringLiteral<43ul>(char const (&) [43ul]) [enable_if:(__builtin_strlen(fp)) == ((43ul) - (1))]
Line
Count
Source
853
8
        : StringRef(Str, N - 1) {
854
8
    }
llvm::StringLiteral::StringLiteral<48ul>(char const (&) [48ul]) [enable_if:(__builtin_strlen(fp)) == ((48ul) - (1))]
Line
Count
Source
853
1.97M
        : StringRef(Str, N - 1) {
854
1.97M
    }
llvm::StringLiteral::StringLiteral<44ul>(char const (&) [44ul]) [enable_if:(__builtin_strlen(fp)) == ((44ul) - (1))]
Line
Count
Source
853
2.96k
        : StringRef(Str, N - 1) {
854
2.96k
    }
855
856
    // Explicit construction for strings like "foo\0bar".
857
    template <size_t N>
858
1.09M
    static constexpr StringLiteral withInnerNUL(const char (&Str)[N]) {
859
1.09M
      return StringLiteral(Str, N - 1);
860
1.09M
    }
861
  };
862
863
  /// @name StringRef Comparison Operators
864
  /// @{
865
866
19.9G
  inline bool operator==(StringRef LHS, StringRef RHS) {
867
19.9G
    return LHS.equals(RHS);
868
19.9G
  }
869
870
48.0M
  inline bool operator!=(StringRef LHS, StringRef RHS) { return !(LHS == RHS); }
871
872
893M
  inline bool operator<(StringRef LHS, StringRef RHS) {
873
893M
    return LHS.compare(RHS) == -1;
874
893M
  }
875
876
57
  inline bool operator<=(StringRef LHS, StringRef RHS) {
877
57
    return LHS.compare(RHS) != 1;
878
57
  }
879
880
389k
  inline bool operator>(StringRef LHS, StringRef RHS) {
881
389k
    return LHS.compare(RHS) == 1;
882
389k
  }
883
884
363
  inline bool operator>=(StringRef LHS, StringRef RHS) {
885
363
    return LHS.compare(RHS) != -1;
886
363
  }
887
888
11.9M
  inline std::string &operator+=(std::string &buffer, StringRef string) {
889
11.9M
    return buffer.append(string.data(), string.size());
890
11.9M
  }
891
892
  /// @}
893
894
  /// Compute a hash_code for a StringRef.
895
  LLVM_NODISCARD
896
  hash_code hash_value(StringRef S);
897
898
} // end namespace llvm
899
900
#endif // LLVM_ADT_STRINGREF_H