diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2011-04-15 17:56:50 +0000 |
---|---|---|
committer | Lenny Maiorani <lenny@colorado.edu> | 2011-04-15 17:56:50 +0000 |
commit | 437ef0cfb74102208d6e96ff7e7f1204835e66f3 (patch) | |
tree | 54e728995aa94004e9168115304357cd2b0ed00c /include/llvm/ADT/StringRef.h | |
parent | 44b7ae2355a32035ea286555736d173755a1c5e2 (diff) |
Implements StringRef::compare with bounds. It is behaves similarly to strncmp(). Unit tests also included.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129582 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringRef.h')
-rw-r--r-- | include/llvm/ADT/StringRef.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 1766d2b9f2..adff42fe2d 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -125,6 +125,12 @@ namespace llvm { return Length < RHS.Length ? -1 : 1; } + /// compare - Compare two strings; the result is -1, 0, or 1 if this string + /// is lexicographically less than, equal to, or greater than the \arg RHS. + /// This is different than compare with no size specified as it only + /// compares at most the first n bytes. + int compare(StringRef RHS, size_t n) const; + /// compare_lower - Compare two strings, ignoring case. int compare_lower(StringRef RHS) const; |