aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp4
-rw-r--r--libsolidity/ast/AST.cpp17
-rw-r--r--libsolidity/ast/AST.h2
-rw-r--r--libsolidity/ast/ASTJsonConverter.cpp9
-rw-r--r--libsolidity/ast/Types.cpp2
-rw-r--r--libsolidity/codegen/ArrayUtils.cpp2
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp9
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp2
-rw-r--r--libsolidity/formal/SMTChecker.cpp2
-rw-r--r--libsolidity/formal/Z3Interface.cpp2
-rw-r--r--libsolidity/interface/CompilerStack.cpp3
-rw-r--r--libsolidity/interface/Exceptions.cpp3
12 files changed, 19 insertions, 38 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 3d119c82..bc040623 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -2398,11 +2398,11 @@ void TypeChecker::endVisit(Literal const& _literal)
_literal.annotation().type = make_shared<AddressType>(StateMutability::Payable);
string msg;
- if (_literal.value().length() != 42) // "0x" + 40 hex digits
+ if (_literal.valueWithoutUnderscores().length() != 42) // "0x" + 40 hex digits
// looksLikeAddress enforces that it is a hex literal starting with "0x"
msg =
"This looks like an address but is not exactly 40 hex digits. It is " +
- to_string(_literal.value().length() - 2) +
+ to_string(_literal.valueWithoutUnderscores().length() - 2) +
" hex digits.";
else if (!_literal.passesAddressChecksum())
{
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index 8e7a81a6..d9264230 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -311,8 +311,6 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const
return make_shared<FunctionType>(*this, _internal);
case Declaration::Visibility::External:
return {};
- default:
- solAssert(false, "visibility() should return a Visibility");
}
}
else
@@ -327,8 +325,6 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const
case Declaration::Visibility::Public:
case Declaration::Visibility::External:
return make_shared<FunctionType>(*this, _internal);
- default:
- solAssert(false, "visibility() should return a Visibility");
}
}
@@ -568,8 +564,6 @@ FunctionTypePointer VariableDeclaration::functionType(bool _internal) const
case Declaration::Visibility::Public:
case Declaration::Visibility::External:
return make_shared<FunctionType>(*this);
- default:
- solAssert(false, "visibility() should not return a Visibility");
}
// To make the compiler happy
@@ -639,6 +633,11 @@ IdentifierAnnotation& Identifier::annotation() const
return dynamic_cast<IdentifierAnnotation&>(*m_annotation);
}
+ASTString Literal::valueWithoutUnderscores() const
+{
+ return boost::erase_all_copy(value(), "_");
+}
+
bool Literal::isHexNumber() const
{
if (token() != Token::Number)
@@ -654,20 +653,20 @@ bool Literal::looksLikeAddress() const
if (!isHexNumber())
return false;
- return abs(int(value().length()) - 42) <= 1;
+ return abs(int(valueWithoutUnderscores().length()) - 42) <= 1;
}
bool Literal::passesAddressChecksum() const
{
solAssert(isHexNumber(), "Expected hex number");
- return dev::passesAddressChecksum(value(), true);
+ return dev::passesAddressChecksum(valueWithoutUnderscores(), true);
}
string Literal::getChecksummedAddress() const
{
solAssert(isHexNumber(), "Expected hex number");
/// Pad literal to be a proper hex address.
- string address = value().substr(2);
+ string address = valueWithoutUnderscores().substr(2);
if (address.length() > 40)
return string();
address.insert(address.begin(), 40 - address.size(), '0');
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index f3464f92..b84f9730 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -1679,6 +1679,8 @@ public:
/// @returns the non-parsed value of the literal
ASTString const& value() const { return *m_value; }
+ ASTString valueWithoutUnderscores() const;
+
SubDenomination subDenomination() const { return m_subDenomination; }
/// @returns true if this is a number with a hex prefix.
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp
index 8d52851a..cadc5f28 100644
--- a/libsolidity/ast/ASTJsonConverter.cpp
+++ b/libsolidity/ast/ASTJsonConverter.cpp
@@ -752,9 +752,9 @@ string ASTJsonConverter::location(VariableDeclaration::Location _location)
return "memory";
case VariableDeclaration::Location::CallData:
return "calldata";
- default:
- solAssert(false, "Unknown declaration location.");
}
+ // To make the compiler happy
+ return {};
}
string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind)
@@ -767,9 +767,10 @@ string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind)
return "contract";
case ContractDefinition::ContractKind::Library:
return "library";
- default:
- solAssert(false, "Unknown kind of contract.");
}
+
+ // To make the compiler happy
+ return {};
}
string ASTJsonConverter::functionCallKind(FunctionCallKind _kind)
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index fd72bf41..e45fc81d 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -499,7 +499,7 @@ u256 AddressType::literalValue(Literal const* _literal) const
{
solAssert(_literal, "");
solAssert(_literal->value().substr(0, 2) == "0x", "");
- return u256(_literal->value());
+ return u256(_literal->valueWithoutUnderscores());
}
TypePointer AddressType::unaryOperatorResult(Token::Value _operator) const
diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp
index 2b77db8f..d33f749c 100644
--- a/libsolidity/codegen/ArrayUtils.cpp
+++ b/libsolidity/codegen/ArrayUtils.cpp
@@ -1108,8 +1108,6 @@ void ArrayUtils::accessIndex(ArrayType const& _arrayType, bool _doBoundsCheck) c
m_context << endTag;
break;
}
- default:
- solAssert(false, "");
}
}
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index e6ad6d9c..2bdf88e3 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -895,15 +895,6 @@ void CompilerUtils::convertType(
typeOnStack.location() == DataLocation::CallData,
"Invalid conversion to calldata type.");
break;
- default:
- solAssert(
- false,
- "Invalid type conversion " +
- _typeOnStack.toString(false) +
- " to " +
- _targetType.toString(false) +
- " requested."
- );
}
break;
}
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 587cf34a..27440289 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1098,8 +1098,6 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
case FunctionType::Kind::GasLeft:
m_context << Instruction::GAS;
break;
- default:
- solAssert(false, "Invalid function type.");
}
}
return false;
diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp
index 49c90405..19785817 100644
--- a/libsolidity/formal/SMTChecker.cpp
+++ b/libsolidity/formal/SMTChecker.cpp
@@ -639,8 +639,6 @@ void SMTChecker::checkCondition(
case smt::CheckResult::ERROR:
m_errorReporter.warning(_location, "Error trying to invoke SMT solver.");
break;
- default:
- solAssert(false, "");
}
m_interface->pop();
}
diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp
index 747c9172..9a0ccf48 100644
--- a/libsolidity/formal/Z3Interface.cpp
+++ b/libsolidity/formal/Z3Interface.cpp
@@ -91,8 +91,6 @@ pair<CheckResult, vector<string>> Z3Interface::check(vector<Expression> const& _
case z3::check_result::unknown:
result = CheckResult::UNKNOWN;
break;
- default:
- solAssert(false, "");
}
if (result == CheckResult::SATISFIABLE && !_expressionsToEvaluate.empty())
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index adf59a9c..d1001c80 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -988,8 +988,7 @@ Json::Value CompilerStack::gasEstimates(string const& _contractName) const
if (eth::AssemblyItems const* items = assemblyItems(_contractName))
{
Gas executionGas = gasEstimator.functionalEstimation(*items);
- u256 bytecodeSize(runtimeObject(_contractName).bytecode.size());
- Gas codeDepositGas = bytecodeSize * eth::GasCosts::createDataGas;
+ Gas codeDepositGas{eth::GasMeter::dataGas(runtimeObject(_contractName).bytecode, false)};
Json::Value creation(Json::objectValue);
creation["codeDepositCost"] = gasToJson(codeDepositGas);
diff --git a/libsolidity/interface/Exceptions.cpp b/libsolidity/interface/Exceptions.cpp
index a837dce6..ecadd0b7 100644
--- a/libsolidity/interface/Exceptions.cpp
+++ b/libsolidity/interface/Exceptions.cpp
@@ -49,9 +49,6 @@ Error::Error(Type _type, SourceLocation const& _location, string const& _descrip
case Type::Warning:
m_typeName = "Warning";
break;
- default:
- solAssert(false, "");
- break;
}
if (!_location.isEmpty())