Coverage Report

Created: 2018-09-17 19:50

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