Files
revng-revng/lib/RestructureCFGPass/ExprNode.cpp
T
Pietro Fezzardi cb58b8a526 Fix destruction of ExprNodes class hierarchy
`ExprNode` and its child classes use LLVM-style RTTI.

Until now their destruction was not handled properly, causing the
constructor-destructor type mismatch warnings on ASAN.
Despite this all the code was working properly, but just for luck,
because of the fact that these classes are very shallow.

This commit fixes the issue, and allow `ExprNode` and its child classes
to be extended without worrying about wrong destructors being invoked.
2019-11-20 15:16:17 +01:00

29 lines
659 B
C++

//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
// revng includes
#include <revng/Support/Debug.h>
// Local libraries includes
#include "revng-c/RestructureCFGPass/ExprNode.h"
void ExprNode::deleteExprNode(ExprNode *E) {
switch (E->getKind()) {
case NodeKind::NK_Atomic:
delete static_cast<AtomicNode *>(E);
break;
case NodeKind::NK_Not:
delete static_cast<NotNode *>(E);
break;
case NodeKind::NK_And:
delete static_cast<AndNode *>(E);
break;
case NodeKind::NK_Or:
delete static_cast<OrNode *>(E);
break;
default:
revng_unreachable("Deleting unexpected ExprNode");
}
}