Skip to content

Commit

Permalink
Remove virtual calls in constructor/destructor (#1428)
Browse files Browse the repository at this point in the history
* AddressTranslateWin

Found using cppcheck:

common/src/addrtranslate-win.C:49:17: style: Virtual function 'init' is called from constructor 'AddressTranslateWin(PID pid,PROC_HANDLE phandle)' at line 168. Dynamic binding is not used. [virtualCallInConstructor]
   virtual bool init();

* NodeIteratorPredicateObj

Found using cppcheck:

common/src/NodeIterator.h:293:18: style: Virtual function 'inc' is
called from constructor
'NodeIteratorPredicateObj(Graph::NodePredicate::Ptr
p,NodeIterator&b,NodeIterator&e)' at line 331. Dynamic binding is not
used. [virtualCallInConstructor]

* NodeIteratorPredicateFunc

Found using cppcheck:

common/src/NodeIterator.h:352:18: style: Virtual function 'inc' is
called from constructor
'NodeIteratorPredicateFunc(Graph::NodePredicateFunc
p,void*u,NodeIterator&b,NodeIterator&e)' at line 394. Dynamic binding is
not used. [virtualCallInConstructor]

* InstructionDecoder_x86

Found using cppcheck:

instructionAPI/src/InstructionDecoder-x86.h:74:49: style: Virtual function 'setMode' is called from constructor 'InstructionDecoder_x86(Architecture a)' at line 144. Dynamic binding is not used. [virtualCallInConstructor]
                INSTRUCTION_EXPORT virtual void setMode(bool is64);
                                                ^
instructionAPI/src/InstructionDecoder-x86.C:144:28: note: Calling setMode
      if(a == Arch_x86_64) setMode(true);
                           ^
instructionAPI/src/InstructionDecoder-x86.h:74:49: note: setMode is a virtual function
                INSTRUCTION_EXPORT virtual void setMode(bool is64);

* CFGFactor::destroy_block

Found using cppcheck:

parseAPI/h/CFGFactory.h:117:18: style: Virtual function 'free_block' is called from destructor '~CFGFactory()' at line 92. Dynamic binding is not used. [virtualCallInConstructor]
    virtual void free_block(Block * b);
                 ^
parseAPI/src/CFGFactory.C:92:5: note: Calling destroy_block
    destroy_block(b);
    ^
parseAPI/src/CFGFactory.C:182:5: note: Calling free_block
    free_block(b);
    ^
parseAPI/h/CFGFactory.h:117:18: note: free_block is a virtual function
    virtual void free_block(Block * b);

* CFGFactor::free_func

Found using cppcheck:

parseAPI/h/CFGFactory.h:116:18: style: Virtual function 'free_func' is called from destructor '~CFGFactory()' at line 95. Dynamic binding is not used. [virtualCallInConstructor]
    virtual void free_func(Function * f);
                 ^
parseAPI/src/CFGFactory.C:95:5: note: Calling destroy_func
    destroy_func(f);
    ^
parseAPI/src/CFGFactory.C:172:4: note: Calling free_func
   free_func(f);
   ^
parseAPI/h/CFGFactory.h:116:18: note: free_func is a virtual function
    virtual void free_func(Function * f);

* CFGFactor::free_edge

* ~freebsd_process

Found using cppcheck:

proccontrol/src/freebsd.C:1046:17: warning: Member variable 'freebsd_thread::is_exited' is not initialized in the constructor. [uninitMemberVar]
freebsd_thread::freebsd_thread(int_process *p, Dyninst::THR_ID t, Dyninst::LWP l)
                ^
proccontrol/src/freebsd.h:122:17: style: Virtual function 'getEventQueue' is called from destructor '~freebsd_process()' at line 795. Dynamic binding is not used. [virtualCallInConstructor]
    virtual int getEventQueue();
                ^
proccontrol/src/freebsd.C:795:22: note: Calling getEventQueue
    int eventQueue = getEventQueue();
                     ^
proccontrol/src/freebsd.h:122:17: note: getEventQueue is a virtual function
    virtual int getEventQueue();
  • Loading branch information
hainest authored May 9, 2023
1 parent d6ab42a commit 85fb0f9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions common/src/NodeIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class NodeIteratorPredicateObj : public NodeIteratorImpl {
// next is now a matching node. If the start wasn't,
// then we need to increment...
if ((cur != end) && !pred->predicate(*cur)) {
inc();
NodeIteratorPredicateObj::inc();
}
}
void setNext() {
Expand Down Expand Up @@ -391,7 +391,7 @@ class NodeIteratorPredicateFunc : public NodeIteratorImpl {
// next is now a matching node. If the start wasn't,
// then we need to increment...
if ((cur != end) && !pred(*cur, user_arg)) {
inc();
NodeIteratorPredicateFunc::inc();
}
}
void setNext() {
Expand Down
2 changes: 1 addition & 1 deletion common/src/addrtranslate-win.C
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ AddressTranslateWin::AddressTranslateWin(PID pid, PROC_HANDLE phandle_) :
AddressTranslate(pid, phandle_),
no_proc(false)
{
init();
AddressTranslateWin::init();
}

Address AddressTranslateWin::getLibraryTrapAddrSysV()
Expand Down
2 changes: 1 addition & 1 deletion instructionAPI/src/InstructionDecoder-x86.C
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace Dyninst
sizePrefixPresent(false),
addrSizePrefixPresent(false)
{
if(a == Arch_x86_64) setMode(true);
if(a == Arch_x86_64) InstructionDecoder_x86::setMode(true);

}
INSTRUCTION_EXPORT InstructionDecoder_x86::~InstructionDecoder_x86()
Expand Down
6 changes: 3 additions & 3 deletions parseAPI/src/CFGFactory.C
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ CFGFactory::mkedge(Block * src, Block * trg, EdgeTypeEnum type) {
}

void CFGFactory::destroy_func(Function *f) {
free_func(f);
CFGFactory::free_func(f);
}

void
Expand All @@ -179,7 +179,7 @@ CFGFactory::free_func(Function *f) {

void
CFGFactory::destroy_block(Block *b) {
free_block(b);
CFGFactory::free_block(b);
}

void
Expand All @@ -202,7 +202,7 @@ std::string to_str(EdgeState e)
void
CFGFactory::destroy_edge(Edge *e, Dyninst::ParseAPI::EdgeState reason) {
if(reason == destroyed_all) {
free_edge(e);
CFGFactory::free_edge(e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion proccontrol/src/freebsd.C
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ freebsd_process::freebsd_process(Dyninst::PID pid_, int_process *p) :

freebsd_process::~freebsd_process()
{
int eventQueue = getEventQueue();
int eventQueue = freebsd_process::getEventQueue();
if( -1 != eventQueue ) {
// Remove the event for this process
struct kevent event;
Expand Down

0 comments on commit 85fb0f9

Please sign in to comment.