From e863796dcaec202081c5bd0dd6b8afd946763ab0 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Tue, 8 Aug 2017 00:17:20 +0000 Subject: [PATCH] [libFuzzer] simplify code, NFC llvm-svn: 310326 --- llvm/lib/Fuzzer/FuzzerTracePC.cpp | 11 ++++------- llvm/lib/Fuzzer/FuzzerTracePC.h | 7 +++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.cpp b/llvm/lib/Fuzzer/FuzzerTracePC.cpp index a646c25..a83289f 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.cpp +++ b/llvm/lib/Fuzzer/FuzzerTracePC.cpp @@ -46,8 +46,8 @@ uintptr_t *TracePC::PCs() const { } size_t TracePC::GetTotalPCCoverage() { - if (ObservedPCs) - return ObservedPCs->size(); + if (ObservedPCs.size()) + return ObservedPCs.size(); size_t Res = 0; for (size_t i = 1, N = GetNumPCs(); i < N; i++) if (PCs()[i]) @@ -139,14 +139,11 @@ void TracePC::HandleCallerCallee(uintptr_t Caller, uintptr_t Callee) { void TracePC::UpdateObservedPCs() { if (NumPCsInPCTables) { auto Observe = [&](uintptr_t PC) { - bool Inserted = ObservedPCs->insert(PC).second; + bool Inserted = ObservedPCs.insert(PC).second; if (Inserted && DoPrintNewPCs) PrintPC("\tNEW_PC: %p %F %L\n", "\tNEW_PC: %p\n", PC + 1); }; - if (!ObservedPCs) - ObservedPCs = new std::set; - if (NumInline8bitCounters == NumPCsInPCTables) { for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) { uint8_t *Beg = ModuleCounters[i].Start; @@ -235,7 +232,7 @@ void TracePC::PrintCoverage() { for (auto Ptr = M.Start; Ptr < M.Stop; Ptr++) { auto PC = *Ptr; auto VisualizePC = GetNextInstructionPc(PC); - bool IsObserved = ObservedPCs->count(PC); + bool IsObserved = ObservedPCs.count(PC); std::string FileStr = DescribePC("%s", VisualizePC); if (!IsInterestingCoverageFile(FileStr)) continue; std::string FunctionStr = DescribePC("%F", VisualizePC); diff --git a/llvm/lib/Fuzzer/FuzzerTracePC.h b/llvm/lib/Fuzzer/FuzzerTracePC.h index d5d2985..ea6794c 100644 --- a/llvm/lib/Fuzzer/FuzzerTracePC.h +++ b/llvm/lib/Fuzzer/FuzzerTracePC.h @@ -135,9 +135,8 @@ class TracePC { template void ForEachObservedPC(CallBack CB) { - if (ObservedPCs) - for (auto PC : *ObservedPCs) - CB(PC); + for (auto PC : ObservedPCs) + CB(PC); } private: @@ -164,7 +163,7 @@ private: uint8_t *Counters() const; uintptr_t *PCs() const; - std::set *ObservedPCs; + std::set ObservedPCs; ValueBitMap ValueProfileMap; uintptr_t InitialStack, LowestStack; // Assume stack grows down. -- 2.7.4