summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorWill Dietz <wdietz2@illinois.edu>2013-10-13 22:09:26 +0000
committerWill Dietz <wdietz2@illinois.edu>2013-10-13 22:09:26 +0000
commit4df7c5baa1dfe2d9de7eef2600c9ac325e9fdcd6 (patch)
treefe26a346afd3acc887977295e4ea492b40e8a97d /include
parentcf1f4c7dd19458f47a9ba720d90eec507d66c94a (diff)
downloadllvm-4df7c5baa1dfe2d9de7eef2600c9ac325e9fdcd6.tar.gz
llvm-4df7c5baa1dfe2d9de7eef2600c9ac325e9fdcd6.tar.bz2
llvm-4df7c5baa1dfe2d9de7eef2600c9ac325e9fdcd6.tar.xz
MC: Don't assume incoming StringRef's are null terminated.
This can happen when processing command line arguments, which are often stored as std::string's and later turned into StringRef's via std::string::data(). Unfortunately this is not guaranteed to return a null-terminated string until C++11, causing breakage on platforms that don't do this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192558 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/MC/SubtargetFeature.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/include/llvm/MC/SubtargetFeature.h b/include/llvm/MC/SubtargetFeature.h
index acebf99edc..d0735ccd9f 100644
--- a/include/llvm/MC/SubtargetFeature.h
+++ b/include/llvm/MC/SubtargetFeature.h
@@ -37,9 +37,9 @@ struct SubtargetFeatureKV {
uint64_t Value; // K-V integer value
uint64_t Implies; // K-V bit mask
- // Compare routine for std binary search
- bool operator<(const SubtargetFeatureKV &S) const {
- return strcmp(Key, S.Key) < 0;
+ // Compare routine for std::lower_bound
+ bool operator<(StringRef S) const {
+ return StringRef(Key) < S;
}
};
@@ -52,9 +52,9 @@ struct SubtargetInfoKV {
const char *Key; // K-V key string
const void *Value; // K-V pointer value
- // Compare routine for std binary search
- bool operator<(const SubtargetInfoKV &S) const {
- return strcmp(Key, S.Key) < 0;
+ // Compare routine for std::lower_bound
+ bool operator<(StringRef S) const {
+ return StringRef(Key) < S;
}
};