summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/fuzzer
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2019-05-14 22:16:04 +0000
committerKostya Serebryany <kcc@google.com>2019-05-14 22:16:04 +0000
commit2e2dfe21861562f6c52069b49c29237b19052bf5 (patch)
tree1d3500f981d2ee4cff2507ffc8057f30536c9690 /compiler-rt/lib/fuzzer
parent7f9a008a2db285aca57bfa0c09858c9527a7aa98 (diff)
downloadbcm5719-llvm-2e2dfe21861562f6c52069b49c29237b19052bf5.tar.gz
bcm5719-llvm-2e2dfe21861562f6c52069b49c29237b19052bf5.zip
[libFuzzer] replace string_view with string to fix the bots. This is NFC, just slower.
llvm-svn: 360717
Diffstat (limited to 'compiler-rt/lib/fuzzer')
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp b/compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp
index 9f15cb83a2a..975a98afc50 100644
--- a/compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerDataFlowTrace.cpp
@@ -22,7 +22,6 @@
#include <queue>
#include <sstream>
#include <string>
-#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <vector>
@@ -107,14 +106,14 @@ void DataFlowTrace::ReadCoverage(const std::string &DirPath) {
}
static void DFTStringAppendToVector(Vector<uint8_t> *DFT,
- const std::string_view DFTString) {
+ const std::string &DFTString) {
assert(DFT->size() == DFTString.size());
for (size_t I = 0, Len = DFT->size(); I < Len; I++)
(*DFT)[I] = DFTString[I] == '1';
}
// converts a string of '0' and '1' into a Vector<uint8_t>
-static Vector<uint8_t> DFTStringToVector(const std::string_view DFTString) {
+static Vector<uint8_t> DFTStringToVector(const std::string &DFTString) {
Vector<uint8_t> DFT(DFTString.size());
DFTStringAppendToVector(&DFT, DFTString);
return DFT;
@@ -131,8 +130,10 @@ static bool ParseError(const char *Err, const std::string &Line) {
return false;
};
+// TODO(metzman): replace std::string with std::string_view for
+// better performance. Need to figure our how to use string_view on Windows.
static bool ParseDFTLine(const std::string &Line, size_t *FunctionNum,
- std::string_view *DFTString) {
+ std::string *DFTString) {
if (!Line.empty() && Line[0] != 'F')
return false; // Ignore coverage.
size_t SpacePos = Line.find(' ');
@@ -213,7 +214,7 @@ bool DataFlowTrace::Init(const std::string &DirPath,
std::ifstream IF(SF.File);
while (std::getline(IF, L, '\n')) {
size_t FunctionNum = 0;
- std::string_view DFTString;
+ std::string DFTString;
if (ParseDFTLine(L, &FunctionNum, &DFTString) &&
FunctionNum == FocusFuncIdx) {
NumTracesWithFocusFunction++;
@@ -282,7 +283,7 @@ int CollectDataFlow(const std::string &DFTBinary, const std::string &DirPath,
Cov.insert(L);
} else if (L[0] == 'F') {
size_t FunctionNum = 0;
- std::string_view DFTString;
+ std::string DFTString;
if (ParseDFTLine(L, &FunctionNum, &DFTString)) {
auto &DFT = DFTMap[FunctionNum];
if (DFT.empty()) {
OpenPOWER on IntegriCloud