From 4df7c5baa1dfe2d9de7eef2600c9ac325e9fdcd6 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sun, 13 Oct 2013 22:09:26 +0000 Subject: 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 --- lib/MC/MCSubtargetInfo.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/MC/MCSubtargetInfo.cpp') diff --git a/lib/MC/MCSubtargetInfo.cpp b/lib/MC/MCSubtargetInfo.cpp index ad19921..8d8e290 100644 --- a/lib/MC/MCSubtargetInfo.cpp +++ b/lib/MC/MCSubtargetInfo.cpp @@ -96,10 +96,8 @@ MCSubtargetInfo::getSchedModelForCPU(StringRef CPU) const { #endif // Find entry - SubtargetInfoKV KV; - KV.Key = CPU.data(); const SubtargetInfoKV *Found = - std::lower_bound(ProcSchedModels, ProcSchedModels+NumProcs, KV); + std::lower_bound(ProcSchedModels, ProcSchedModels+NumProcs, CPU); if (Found == ProcSchedModels+NumProcs || StringRef(Found->Key) != CPU) { errs() << "'" << CPU << "' is not a recognized processor for this target" -- cgit v1.1