fix mem leaks
MODIFY
ir/instr.cpp
ir/instr.cpp
@@ -156,8 +156,6 @@ expr BinOp::getTypeConstraints() const {
getType() == rhs.getType();
}
-BinOp::~BinOp() {}
-
void Return::print(ostream &os) const {
os << "ret ";
@@ -175,8 +173,6 @@ expr Return::getTypeConstraints() const {
getType() == val.getType();
}
-Return::~Return() {}
-
void Unreachable::print(ostream &os) const {
os << "unreachable";
@@ -191,6 +187,4 @@ expr Unreachable::getTypeConstraints() const {
return true;
}
-Unreachable::~Unreachable() {}
-
}

MODIFY
ir/instr.h
ir/instr.h
@@ -33,7 +33,6 @@ public:
void print(std::ostream &os) const override;
StateValue toSMT(State &s) const override;
smt::expr getTypeConstraints() const override;
- ~BinOp();
};
@@ -46,7 +45,6 @@ public:
void print(std::ostream &os) const override;
StateValue toSMT(State &s) const override;
smt::expr getTypeConstraints() const override;
- ~Return();
};
@@ -57,7 +55,6 @@ public:
void print(std::ostream &os) const override;
StateValue toSMT(State &s) const override;
smt::expr getTypeConstraints() const override;
- ~Unreachable();
};
}

MODIFY
ir/type.cpp
ir/type.cpp
@@ -43,6 +43,7 @@ void Type::setName(const string &name) {
unsigned Type::bits() const {
UNREACHABLE();
}
+
expr Type::operator==(const Type &b) const {
#define CMP(Ty) \
if (auto lhs = dynamic_cast<const Ty*>(this)) { \
@@ -82,6 +83,8 @@ string Type::toString() const {
return s.str();
}
+Type::~Type() {}
+
expr VoidType::getTypeConstraints() const {
return true;

MODIFY
ir/type.h
ir/type.h
@@ -41,6 +41,8 @@ public:
virtual std::unique_ptr<Type> dup() const = 0;
virtual void print(std::ostream &os) const = 0;
std::string toString() const;
+
+ virtual ~Type();
};

MODIFY
ir/value.cpp
ir/value.cpp
@@ -57,8 +57,6 @@ expr IntConst::getTypeConstraints() const {
getType().atLeastBits(min_bits);
}
-IntConst::~IntConst() {}
-
void Input::print(std::ostream &os) const {
os << getName();
@@ -77,6 +75,4 @@ expr Input::getTypeConstraints() const {
return getType().getTypeConstraints();
}
-Input::~Input() {}
-
}

MODIFY
ir/value.h
ir/value.h
@@ -32,7 +32,7 @@ public:
virtual StateValue toSMT(State &s) const = 0;
virtual smt::expr getTypeConstraints() const = 0;
void fixupTypes(const smt::Model &m);
- virtual ~Value() = 0;
+ virtual ~Value();
friend std::ostream& operator<<(std::ostream &os, const Value &val);
};
@@ -46,7 +46,6 @@ public:
void print(std::ostream &os) const override;
StateValue toSMT(State &s) const override;
smt::expr getTypeConstraints() const override;
- ~IntConst() override;
};
@@ -57,7 +56,6 @@ public:
void print(std::ostream &os) const override;
StateValue toSMT(State &s) const override;
smt::expr getTypeConstraints() const override;
- ~Input() override;
};
}

fix mem leaks