[llvm] r310326 - [libFuzzer] simplify code, NFC
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 7 17:17:20 PDT 2017
Author: kcc
Date: Mon Aug 7 17:17:20 2017
New Revision: 310326
URL: http://llvm.org/viewvc/llvm-project?rev=310326&view=rev
Log:
[libFuzzer] simplify code, NFC
Modified:
llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
llvm/trunk/lib/Fuzzer/FuzzerTracePC.h
Modified: llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp?rev=310326&r1=310325&r2=310326&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp Mon Aug 7 17:17:20 2017
@@ -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
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<uintptr_t>;
-
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);
Modified: llvm/trunk/lib/Fuzzer/FuzzerTracePC.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.h?rev=310326&r1=310325&r2=310326&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerTracePC.h (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerTracePC.h Mon Aug 7 17:17:20 2017
@@ -135,9 +135,8 @@ class TracePC {
template<class CallBack>
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<uintptr_t> *ObservedPCs;
+ std::set<uintptr_t> ObservedPCs;
ValueBitMap ValueProfileMap;
uintptr_t InitialStack, LowestStack; // Assume stack grows down.
More information about the llvm-commits
mailing list