Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SVF::PartialLeakBug Class Reference

#include <SVFBugReport.h>

Inheritance diagram for SVF::PartialLeakBug:
SVF::GenericBug

Public Member Functions

 PartialLeakBug (const EventStack &bugEventStack)
 
cJSONgetBugDescription () const
 
void printBugToTerminal () const
 
- Public Member Functions inherited from SVF::GenericBug
 GenericBug (BugType bugType, const EventStack &bugEventStack)
 note: should be initialized with a bugEventStack
 
virtual ~GenericBug ()=default
 
BugType getBugType () const
 returns bug type
 
const std::string getLoc () const
 returns bug location as json format string
 
const std::string getFuncName () const
 return bug source function name
 
const EventStackgetEventStack () const
 

Static Public Member Functions

static bool classof (const GenericBug *bug)
 ClassOf.
 

Additional Inherited Members

- Public Types inherited from SVF::GenericBug
enum  BugType {
  FULLBUFOVERFLOW , PARTIALBUFOVERFLOW , NEVERFREE , PARTIALLEAK ,
  DOUBLEFREE , FILENEVERCLOSE , FILEPARTIALCLOSE , FULLNULLPTRDEREFERENCE ,
  PARTIALNULLPTRDEREFERENCE
}
 
typedef std::vector< SVFBugEventEventStack
 
- Static Public Attributes inherited from SVF::GenericBug
static const OrderedMap< GenericBug::BugType, std::string > BugType2Str
 
- Protected Attributes inherited from SVF::GenericBug
BugType bugType
 
const EventStack bugEventStack
 

Detailed Description

Definition at line 190 of file SVFBugReport.h.

Constructor & Destructor Documentation

◆ PartialLeakBug()

SVF::PartialLeakBug::PartialLeakBug ( const EventStack bugEventStack)
inline

Definition at line 193 of file SVFBugReport.h.

193 :
GenericBug(BugType bugType, const EventStack &bugEventStack)
note: should be initialized with a bugEventStack
const EventStack bugEventStack

Member Function Documentation

◆ classof()

static bool SVF::PartialLeakBug::classof ( const GenericBug bug)
inlinestatic

ClassOf.

Definition at line 200 of file SVFBugReport.h.

201 {
202 return bug->getBugType() == GenericBug::PARTIALLEAK;
203 }
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ getBugDescription()

cJSON * PartialLeakBug::getBugDescription ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 132 of file SVFBugReport.cpp.

133{
136 auto lastBranchEventIt = bugEventStack.end() - 1;
137 for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
138 {
140 cJSON *branchLoc = cJSON_Parse((*eventIt).getEventLoc().c_str());
141 if(branchLoc == nullptr) branchLoc = cJSON_CreateObject();
142
143 cJSON *branchCondition = cJSON_CreateString((*eventIt).getEventDescription().c_str());
144
147
149 }
150
151 cJSON_AddItemToObject(bugDescription, "ConditionalFreePath", pathInfo);
152
153 return bugDescription;
154}
Definition cJSON.h:104

◆ printBugToTerminal()

void PartialLeakBug::printBugToTerminal ( ) const
virtual

Implements SVF::GenericBug.

Definition at line 156 of file SVFBugReport.cpp.

157{
158 SVFUtil::errs() << SVFUtil::bugMsg2("\t PartialLeak :") << " memory allocation at : ("
159 << GenericBug::getLoc() << ")\n";
160
161 SVFUtil::errs() << "\t\t conditional free path: \n";
162 auto lastBranchEventIt = bugEventStack.end() - 1;
163 for(auto eventIt = bugEventStack.begin(); eventIt != lastBranchEventIt; eventIt++)
164 {
165 SVFUtil::errs() << "\t\t --> (" << (*eventIt).getEventLoc() << "|" << (*eventIt).getEventDescription() << ") \n";
166 }
167 SVFUtil::errs() << "\n";
168}
const std::string getLoc() const
returns bug location as json format string
std::ostream & errs()
Overwrite llvm::errs()
Definition SVFUtil.h:58
std::string bugMsg2(const std::string &msg)
Definition SVFUtil.cpp:92

The documentation for this class was generated from the following files: