Coverage Report

Created: 2019-02-20 00:17

/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
0
  class StringRef {
Unexecuted instantiation: llvm::StringRef::operator=(llvm::StringRef const&)
Unexecuted instantiation: llvm::StringRef::operator=(llvm::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
2.97G
    static int compareMemory(const char *Lhs, const char *Rhs, size_t Length) {
66
2.97G
      if (Length == 0) 
{ return 0; }13.2M
67
2.96G
      return ::memcmp(Lhs,Rhs,Length);
68
2.96G
    }
69
70
  public:
71
    /// @name Constructors
72
    /// @{
73
74
    /// Construct an empty string ref.
75
759M
    /*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
5.73G
        : 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.42G
        : Data(data), Length(length) {}
88
89
    /// Construct a string ref from an std::string.
90
    /*implicit*/ StringRef(const std::string &Str)
91
3.45G
      : 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.52G
    iterator begin() const { return Data; }
102
103
1.50G
    iterator end() const { return Data + Length; }
104
105
1.20G
    const unsigned char *bytes_begin() const {
106
1.20G
      return reinterpret_cast<const unsigned char *>(begin());
107
1.20G
    }
108
1.20G
    const unsigned char *bytes_end() const {
109
1.20G
      return reinterpret_cast<const unsigned char *>(end());
110
1.20G
    }
111
1.20G
    iterator_range<const unsigned char *> bytes() const {
112
1.20G
      return make_range(bytes_begin(), bytes_end());
113
1.20G
    }
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.80G
    const char *data() const { return Data; }
123
124
    /// empty - Check if the string is empty.
125
    LLVM_NODISCARD
126
761M
    bool empty() const { return Length == 0; }
127
128
    /// size - Get the string size.
129
    LLVM_NODISCARD
130
2.37G
    size_t size() const { return Length; }
131
132
    /// front - Get the first character in the string.
133
    LLVM_NODISCARD
134
10.0M
    char front() const {
135
10.0M
      assert(!empty());
136
10.0M
      return Data[0];
137
10.0M
    }
138
139
    /// back - Get the last character in the string.
140
    LLVM_NODISCARD
141
6.60M
    char back() const {
142
6.60M
      assert(!empty());
143
6.60M
      return Data[Length-1];
144
6.60M
    }
145
146
    // copy - Allocate copy in Allocator and return StringRef to it.
147
    template <typename Allocator>
148
28.1k
    LLVM_NODISCARD StringRef copy(Allocator &A) const {
149
28.1k
      // Don't request a length 0 copy from the allocator.
150
28.1k
      if (empty())
151
123
        return StringRef();
152
28.0k
      char *S = A.template Allocate<char>(Length);
153
28.0k
      std::copy(begin(), end(), S);
154
28.0k
      return StringRef(S, Length);
155
28.0k
    }
llvm::StringRef llvm::StringRef::copy<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul> >(llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>&) const
Line
Count
Source
148
27.6k
    LLVM_NODISCARD StringRef copy(Allocator &A) const {
149
27.6k
      // Don't request a length 0 copy from the allocator.
150
27.6k
      if (empty())
151
112
        return StringRef();
152
27.4k
      char *S = A.template Allocate<char>(Length);
153
27.4k
      std::copy(begin(), end(), S);
154
27.4k
      return StringRef(S, Length);
155
27.4k
    }
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
588
    LLVM_NODISCARD StringRef copy(Allocator &A) const {
149
588
      // Don't request a length 0 copy from the allocator.
150
588
      if (empty())
151
11
        return StringRef();
152
577
      char *S = A.template Allocate<char>(Length);
153
577
      std::copy(begin(), end(), S);
154
577
      return StringRef(S, Length);
155
577
    }
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
17.4G
    bool equals(StringRef RHS) const {
161
17.4G
      return (Length == RHS.Length &&
162
17.4G
              
compareMemory(Data, RHS.Data, RHS.Length) == 01.70G
);
163
17.4G
    }
164
165
    /// equals_lower - Check for string equality, ignoring case.
166
    LLVM_NODISCARD
167
114M
    bool equals_lower(StringRef RHS) const {
168
114M
      return Length == RHS.Length && 
compare_lower(RHS) == 022.8M
;
169
114M
    }
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
881M
    int compare(StringRef RHS) const {
175
881M
      // Check the prefix for a mismatch.
176
881M
      if (int Res = compareMemory(Data, RHS.Data, std::min(Length, RHS.Length)))
177
833M
        return Res < 0 ? 
-1441M
:
1392M
;
178
48.6M
179
48.6M
      // Otherwise the prefixes match, so we only need to check the lengths.
180
48.6M
      if (Length == RHS.Length)
181
28.5M
        return 0;
182
20.0M
      return Length < RHS.Length ? 
-16.05M
:
114.0M
;
183
20.0M
    }
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
211M
    std::string str() const {
219
211M
      if (!Data) 
return std::string()1.42M
;
220
210M
      return std::string(Data, Length);
221
210M
    }
222
223
    /// @}
224
    /// @name Operator Overloads
225
    /// @{
226
227
    LLVM_NODISCARD
228
2.34G
    char operator[](size_t Index) const {
229
2.34G
      assert(Index < Length && "Invalid index!");
230
2.34G
      return Data[Index];
231
2.34G
    }
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
174M
    operator std::string() const {
247
174M
      return str();
248
174M
    }
249
250
    /// @}
251
    /// @name String Predicates
252
    /// @{
253
254
    /// Check if this string starts with the given \p Prefix.
255
    LLVM_NODISCARD
256
373M
    bool startswith(StringRef Prefix) const {
257
373M
      return Length >= Prefix.Length &&
258
373M
             
compareMemory(Data, Prefix.Data, Prefix.Length) == 0309M
;
259
373M
    }
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
98.3M
    bool endswith(StringRef Suffix) const {
268
98.3M
      return Length >= Suffix.Length &&
269
98.3M
        
compareMemory(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 083.2M
;
270
98.3M
    }
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.5M
    size_t find(char C, size_t From = 0) const {
286
79.5M
      size_t FindBegin = std::min(From, Length);
287
79.5M
      if (FindBegin < Length) { // Avoid calling memchr with nullptr.
288
77.9M
        // Just forward to memchr, which is faster than a hand-rolled loop.
289
77.9M
        if (const void *P = ::memchr(Data + FindBegin, C, Length - FindBegin))
290
9.44M
          return static_cast<const char *>(P) - Data;
291
70.1M
      }
292
70.1M
      return npos;
293
70.1M
    }
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
143k
    size_t find_if(function_ref<bool(char)> F, size_t From = 0) const {
308
143k
      StringRef S = drop_front(From);
309
312k
      while (!S.empty()) {
310
311k
        if (F(S.front()))
311
143k
          return size() - S.size();
312
168k
        S = S.drop_front();
313
168k
      }
314
143k
      
return npos803
;
315
143k
    }
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
143k
    size_t find_if_not(function_ref<bool(char)> F, size_t From = 0) const {
323
311k
      return find_if([F](char c) { return !F(c); }, From);
324
143k
    }
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
586k
    size_t rfind(char C, size_t From = npos) const {
346
586k
      From = std::min(From, Length);
347
586k
      size_t i = From;
348
3.50M
      while (i != 0) {
349
3.26M
        --i;
350
3.26M
        if (Data[i] == C)
351
349k
          return i;
352
3.26M
      }
353
586k
      
return npos237k
;
354
586k
    }
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.56M
    size_t find_first_of(char C, size_t From = 0) const {
381
8.56M
      return find(C, From);
382
8.56M
    }
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
342k
    size_t find_last_of(char C, size_t From = npos) const {
407
342k
      return rfind(C, From);
408
342k
    }
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
97.6k
    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
4.97k
    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
2.63k
    bool contains_lower(StringRef Other) const {
443
2.63k
      return find_lower(Other) != npos;
444
2.63k
    }
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
439k
    size_t count(char C) const {
458
439k
      size_t Count = 0;
459
10.7M
      for (size_t i = 0, e = Length; i != e; 
++i10.2M
)
460
10.2M
        if (Data[i] == C)
461
121k
          ++Count;
462
439k
      return Count;
463
439k
    }
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
131k
    getAsInteger(unsigned Radix, T &Result) const {
479
131k
      long long LLVal;
480
131k
      if (getAsSignedInteger(*this, Radix, LLVal) ||
481
131k
            
static_cast<T>(LLVal) != LLVal130k
)
482
176
        return true;
483
130k
      Result = LLVal;
484
130k
      return false;
485
130k
    }
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.46k
    getAsInteger(unsigned Radix, T &Result) const {
479
4.46k
      long long LLVal;
480
4.46k
      if (getAsSignedInteger(*this, Radix, LLVal) ||
481
4.46k
            
static_cast<T>(LLVal) != LLVal4.42k
)
482
48
        return true;
483
4.42k
      Result = LLVal;
484
4.42k
      return false;
485
4.42k
    }
std::__1::enable_if<std::numeric_limits<int>::is_signed, bool>::type llvm::StringRef::getAsInteger<int>(unsigned int, int&) const
Line
Count
Source
478
126k
    getAsInteger(unsigned Radix, T &Result) const {
479
126k
      long long LLVal;
480
126k
      if (getAsSignedInteger(*this, Radix, LLVal) ||
481
126k
            
static_cast<T>(LLVal) != LLVal126k
)
482
128
        return true;
483
126k
      Result = LLVal;
484
126k
      return false;
485
126k
    }
486
487
    template <typename T>
488
    typename std::enable_if<!std::numeric_limits<T>::is_signed, bool>::type
489
6.89M
    getAsInteger(unsigned Radix, T &Result) const {
490
6.89M
      unsigned long long ULLVal;
491
6.89M
      // The additional cast to unsigned long long is required to avoid the
492
6.89M
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
6.89M
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
6.89M
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
6.89M
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal6.81M
)
496
74.4k
        return true;
497
6.81M
      Result = ULLVal;
498
6.81M
      return false;
499
6.81M
    }
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.20k
    getAsInteger(unsigned Radix, T &Result) const {
490
1.20k
      unsigned long long ULLVal;
491
1.20k
      // The additional cast to unsigned long long is required to avoid the
492
1.20k
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
1.20k
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
1.20k
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
1.20k
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal1.20k
)
496
2
        return true;
497
1.20k
      Result = ULLVal;
498
1.20k
      return false;
499
1.20k
    }
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.05M
    getAsInteger(unsigned Radix, T &Result) const {
490
1.05M
      unsigned long long ULLVal;
491
1.05M
      // The additional cast to unsigned long long is required to avoid the
492
1.05M
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
1.05M
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
1.05M
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
1.05M
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal1.05M
)
496
1.29k
        return true;
497
1.05M
      Result = ULLVal;
498
1.05M
      return false;
499
1.05M
    }
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
5.82M
    getAsInteger(unsigned Radix, T &Result) const {
490
5.82M
      unsigned long long ULLVal;
491
5.82M
      // The additional cast to unsigned long long is required to avoid the
492
5.82M
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
5.82M
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
5.82M
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
5.82M
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal5.75M
)
496
73.1k
        return true;
497
5.75M
      Result = ULLVal;
498
5.75M
      return false;
499
5.75M
    }
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
958
    getAsInteger(unsigned Radix, T &Result) const {
490
958
      unsigned long long ULLVal;
491
958
      // The additional cast to unsigned long long is required to avoid the
492
958
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
958
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
958
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
958
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal942
)
496
22
        return true;
497
936
      Result = ULLVal;
498
936
      return false;
499
936
    }
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
29
    getAsInteger(unsigned Radix, T &Result) const {
490
29
      unsigned long long ULLVal;
491
29
      // The additional cast to unsigned long long is required to avoid the
492
29
      // Visual C++ warning C4805: '!=' : unsafe mix of type 'bool' and type
493
29
      // 'unsigned __int64' when instantiating getAsInteger with T = bool.
494
29
      if (getAsUnsignedInteger(*this, Radix, ULLVal) ||
495
29
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal24
)
496
9
        return true;
497
20
      Result = ULLVal;
498
20
      return false;
499
20
    }
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
232k
    consumeInteger(unsigned Radix, T &Result) {
524
232k
      unsigned long long ULLVal;
525
232k
      if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
526
232k
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal213k
)
527
18.5k
        return true;
528
213k
      Result = ULLVal;
529
213k
      return false;
530
213k
    }
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
57.1k
    consumeInteger(unsigned Radix, T &Result) {
524
57.1k
      unsigned long long ULLVal;
525
57.1k
      if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
526
57.1k
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal57.1k
)
527
4
        return true;
528
57.1k
      Result = ULLVal;
529
57.1k
      return false;
530
57.1k
    }
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
175k
    consumeInteger(unsigned Radix, T &Result) {
524
175k
      unsigned long long ULLVal;
525
175k
      if (consumeUnsignedInteger(*this, Radix, ULLVal) ||
526
175k
          
static_cast<unsigned long long>(static_cast<T>(ULLVal)) != ULLVal156k
)
527
18.5k
        return true;
528
156k
      Result = ULLVal;
529
156k
      return false;
530
156k
    }
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
267M
    StringRef substr(size_t Start, size_t N = npos) const {
579
267M
      Start = std::min(Start, Length);
580
267M
      return StringRef(Data + Start, std::min(N, Length - Start));
581
267M
    }
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
17.5k
    StringRef take_front(size_t N = 1) const {
588
17.5k
      if (N >= size())
589
11.3k
        return *this;
590
6.20k
      return drop_back(size() - N);
591
6.20k
    }
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
5.02k
    StringRef take_back(size_t N = 1) const {
598
5.02k
      if (N >= size())
599
1
        return *this;
600
5.02k
      return drop_front(size() - N);
601
5.02k
    }
602
603
    /// Return the longest prefix of 'this' such that every character
604
    /// in the prefix satisfies the given predicate.
605
    LLVM_NODISCARD
606
143k
    StringRef take_while(function_ref<bool(char)> F) const {
607
143k
      return substr(0, find_if_not(F));
608
143k
    }
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
42.3M
    StringRef drop_front(size_t N = 1) const {
621
42.3M
      assert(size() >= N && "Dropping more elements than exist");
622
42.3M
      return substr(N);
623
42.3M
    }
624
625
    /// Return a StringRef equal to 'this' but with the last \p N elements
626
    /// dropped.
627
    LLVM_NODISCARD
628
86.4M
    StringRef drop_back(size_t N = 1) const {
629
86.4M
      assert(size() >= N && "Dropping more elements than exist");
630
86.4M
      return substr(0, size()-N);
631
86.4M
    }
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
33
    StringRef drop_until(function_ref<bool(char)> F) const {
644
33
      return substr(find_if(F));
645
33
    }
646
647
    /// Returns true if this StringRef has the given prefix and removes that
648
    /// prefix.
649
24.0M
    bool consume_front(StringRef Prefix) {
650
24.0M
      if (!startswith(Prefix))
651
327k
        return false;
652
23.7M
653
23.7M
      *this = drop_front(Prefix.size());
654
23.7M
      return true;
655
23.7M
    }
656
657
    /// Returns true if this StringRef has the given suffix and removes that
658
    /// suffix.
659
85.4k
    bool consume_back(StringRef Suffix) {
660
85.4k
      if (!endswith(Suffix))
661
84.7k
        return false;
662
683
663
683
      *this = drop_back(Suffix.size());
664
683
      return true;
665
683
    }
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
64.9M
    StringRef slice(size_t Start, size_t End) const {
680
64.9M
      Start = std::min(Start, Length);
681
64.9M
      End = std::min(std::max(Start, End), Length);
682
64.9M
      return StringRef(Data + Start, End - Start);
683
64.9M
    }
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
5.85M
    std::pair<StringRef, StringRef> split(char Separator) const {
697
5.85M
      return split(StringRef(&Separator, 1));
698
5.85M
    }
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
5.91M
    std::pair<StringRef, StringRef> split(StringRef Separator) const {
712
5.91M
      size_t Idx = find(Separator);
713
5.91M
      if (Idx == npos)
714
2.22M
        return std::make_pair(*this, StringRef());
715
3.68M
      return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
716
3.68M
    }
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
407k
    std::pair<StringRef, StringRef> rsplit(StringRef Separator) const {
730
407k
      size_t Idx = rfind(Separator);
731
407k
      if (Idx == npos)
732
130k
        return std::make_pair(*this, StringRef());
733
276k
      return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
734
276k
    }
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
407k
    std::pair<StringRef, StringRef> rsplit(char Separator) const {
783
407k
      return rsplit(StringRef(&Separator, 1));
784
407k
    }
785
786
    /// Return string with consecutive \p Char characters starting from the
787
    /// the left removed.
788
    LLVM_NODISCARD
789
348
    StringRef ltrim(char Char) const {
790
348
      return drop_front(std::min(Length, find_first_not_of(Char)));
791
348
    }
792
793
    /// Return string with consecutive characters in \p Chars starting from
794
    /// the left removed.
795
    LLVM_NODISCARD
796
4.72M
    StringRef ltrim(StringRef Chars = " \t\n\v\f\r") const {
797
4.72M
      return drop_front(std::min(Length, find_first_not_of(Chars)));
798
4.72M
    }
799
800
    /// Return string with consecutive \p Char characters starting from the
801
    /// right removed.
802
    LLVM_NODISCARD
803
340k
    StringRef rtrim(char Char) const {
804
340k
      return drop_back(Length - std::min(Length, find_last_not_of(Char) + 1));
805
340k
    }
806
807
    /// Return string with consecutive characters in \p Chars starting from
808
    /// the right removed.
809
    LLVM_NODISCARD
810
1.82M
    StringRef rtrim(StringRef Chars = " \t\n\v\f\r") const {
811
1.82M
      return drop_back(Length - std::min(Length, find_last_not_of(Chars) + 1));
812
1.82M
    }
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.73M
    StringRef trim(StringRef Chars = " \t\n\v\f\r") const {
825
1.73M
      return ltrim(Chars).rtrim(Chars);
826
1.73M
    }
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.06M
    constexpr StringLiteral(const char *Str, size_t N) : StringRef(Str, N) {
841
1.06M
    }
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.33G
        : StringRef(Str, N - 1) {
854
1.33G
    }
llvm::StringLiteral::StringLiteral<5ul>(char const (&) [5ul]) [enable_if:(__builtin_strlen(fp)) == ((5ul) - (1))]
Line
Count
Source
853
159M
        : StringRef(Str, N - 1) {
854
159M
    }
llvm::StringLiteral::StringLiteral<9ul>(char const (&) [9ul]) [enable_if:(__builtin_strlen(fp)) == ((9ul) - (1))]
Line
Count
Source
853
62.9M
        : StringRef(Str, N - 1) {
854
62.9M
    }
llvm::StringLiteral::StringLiteral<4ul>(char const (&) [4ul]) [enable_if:(__builtin_strlen(fp)) == ((4ul) - (1))]
Line
Count
Source
853
207M
        : StringRef(Str, N - 1) {
854
207M
    }
llvm::StringLiteral::StringLiteral<8ul>(char const (&) [8ul]) [enable_if:(__builtin_strlen(fp)) == ((8ul) - (1))]
Line
Count
Source
853
104M
        : StringRef(Str, N - 1) {
854
104M
    }
llvm::StringLiteral::StringLiteral<7ul>(char const (&) [7ul]) [enable_if:(__builtin_strlen(fp)) == ((7ul) - (1))]
Line
Count
Source
853
116M
        : StringRef(Str, N - 1) {
854
116M
    }
llvm::StringLiteral::StringLiteral<3ul>(char const (&) [3ul]) [enable_if:(__builtin_strlen(fp)) == ((3ul) - (1))]
Line
Count
Source
853
44.7M
        : StringRef(Str, N - 1) {
854
44.7M
    }
llvm::StringLiteral::StringLiteral<1ul>(char const (&) [1ul]) [enable_if:(__builtin_strlen(fp)) == ((1ul) - (1))]
Line
Count
Source
853
125k
        : StringRef(Str, N - 1) {
854
125k
    }
llvm::StringLiteral::StringLiteral<6ul>(char const (&) [6ul]) [enable_if:(__builtin_strlen(fp)) == ((6ul) - (1))]
Line
Count
Source
853
120M
        : StringRef(Str, N - 1) {
854
120M
    }
llvm::StringLiteral::StringLiteral<10ul>(char const (&) [10ul]) [enable_if:(__builtin_strlen(fp)) == ((10ul) - (1))]
Line
Count
Source
853
27.1M
        : StringRef(Str, N - 1) {
854
27.1M
    }
llvm::StringLiteral::StringLiteral<13ul>(char const (&) [13ul]) [enable_if:(__builtin_strlen(fp)) == ((13ul) - (1))]
Line
Count
Source
853
13.7M
        : StringRef(Str, N - 1) {
854
13.7M
    }
llvm::StringLiteral::StringLiteral<12ul>(char const (&) [12ul]) [enable_if:(__builtin_strlen(fp)) == ((12ul) - (1))]
Line
Count
Source
853
28.0M
        : StringRef(Str, N - 1) {
854
28.0M
    }
llvm::StringLiteral::StringLiteral<15ul>(char const (&) [15ul]) [enable_if:(__builtin_strlen(fp)) == ((15ul) - (1))]
Line
Count
Source
853
29.1M
        : StringRef(Str, N - 1) {
854
29.1M
    }
llvm::StringLiteral::StringLiteral<11ul>(char const (&) [11ul]) [enable_if:(__builtin_strlen(fp)) == ((11ul) - (1))]
Line
Count
Source
853
48.9M
        : StringRef(Str, N - 1) {
854
48.9M
    }
llvm::StringLiteral::StringLiteral<14ul>(char const (&) [14ul]) [enable_if:(__builtin_strlen(fp)) == ((14ul) - (1))]
Line
Count
Source
853
29.5M
        : StringRef(Str, N - 1) {
854
29.5M
    }
llvm::StringLiteral::StringLiteral<16ul>(char const (&) [16ul]) [enable_if:(__builtin_strlen(fp)) == ((16ul) - (1))]
Line
Count
Source
853
27.8M
        : StringRef(Str, N - 1) {
854
27.8M
    }
llvm::StringLiteral::StringLiteral<17ul>(char const (&) [17ul]) [enable_if:(__builtin_strlen(fp)) == ((17ul) - (1))]
Line
Count
Source
853
16.7M
        : StringRef(Str, N - 1) {
854
16.7M
    }
llvm::StringLiteral::StringLiteral<22ul>(char const (&) [22ul]) [enable_if:(__builtin_strlen(fp)) == ((22ul) - (1))]
Line
Count
Source
853
29.8M
        : StringRef(Str, N - 1) {
854
29.8M
    }
llvm::StringLiteral::StringLiteral<21ul>(char const (&) [21ul]) [enable_if:(__builtin_strlen(fp)) == ((21ul) - (1))]
Line
Count
Source
853
13.6M
        : StringRef(Str, N - 1) {
854
13.6M
    }
llvm::StringLiteral::StringLiteral<27ul>(char const (&) [27ul]) [enable_if:(__builtin_strlen(fp)) == ((27ul) - (1))]
Line
Count
Source
853
27.8M
        : StringRef(Str, N - 1) {
854
27.8M
    }
llvm::StringLiteral::StringLiteral<18ul>(char const (&) [18ul]) [enable_if:(__builtin_strlen(fp)) == ((18ul) - (1))]
Line
Count
Source
853
28.0M
        : StringRef(Str, N - 1) {
854
28.0M
    }
llvm::StringLiteral::StringLiteral<2ul>(char const (&) [2ul]) [enable_if:(__builtin_strlen(fp)) == ((2ul) - (1))]
Line
Count
Source
853
1.05M
        : StringRef(Str, N - 1) {
854
1.05M
    }
llvm::StringLiteral::StringLiteral<20ul>(char const (&) [20ul]) [enable_if:(__builtin_strlen(fp)) == ((20ul) - (1))]
Line
Count
Source
853
27.2M
        : StringRef(Str, N - 1) {
854
27.2M
    }
llvm::StringLiteral::StringLiteral<23ul>(char const (&) [23ul]) [enable_if:(__builtin_strlen(fp)) == ((23ul) - (1))]
Line
Count
Source
853
20.9M
        : StringRef(Str, N - 1) {
854
20.9M
    }
llvm::StringLiteral::StringLiteral<19ul>(char const (&) [19ul]) [enable_if:(__builtin_strlen(fp)) == ((19ul) - (1))]
Line
Count
Source
853
28.2M
        : StringRef(Str, N - 1) {
854
28.2M
    }
llvm::StringLiteral::StringLiteral<25ul>(char const (&) [25ul]) [enable_if:(__builtin_strlen(fp)) == ((25ul) - (1))]
Line
Count
Source
853
13.1M
        : StringRef(Str, N - 1) {
854
13.1M
    }
llvm::StringLiteral::StringLiteral<28ul>(char const (&) [28ul]) [enable_if:(__builtin_strlen(fp)) == ((28ul) - (1))]
Line
Count
Source
853
8.81M
        : StringRef(Str, N - 1) {
854
8.81M
    }
llvm::StringLiteral::StringLiteral<26ul>(char const (&) [26ul]) [enable_if:(__builtin_strlen(fp)) == ((26ul) - (1))]
Line
Count
Source
853
17.0M
        : StringRef(Str, N - 1) {
854
17.0M
    }
llvm::StringLiteral::StringLiteral<24ul>(char const (&) [24ul]) [enable_if:(__builtin_strlen(fp)) == ((24ul) - (1))]
Line
Count
Source
853
21.4M
        : StringRef(Str, N - 1) {
854
21.4M
    }
llvm::StringLiteral::StringLiteral<36ul>(char const (&) [36ul]) [enable_if:(__builtin_strlen(fp)) == ((36ul) - (1))]
Line
Count
Source
853
4.03M
        : StringRef(Str, N - 1) {
854
4.03M
    }
llvm::StringLiteral::StringLiteral<29ul>(char const (&) [29ul]) [enable_if:(__builtin_strlen(fp)) == ((29ul) - (1))]
Line
Count
Source
853
10.8M
        : StringRef(Str, N - 1) {
854
10.8M
    }
llvm::StringLiteral::StringLiteral<30ul>(char const (&) [30ul]) [enable_if:(__builtin_strlen(fp)) == ((30ul) - (1))]
Line
Count
Source
853
12.2M
        : StringRef(Str, N - 1) {
854
12.2M
    }
llvm::StringLiteral::StringLiteral<32ul>(char const (&) [32ul]) [enable_if:(__builtin_strlen(fp)) == ((32ul) - (1))]
Line
Count
Source
853
127k
        : StringRef(Str, N - 1) {
854
127k
    }
llvm::StringLiteral::StringLiteral<47ul>(char const (&) [47ul]) [enable_if:(__builtin_strlen(fp)) == ((47ul) - (1))]
Line
Count
Source
853
44.0k
        : StringRef(Str, N - 1) {
854
44.0k
    }
llvm::StringLiteral::StringLiteral<35ul>(char const (&) [35ul]) [enable_if:(__builtin_strlen(fp)) == ((35ul) - (1))]
Line
Count
Source
853
10.3M
        : StringRef(Str, N - 1) {
854
10.3M
    }
llvm::StringLiteral::StringLiteral<37ul>(char const (&) [37ul]) [enable_if:(__builtin_strlen(fp)) == ((37ul) - (1))]
Line
Count
Source
853
4.42M
        : StringRef(Str, N - 1) {
854
4.42M
    }
llvm::StringLiteral::StringLiteral<42ul>(char const (&) [42ul]) [enable_if:(__builtin_strlen(fp)) == ((42ul) - (1))]
Line
Count
Source
853
477k
        : StringRef(Str, N - 1) {
854
477k
    }
llvm::StringLiteral::StringLiteral<41ul>(char const (&) [41ul]) [enable_if:(__builtin_strlen(fp)) == ((41ul) - (1))]
Line
Count
Source
853
9.91k
        : StringRef(Str, N - 1) {
854
9.91k
    }
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.88M
        : StringRef(Str, N - 1) {
854
7.88M
    }
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
    }
855
856
    // Explicit construction for strings like "foo\0bar".
857
    template <size_t N>
858
1.06M
    static constexpr StringLiteral withInnerNUL(const char (&Str)[N]) {
859
1.06M
      return StringLiteral(Str, N - 1);
860
1.06M
    }
861
  };
862
863
  /// @name StringRef Comparison Operators
864
  /// @{
865
866
17.3G
  inline bool operator==(StringRef LHS, StringRef RHS) {
867
17.3G
    return LHS.equals(RHS);
868
17.3G
  }
869
870
38.8M
  inline bool operator!=(StringRef LHS, StringRef RHS) { return !(LHS == RHS); }
871
872
876M
  inline bool operator<(StringRef LHS, StringRef RHS) {
873
876M
    return LHS.compare(RHS) == -1;
874
876M
  }
875
876
54
  inline bool operator<=(StringRef LHS, StringRef RHS) {
877
54
    return LHS.compare(RHS) != 1;
878
54
  }
879
880
22.1k
  inline bool operator>(StringRef LHS, StringRef RHS) {
881
22.1k
    return LHS.compare(RHS) == 1;
882
22.1k
  }
883
884
363
  inline bool operator>=(StringRef LHS, StringRef RHS) {
885
363
    return LHS.compare(RHS) != -1;
886
363
  }
887
888
10.1M
  inline std::string &operator+=(std::string &buffer, StringRef string) {
889
10.1M
    return buffer.append(string.data(), string.size());
890
10.1M
  }
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