Skip to content

Commit

Permalink
[libFuzzer] simplify code, NFC
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310326 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
kcc committed Aug 8, 2017
1 parent 7550cbd commit 1aea640
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
11 changes: 4 additions & 7 deletions lib/Fuzzer/FuzzerTracePC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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<uintptr_t>;

if (NumInline8bitCounters == NumPCsInPCTables) {
for (size_t i = 0; i < NumModulesWithInline8bitCounters; i++) {
uint8_t *Beg = ModuleCounters[i].Start;
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions lib/Fuzzer/FuzzerTracePC.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -164,7 +163,7 @@ class TracePC {
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.
Expand Down

0 comments on commit 1aea640

Please sign in to comment.