From bbd2c91e199ebdffa27359888337016cc78603ae Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Tue, 26 Feb 2019 00:47:59 +0100 Subject: [PATCH] [SMTChecker] Replace dynamic_cast by category check --- libsolidity/formal/SMTChecker.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp index a9e3c171f..234eba106 100644 --- a/libsolidity/formal/SMTChecker.cpp +++ b/libsolidity/formal/SMTChecker.cpp @@ -414,7 +414,7 @@ void SMTChecker::endVisit(UnaryOperation const& _op) case Token::Sub: // - { defineExpr(_op, 0 - expr(_op.subExpression())); - if (dynamic_cast(_op.annotation().type.get())) + if (_op.annotation().type->category() == Type::Category::Integer) addOverflowTarget( OverflowTarget::Type::All, _op.annotation().type, @@ -625,10 +625,8 @@ void SMTChecker::endVisit(Identifier const& _identifier) { // Will be translated as part of the node that requested the lvalue. } - else if (dynamic_cast(_identifier.annotation().type.get())) - { + else if (_identifier.annotation().type->category() == Type::Category::Function) visitFunctionIdentifier(_identifier); - } else if (isSupportedType(_identifier.annotation().type->category())) { if (VariableDeclaration const* decl = dynamic_cast(_identifier.annotation().referencedDeclaration)) @@ -1006,11 +1004,11 @@ void SMTChecker::assignment(VariableDeclaration const& _variable, Expression con void SMTChecker::assignment(VariableDeclaration const& _variable, smt::Expression const& _value, SourceLocation const& _location) { TypePointer type = _variable.type(); - if (dynamic_cast(type.get())) + if (type->category() == Type::Category::Integer) addOverflowTarget(OverflowTarget::Type::All, type, _value, _location); - else if (dynamic_cast(type.get())) + else if (type->category() == Type::Category::Address) addOverflowTarget(OverflowTarget::Type::All, make_shared(160), _value, _location); - else if (dynamic_cast(type.get())) + else if (type->category() == Type::Category::Mapping) arrayAssignment(); m_interface->addAssertion(newValue(_variable) == _value); }