summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/SubtargetFeature.cpp
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
commit5357df6290e7049c2130d4e36dcd37d6f78f0018 (patch)
tree8c2824b76b6de401c9f2cc6e2aa3879a1f0dfb40 /llvm/lib/MC/SubtargetFeature.cpp
parentd6cbede9c5cdcff4aeb6016a19222848aa8bb549 (diff)
downloadbcm5719-llvm-5357df6290e7049c2130d4e36dcd37d6f78f0018.tar.gz
bcm5719-llvm-5357df6290e7049c2130d4e36dcd37d6f78f0018.zip
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. llvm-svn: 192558
Diffstat (limited to 'llvm/lib/MC/SubtargetFeature.cpp')
-rw-r--r--llvm/lib/MC/SubtargetFeature.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/llvm/lib/MC/SubtargetFeature.cpp b/llvm/lib/MC/SubtargetFeature.cpp
index 68d68fff546..2fb91f2125b 100644
--- a/llvm/lib/MC/SubtargetFeature.cpp
+++ b/llvm/lib/MC/SubtargetFeature.cpp
@@ -121,13 +121,10 @@ void SubtargetFeatures::AddFeature(const StringRef String,
/// Find KV in array using binary search.
static const SubtargetFeatureKV *Find(StringRef S, const SubtargetFeatureKV *A,
size_t L) {
- // Make the lower bound element we're looking for
- SubtargetFeatureKV KV;
- KV.Key = S.data();
// Determine the end of the array
const SubtargetFeatureKV *Hi = A + L;
// Binary search the array
- const SubtargetFeatureKV *F = std::lower_bound(A, Hi, KV);
+ const SubtargetFeatureKV *F = std::lower_bound(A, Hi, S);
// If not found then return NULL
if (F == Hi || StringRef(F->Key) != S) return NULL;
// Return the found array item
OpenPOWER on IntegriCloud