Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SVFBugRecoder and modify source loc format #1067

Merged
merged 13 commits into from
Apr 26, 2023
10 changes: 5 additions & 5 deletions svf-llvm/lib/LLVMUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ const std::string LLVMUtil::getSourceLoc(const Value* val )
if (llvm::DbgDeclareInst *DDI = SVFUtil::dyn_cast<llvm::DbgDeclareInst>(DII))
{
llvm::DIVariable *DIVar = SVFUtil::cast<llvm::DIVariable>(DDI->getVariable());
rawstr << "ln: " << DIVar->getLine() << " fl: " << DIVar->getFilename().str();
rawstr << "\"ln\": " << DIVar->getLine() << ", \"fl\": \"" << DIVar->getFilename().str() << "\"";
break;
}
}
Expand All @@ -508,7 +508,7 @@ const std::string LLVMUtil::getSourceLoc(const Value* val )
File = inlineLoc->getFilename().str();
}
}
rawstr << "ln: " << Line << " cl: " << Column << " fl: " << File;
rawstr << "\"ln\": " << Line << ", \"cl\": " << Column << ", \"fl\": \"" << File << "\"";
}
}
else if (const Argument* argument = SVFUtil::dyn_cast<Argument>(val))
Expand Down Expand Up @@ -539,7 +539,7 @@ const std::string LLVMUtil::getSourceLoc(const Value* val )

if(DGV->getName() == gvar->getName())
{
rawstr << "ln: " << DGV->getLine() << " fl: " << DGV->getFilename().str();
rawstr << "\"ln\": " << DGV->getLine() << ", \"fl\": \"" << DGV->getFilename().str() << "\"";
}

}
Expand All @@ -552,7 +552,7 @@ const std::string LLVMUtil::getSourceLoc(const Value* val )
}
else if (const BasicBlock* bb = SVFUtil::dyn_cast<BasicBlock>(val))
{
rawstr << "basic block: " << bb->getName().str() << " " << getSourceLoc(bb->getFirstNonPHI());
rawstr << "\"basic block\": " << bb->getName().str() << ", \"location\": " << getSourceLoc(bb->getFirstNonPHI());
}
else if(LLVMUtil::isConstDataOrAggData(val))
{
Expand Down Expand Up @@ -584,7 +584,7 @@ const std::string LLVMUtil::getSourceLocOfFunction(const Function* F)
if (llvm::DISubprogram *SP = F->getSubprogram())
{
if (SP->describes(F))
rawstr << "in line: " << SP->getLine() << " file: " << SP->getFilename().str();
rawstr << "\"ln\": " << SP->getLine() << ", \"file\": \"" << SP->getFilename().str() << "\"";
}
return rawstr.str();
}
Expand Down
2 changes: 0 additions & 2 deletions svf/include/SABER/FileChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ class FileChecker : public LeakChecker
}
/// Report file/close bugs
void reportBug(ProgSlice* slice);
void reportNeverClose(const SVFGNode* src);
void reportPartialClose(const SVFGNode* src);
};

} // End namespace SVF
Expand Down
2 changes: 0 additions & 2 deletions svf/include/SABER/LeakChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ class LeakChecker : public SrcSnkDDA
/// Report leaks
//@{
virtual void reportBug(ProgSlice* slice) override;
void reportNeverFree(const SVFGNode* src);
void reportPartialLeak(const SVFGNode* src);
//@}

/// Validate test cases for regression test purpose
Expand Down
3 changes: 3 additions & 0 deletions svf/include/SABER/ProgSlice.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "Util/WorkList.h"
#include "Graphs/SVFG.h"
#include "Util/DPItem.h"
#include "Util/SVFBugReport.h"

namespace SVF
{
Expand Down Expand Up @@ -201,6 +202,8 @@ class ProgSlice
}
/// Evaluate final condition
std::string evalFinalCond() const;
/// Add final condition to eventStack
void evalFinalCond2Event(GenericBug::EventStack &eventStack) const;
//@}

protected:
Expand Down
5 changes: 3 additions & 2 deletions svf/include/SABER/SrcSnkDDA.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
#ifndef SRCSNKANALYSIS_H_
#define SRCSNKANALYSIS_H_


#include "Util/GraphReachSolver.h"
#include "Graphs/SVFGOPT.h"
#include "SABER/ProgSlice.h"
#include "SABER/SaberSVFGBuilder.h"
#include "Util/GraphReachSolver.h"
#include "Util/SVFBugReport.h"

namespace SVF
{
Expand Down Expand Up @@ -77,6 +77,7 @@ class SrcSnkDDA : public CFLSrcSnkSolver
SaberSVFGBuilder memSSA;
SVFG* svfg;
PTACallGraph* ptaCallGraph;
SVFBugReport report; /// Bug Reporter

public:

Expand Down
Loading