mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into develop_060
This commit is contained in:
commit
edf1e83fda
@ -119,7 +119,7 @@ Use `solAssert` and `solUnimplementedAssert` generously to check assumptions tha
|
||||
4. Favour declarations close to use; don't habitually declare at top of scope ala C.
|
||||
5. Pass non-trivial parameters as const reference, unless the data is to be copied into the function, then either pass by const reference or by value and use std::move.
|
||||
6. If a function returns multiple values, use std::tuple (std::pair acceptable) or better introduce a struct type. Do not use */& arguments.
|
||||
7. Use parameters of pointer type only if ``nullptr`` is a valid argument, use references otherwise. Often, ``boost::optional`` is better suited than a raw pointer.
|
||||
7. Use parameters of pointer type only if ``nullptr`` is a valid argument, use references otherwise. Often, ``std::optional`` is better suited than a raw pointer.
|
||||
8. Never use a macro where adequate non-preprocessor C++ can be written.
|
||||
9. Only use ``auto`` if the type is very long and rather irrelevant.
|
||||
10. Do not pass bools: prefer enumerations instead.
|
||||
|
@ -25,11 +25,10 @@
|
||||
|
||||
#include <libdevcore/Common.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
#include <cstring>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <functional>
|
||||
@ -277,7 +276,7 @@ void iterateReplacing(std::vector<T>& _vector, F const& _f)
|
||||
std::vector<T> modifiedVector;
|
||||
for (size_t i = 0; i < _vector.size(); ++i)
|
||||
{
|
||||
if (boost::optional<std::vector<T>> r = _f(_vector[i]))
|
||||
if (std::optional<std::vector<T>> r = _f(_vector[i]))
|
||||
{
|
||||
if (!useModified)
|
||||
{
|
||||
@ -305,7 +304,7 @@ void iterateReplacingWindow(std::vector<T>& _vector, F const& _f, std::index_seq
|
||||
size_t i = 0;
|
||||
for (; i + sizeof...(I) <= _vector.size(); ++i)
|
||||
{
|
||||
if (boost::optional<std::vector<T>> r = _f(_vector[i + I]...))
|
||||
if (std::optional<std::vector<T>> r = _f(_vector[i + I]...))
|
||||
{
|
||||
if (!useModified)
|
||||
{
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
#include <libevmasm/Instruction.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
|
||||
@ -51,12 +51,12 @@ public:
|
||||
static EVMVersion istanbul() { return {Version::Istanbul}; }
|
||||
static EVMVersion berlin() { return {Version::Berlin}; }
|
||||
|
||||
static boost::optional<EVMVersion> fromString(std::string const& _version)
|
||||
static std::optional<EVMVersion> fromString(std::string const& _version)
|
||||
{
|
||||
for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin()})
|
||||
if (_version == v.name())
|
||||
return v;
|
||||
return {};
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool operator==(EVMVersion const& _other) const { return m_version == _other.m_version; }
|
||||
|
@ -53,8 +53,9 @@
|
||||
#include <liblangutil/Common.h>
|
||||
#include <liblangutil/Exceptions.h>
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <tuple>
|
||||
|
||||
@ -187,7 +188,7 @@ bool Scanner::scanHexByte(char& o_scannedByte)
|
||||
return true;
|
||||
}
|
||||
|
||||
boost::optional<unsigned> Scanner::scanUnicode()
|
||||
std::optional<unsigned> Scanner::scanUnicode()
|
||||
{
|
||||
unsigned x = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
@ -718,7 +719,7 @@ bool Scanner::scanEscape()
|
||||
break;
|
||||
case 'u':
|
||||
{
|
||||
if (boost::optional<unsigned> codepoint = scanUnicode())
|
||||
if (auto const codepoint = scanUnicode(); codepoint.has_value())
|
||||
addUnicodeAsUTF8(*codepoint);
|
||||
else
|
||||
return false;
|
||||
|
@ -57,6 +57,8 @@
|
||||
#include <liblangutil/SourceLocation.h>
|
||||
#include <libdevcore/Common.h>
|
||||
#include <libdevcore/CommonData.h>
|
||||
|
||||
#include <optional>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace langutil
|
||||
@ -207,7 +209,7 @@ private:
|
||||
inline Token selectToken(char _next, Token _then, Token _else);
|
||||
|
||||
bool scanHexByte(char& o_scannedByte);
|
||||
boost::optional<unsigned> scanUnicode();
|
||||
std::optional<unsigned> scanUnicode();
|
||||
|
||||
/// Scans a single Solidity token.
|
||||
void scanToken();
|
||||
|
@ -122,7 +122,7 @@ bool ReferencesResolver::visit(ElementaryTypeName const& _typeName)
|
||||
if (!_typeName.annotation().type)
|
||||
{
|
||||
_typeName.annotation().type = TypeProvider::fromElementaryTypeName(_typeName.typeName());
|
||||
if (_typeName.stateMutability().is_initialized())
|
||||
if (_typeName.stateMutability().has_value())
|
||||
{
|
||||
// for non-address types this was already caught by the parser
|
||||
solAssert(_typeName.annotation().type->category() == Type::Category::Address, "");
|
||||
|
@ -239,7 +239,7 @@ void ViewPureChecker::endVisit(InlineAssembly const& _inlineAssembly)
|
||||
void ViewPureChecker::reportMutability(
|
||||
StateMutability _mutability,
|
||||
SourceLocation const& _location,
|
||||
boost::optional<SourceLocation> const& _nestedLocation
|
||||
std::optional<SourceLocation> const& _nestedLocation
|
||||
)
|
||||
{
|
||||
if (_mutability > m_bestMutabilityAndLocation.mutability)
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace langutil
|
||||
{
|
||||
@ -68,7 +69,7 @@ private:
|
||||
void reportMutability(
|
||||
StateMutability _mutability,
|
||||
langutil::SourceLocation const& _location,
|
||||
boost::optional<langutil::SourceLocation> const& _nestedLocation = {}
|
||||
std::optional<langutil::SourceLocation> const& _nestedLocation = {}
|
||||
);
|
||||
|
||||
std::vector<std::shared_ptr<ASTNode>> const& m_ast;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <json/json.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -949,10 +950,10 @@ public:
|
||||
ElementaryTypeName(
|
||||
SourceLocation const& _location,
|
||||
ElementaryTypeNameToken const& _elem,
|
||||
boost::optional<StateMutability> _stateMutability = {}
|
||||
std::optional<StateMutability> _stateMutability = {}
|
||||
): TypeName(_location), m_type(_elem), m_stateMutability(_stateMutability)
|
||||
{
|
||||
solAssert(!_stateMutability.is_initialized() || _elem.token() == Token::Address, "");
|
||||
solAssert(!_stateMutability.has_value() || _elem.token() == Token::Address, "");
|
||||
}
|
||||
|
||||
void accept(ASTVisitor& _visitor) override;
|
||||
@ -960,11 +961,11 @@ public:
|
||||
|
||||
ElementaryTypeNameToken const& typeName() const { return m_type; }
|
||||
|
||||
boost::optional<StateMutability> const& stateMutability() const { return m_stateMutability; }
|
||||
std::optional<StateMutability> const& stateMutability() const { return m_stateMutability; }
|
||||
|
||||
private:
|
||||
ElementaryTypeNameToken m_type;
|
||||
boost::optional<StateMutability> m_stateMutability; ///< state mutability for address type
|
||||
std::optional<StateMutability> m_stateMutability; ///< state mutability for address type
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -26,10 +26,9 @@
|
||||
#include <libsolidity/ast/ASTEnums.h>
|
||||
#include <libsolidity/ast/ExperimentalFeatures.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@ -183,7 +182,7 @@ struct ExpressionAnnotation: ASTAnnotation
|
||||
|
||||
/// Types and - if given - names of arguments if the expr. is a function
|
||||
/// that is called, used for overload resoultion
|
||||
boost::optional<FuncCallArguments> arguments;
|
||||
std::optional<FuncCallArguments> arguments;
|
||||
};
|
||||
|
||||
struct IdentifierAnnotation: ExpressionAnnotation
|
||||
|
@ -148,7 +148,7 @@ Json::Value ASTJsonConverter::typePointerToJson(TypePointer _tp, bool _short)
|
||||
return typeDescriptions;
|
||||
|
||||
}
|
||||
Json::Value ASTJsonConverter::typePointerToJson(boost::optional<FuncCallArguments> const& _tps)
|
||||
Json::Value ASTJsonConverter::typePointerToJson(std::optional<FuncCallArguments> const& _tps)
|
||||
{
|
||||
if (_tps)
|
||||
{
|
||||
|
@ -27,10 +27,12 @@
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace langutil
|
||||
{
|
||||
@ -172,7 +174,7 @@ private:
|
||||
return json;
|
||||
}
|
||||
static Json::Value typePointerToJson(TypePointer _tp, bool _short = false);
|
||||
static Json::Value typePointerToJson(boost::optional<FuncCallArguments> const& _tps);
|
||||
static Json::Value typePointerToJson(std::optional<FuncCallArguments> const& _tps);
|
||||
void appendExpressionAttributes(
|
||||
std::vector<std::pair<std::string, Json::Value>> &_attributes,
|
||||
ExpressionAnnotation const& _annotation
|
||||
|
@ -202,7 +202,7 @@ inline T const* TypeProvider::createAndGet(Args&& ... _args)
|
||||
return static_cast<T const*>(instance().m_generalTypes.back().get());
|
||||
}
|
||||
|
||||
Type const* TypeProvider::fromElementaryTypeName(ElementaryTypeNameToken const& _type, boost::optional<StateMutability> _stateMutability)
|
||||
Type const* TypeProvider::fromElementaryTypeName(ElementaryTypeNameToken const& _type, std::optional<StateMutability> _stateMutability)
|
||||
{
|
||||
solAssert(
|
||||
TokenTraits::isElementaryTypeName(_type.token()),
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
namespace dev
|
||||
@ -54,7 +55,7 @@ public:
|
||||
|
||||
/// @name Factory functions
|
||||
/// Factory functions that convert an AST @ref TypeName to a Type.
|
||||
static Type const* fromElementaryTypeName(ElementaryTypeNameToken const& _type, boost::optional<StateMutability> _stateMutability = {});
|
||||
static Type const* fromElementaryTypeName(ElementaryTypeNameToken const& _type, std::optional<StateMutability> _stateMutability = {});
|
||||
|
||||
/// Converts a given elementary type name with optional data location
|
||||
/// suffix " storage", " calldata" or " memory" to a type pointer. If suffix not given, defaults to " storage".
|
||||
|
@ -1824,10 +1824,10 @@ TypePointer ArrayType::decodingType() const
|
||||
|
||||
TypeResult ArrayType::interfaceType(bool _inLibrary) const
|
||||
{
|
||||
if (_inLibrary && m_interfaceType_library.is_initialized())
|
||||
if (_inLibrary && m_interfaceType_library.has_value())
|
||||
return *m_interfaceType_library;
|
||||
|
||||
if (!_inLibrary && m_interfaceType.is_initialized())
|
||||
if (!_inLibrary && m_interfaceType.has_value())
|
||||
return *m_interfaceType;
|
||||
|
||||
TypeResult result{TypePointer{}};
|
||||
@ -2142,10 +2142,10 @@ MemberList::MemberMap StructType::nativeMembers(ContractDefinition const*) const
|
||||
|
||||
TypeResult StructType::interfaceType(bool _inLibrary) const
|
||||
{
|
||||
if (_inLibrary && m_interfaceType_library.is_initialized())
|
||||
if (_inLibrary && m_interfaceType_library.has_value())
|
||||
return *m_interfaceType_library;
|
||||
|
||||
if (!_inLibrary && m_interfaceType.is_initialized())
|
||||
if (!_inLibrary && m_interfaceType.has_value())
|
||||
return *m_interfaceType;
|
||||
|
||||
TypeResult result{TypePointer{}};
|
||||
@ -2202,7 +2202,7 @@ TypeResult StructType::interfaceType(bool _inLibrary) const
|
||||
}
|
||||
};
|
||||
|
||||
m_recursive = m_recursive.get() || (CycleDetector<StructDefinition>(visitor).run(structDefinition()) != nullptr);
|
||||
m_recursive = m_recursive.value() || (CycleDetector<StructDefinition>(visitor).run(structDefinition()) != nullptr);
|
||||
|
||||
std::string const recursiveErrMsg = "Recursive type not allowed for public or external contract functions.";
|
||||
|
||||
@ -2215,13 +2215,13 @@ TypeResult StructType::interfaceType(bool _inLibrary) const
|
||||
else
|
||||
m_interfaceType_library = TypeProvider::withLocation(this, DataLocation::Memory, true);
|
||||
|
||||
if (m_recursive.get())
|
||||
if (m_recursive.value())
|
||||
m_interfaceType = TypeResult::err(recursiveErrMsg);
|
||||
|
||||
return *m_interfaceType_library;
|
||||
}
|
||||
|
||||
if (m_recursive.get())
|
||||
if (m_recursive.value())
|
||||
m_interfaceType = TypeResult::err(recursiveErrMsg);
|
||||
else if (!result.message().empty())
|
||||
m_interfaceType = result;
|
||||
|
@ -31,11 +31,11 @@
|
||||
#include <libdevcore/CommonIO.h>
|
||||
#include <libdevcore/Result.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/rational.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
@ -769,8 +769,8 @@ private:
|
||||
Type const* m_baseType;
|
||||
bool m_hasDynamicLength = true;
|
||||
u256 m_length;
|
||||
mutable boost::optional<TypeResult> m_interfaceType;
|
||||
mutable boost::optional<TypeResult> m_interfaceType_library;
|
||||
mutable std::optional<TypeResult> m_interfaceType;
|
||||
mutable std::optional<TypeResult> m_interfaceType_library;
|
||||
};
|
||||
|
||||
class ArraySliceType: public ReferenceType
|
||||
@ -894,12 +894,12 @@ public:
|
||||
|
||||
bool recursive() const
|
||||
{
|
||||
if (m_recursive.is_initialized())
|
||||
return m_recursive.get();
|
||||
if (m_recursive.has_value())
|
||||
return m_recursive.value();
|
||||
|
||||
interfaceType(false);
|
||||
|
||||
return m_recursive.get();
|
||||
return m_recursive.value();
|
||||
}
|
||||
|
||||
std::unique_ptr<ReferenceType> copyForLocation(DataLocation _location, bool _isPointer) const override;
|
||||
@ -927,9 +927,9 @@ public:
|
||||
private:
|
||||
StructDefinition const& m_struct;
|
||||
// Caches for interfaceType(bool)
|
||||
mutable boost::optional<TypeResult> m_interfaceType;
|
||||
mutable boost::optional<TypeResult> m_interfaceType_library;
|
||||
mutable boost::optional<bool> m_recursive;
|
||||
mutable std::optional<TypeResult> m_interfaceType;
|
||||
mutable std::optional<TypeResult> m_interfaceType_library;
|
||||
mutable std::optional<bool> m_recursive;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -957,11 +957,11 @@ string YulUtilFunctions::readFromCalldata(Type const& _type)
|
||||
return readFromMemoryOrCalldata(_type, true);
|
||||
}
|
||||
|
||||
string YulUtilFunctions::updateStorageValueFunction(Type const& _type, boost::optional<unsigned> const& _offset)
|
||||
string YulUtilFunctions::updateStorageValueFunction(Type const& _type, std::optional<unsigned> const& _offset)
|
||||
{
|
||||
string const functionName =
|
||||
"update_storage_value_" +
|
||||
(_offset.is_initialized() ? ("offset_" + to_string(*_offset)) : "") +
|
||||
(_offset.has_value() ? ("offset_" + to_string(*_offset)) : "") +
|
||||
_type.identifier();
|
||||
|
||||
return m_functionCollector->createFunction(functionName, [&] {
|
||||
@ -978,11 +978,11 @@ string YulUtilFunctions::updateStorageValueFunction(Type const& _type, boost::op
|
||||
)")
|
||||
("functionName", functionName)
|
||||
("update",
|
||||
_offset.is_initialized() ?
|
||||
_offset.has_value() ?
|
||||
updateByteSliceFunction(_type.storageBytes(), *_offset) :
|
||||
updateByteSliceFunctionDynamic(_type.storageBytes())
|
||||
)
|
||||
("offset", _offset.is_initialized() ? "" : "offset, ")
|
||||
("offset", _offset.has_value() ? "" : "offset, ")
|
||||
("prepare", prepareStoreFunction(_type))
|
||||
.render();
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public:
|
||||
/// the specified slot and offset. If offset is not given, it is expected as
|
||||
/// runtime parameter.
|
||||
/// signature: (slot, [offset,] value)
|
||||
std::string updateStorageValueFunction(Type const& _type, boost::optional<unsigned> const& _offset = boost::optional<unsigned>());
|
||||
std::string updateStorageValueFunction(Type const& _type, std::optional<unsigned> const& _offset = std::optional<unsigned>());
|
||||
|
||||
/// Returns the name of a function that will write the given value to
|
||||
/// the specified address.
|
||||
|
@ -115,7 +115,7 @@ string IRStorageItem::storeValue(string const& _value, Type const& _sourceType)
|
||||
if (m_type->isValueType())
|
||||
solAssert(_sourceType == *m_type, "Different type, but might not be an error.");
|
||||
|
||||
boost::optional<unsigned> offset;
|
||||
std::optional<unsigned> offset;
|
||||
|
||||
if (m_offset.type() == typeid(unsigned))
|
||||
offset = get<unsigned>(m_offset);
|
||||
|
@ -95,7 +95,7 @@ CompilerStack::~CompilerStack()
|
||||
TypeProvider::reset();
|
||||
}
|
||||
|
||||
boost::optional<CompilerStack::Remapping> CompilerStack::parseRemapping(string const& _remapping)
|
||||
std::optional<CompilerStack::Remapping> CompilerStack::parseRemapping(string const& _remapping)
|
||||
{
|
||||
auto eq = find(_remapping.begin(), _remapping.end(), '=');
|
||||
if (eq == _remapping.end())
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
void reset(bool _keepSettings = false);
|
||||
|
||||
// Parses a remapping of the format "context:prefix=target".
|
||||
static boost::optional<Remapping> parseRemapping(std::string const& _remapping);
|
||||
static std::optional<Remapping> parseRemapping(std::string const& _remapping);
|
||||
|
||||
/// Sets path remappings.
|
||||
/// Must be set before parsing.
|
||||
|
@ -31,8 +31,9 @@
|
||||
|
||||
#include <boost/algorithm/cxx11/any_of.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
@ -317,7 +318,7 @@ Json::Value collectEVMObject(eth::LinkerObject const& _object, string const* _so
|
||||
return output;
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkKeys(Json::Value const& _input, set<string> const& _keys, string const& _name)
|
||||
std::optional<Json::Value> checkKeys(Json::Value const& _input, set<string> const& _keys, string const& _name)
|
||||
{
|
||||
if (!!_input && !_input.isObject())
|
||||
return formatFatalError("JSONError", "\"" + _name + "\" must be an object");
|
||||
@ -326,46 +327,46 @@ boost::optional<Json::Value> checkKeys(Json::Value const& _input, set<string> co
|
||||
if (!_keys.count(member))
|
||||
return formatFatalError("JSONError", "Unknown key \"" + member + "\"");
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkRootKeys(Json::Value const& _input)
|
||||
std::optional<Json::Value> checkRootKeys(Json::Value const& _input)
|
||||
{
|
||||
static set<string> keys{"auxiliaryInput", "language", "settings", "sources"};
|
||||
return checkKeys(_input, keys, "root");
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkSourceKeys(Json::Value const& _input, string const& _name)
|
||||
std::optional<Json::Value> checkSourceKeys(Json::Value const& _input, string const& _name)
|
||||
{
|
||||
static set<string> keys{"content", "keccak256", "urls"};
|
||||
return checkKeys(_input, keys, "sources." + _name);
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkAuxiliaryInputKeys(Json::Value const& _input)
|
||||
std::optional<Json::Value> checkAuxiliaryInputKeys(Json::Value const& _input)
|
||||
{
|
||||
static set<string> keys{"smtlib2responses"};
|
||||
return checkKeys(_input, keys, "auxiliaryInput");
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkSettingsKeys(Json::Value const& _input)
|
||||
std::optional<Json::Value> checkSettingsKeys(Json::Value const& _input)
|
||||
{
|
||||
static set<string> keys{"parserErrorRecovery", "evmVersion", "libraries", "metadata", "optimizer", "outputSelection", "remappings"};
|
||||
return checkKeys(_input, keys, "settings");
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkOptimizerKeys(Json::Value const& _input)
|
||||
std::optional<Json::Value> checkOptimizerKeys(Json::Value const& _input)
|
||||
{
|
||||
static set<string> keys{"details", "enabled", "runs"};
|
||||
return checkKeys(_input, keys, "settings.optimizer");
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkOptimizerDetailsKeys(Json::Value const& _input)
|
||||
std::optional<Json::Value> checkOptimizerDetailsKeys(Json::Value const& _input)
|
||||
{
|
||||
static set<string> keys{"peephole", "jumpdestRemover", "orderLiterals", "deduplicate", "cse", "constantOptimizer", "yul", "yulDetails"};
|
||||
return checkKeys(_input, keys, "settings.optimizer.details");
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkOptimizerDetail(Json::Value const& _details, std::string const& _name, bool& _setting)
|
||||
std::optional<Json::Value> checkOptimizerDetail(Json::Value const& _details, std::string const& _name, bool& _setting)
|
||||
{
|
||||
if (_details.isMember(_name))
|
||||
{
|
||||
@ -376,7 +377,7 @@ boost::optional<Json::Value> checkOptimizerDetail(Json::Value const& _details, s
|
||||
return {};
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkMetadataKeys(Json::Value const& _input)
|
||||
std::optional<Json::Value> checkMetadataKeys(Json::Value const& _input)
|
||||
{
|
||||
if (_input.isObject())
|
||||
{
|
||||
@ -391,7 +392,7 @@ boost::optional<Json::Value> checkMetadataKeys(Json::Value const& _input)
|
||||
return checkKeys(_input, keys, "settings.metadata");
|
||||
}
|
||||
|
||||
boost::optional<Json::Value> checkOutputSelection(Json::Value const& _outputSelection)
|
||||
std::optional<Json::Value> checkOutputSelection(Json::Value const& _outputSelection)
|
||||
{
|
||||
if (!!_outputSelection && !_outputSelection.isObject())
|
||||
return formatFatalError("JSONError", "\"settings.outputSelection\" must be an object");
|
||||
@ -433,7 +434,7 @@ boost::optional<Json::Value> checkOutputSelection(Json::Value const& _outputSele
|
||||
}
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
/// Validates the optimizer settings and returns them in a parsed object.
|
||||
/// On error returns the json-formatted error message.
|
||||
@ -642,7 +643,7 @@ boost::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompile
|
||||
{
|
||||
if (!settings["evmVersion"].isString())
|
||||
return formatFatalError("JSONError", "evmVersion must be a string.");
|
||||
boost::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(settings["evmVersion"].asString());
|
||||
std::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(settings["evmVersion"].asString());
|
||||
if (!version)
|
||||
return formatFatalError("JSONError", "Invalid EVM version requested.");
|
||||
ret.evmVersion = *version;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
namespace dev
|
||||
|
@ -929,7 +929,9 @@ ASTPointer<TypeName> Parser::parseTypeName(bool _allowVar)
|
||||
ASTNodeFactory nodeFactory(*this);
|
||||
nodeFactory.markEndPosition();
|
||||
m_scanner->next();
|
||||
auto stateMutability = boost::make_optional(elemTypeName.token() == Token::Address, StateMutability::NonPayable);
|
||||
auto stateMutability = elemTypeName.token() == Token::Address
|
||||
? optional<StateMutability>{StateMutability::NonPayable}
|
||||
: nullopt;
|
||||
if (TokenTraits::isStateMutabilitySpecifier(m_scanner->currentToken(), false))
|
||||
{
|
||||
if (elemTypeName.token() == Token::Address)
|
||||
@ -1651,7 +1653,7 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression(
|
||||
nodeFactory.markEndPosition();
|
||||
auto expressionType = nodeFactory.createNode<ElementaryTypeName>(
|
||||
ElementaryTypeNameToken(Token::Address, 160, 0),
|
||||
boost::make_optional(StateMutability::Payable)
|
||||
std::make_optional(StateMutability::Payable)
|
||||
);
|
||||
expression = nodeFactory.createNode<ElementaryTypeNameExpression>(expressionType);
|
||||
expectToken(Token::LParen, false);
|
||||
|
@ -658,7 +658,7 @@ bool AsmAnalyzer::warnOnInstructions(std::string const& _instructionIdentifier,
|
||||
{
|
||||
auto const builtin = EVMDialect::strictAssemblyForEVM(EVMVersion{}).builtin(YulString(_instructionIdentifier));
|
||||
if (builtin)
|
||||
return warnOnInstructions(builtin->instruction.get(), _location);
|
||||
return warnOnInstructions(builtin->instruction.value(), _location);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -31,11 +31,11 @@
|
||||
#include <libyul/backends/evm/EVMDialect.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace langutil
|
||||
{
|
||||
|
@ -27,10 +27,10 @@
|
||||
#include <libdevcore/Visitor.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace yul
|
||||
{
|
||||
|
@ -704,9 +704,7 @@ void CodeTransform::visitExpression(Expression const& _expression)
|
||||
|
||||
void CodeTransform::visitStatements(vector<Statement> const& _statements)
|
||||
{
|
||||
// Workaround boost bug:
|
||||
// https://www.boost.org/doc/libs/1_63_0/libs/optional/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html
|
||||
boost::optional<AbstractAssembly::LabelID> jumpTarget = boost::make_optional(false, AbstractAssembly::LabelID());
|
||||
std::optional<AbstractAssembly::LabelID> jumpTarget = std::nullopt;
|
||||
|
||||
for (auto const& statement: _statements)
|
||||
{
|
||||
@ -721,7 +719,7 @@ void CodeTransform::visitStatements(vector<Statement> const& _statements)
|
||||
else if (!functionDefinition && jumpTarget)
|
||||
{
|
||||
m_assembly.appendLabel(*jumpTarget);
|
||||
jumpTarget = boost::none;
|
||||
jumpTarget = std::nullopt;
|
||||
}
|
||||
|
||||
boost::apply_visitor(*this, statement);
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include <libyul/AsmScope.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <stack>
|
||||
|
||||
namespace langutil
|
||||
|
@ -47,7 +47,7 @@ struct BuiltinContext
|
||||
|
||||
struct BuiltinFunctionForEVM: BuiltinFunction
|
||||
{
|
||||
boost::optional<dev::eth::Instruction> instruction;
|
||||
std::optional<dev::eth::Instruction> instruction;
|
||||
/// Function to generate code for the given function call and append it to the abstract
|
||||
/// assembly. The fourth parameter is called to visit (and generate code for) the arguments
|
||||
/// from right to left.
|
||||
|
@ -82,7 +82,7 @@ void WordSizeTransform::operator()(Block& _block)
|
||||
{
|
||||
iterateReplacing(
|
||||
_block.statements,
|
||||
[&](Statement& _s) -> boost::optional<vector<Statement>>
|
||||
[&](Statement& _s) -> std::optional<vector<Statement>>
|
||||
{
|
||||
if (_s.type() == typeid(VariableDeclaration))
|
||||
{
|
||||
@ -95,7 +95,7 @@ void WordSizeTransform::operator()(Block& _block)
|
||||
{
|
||||
if (varDecl.value) visit(*varDecl.value);
|
||||
rewriteVarDeclList(varDecl.variables);
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
else if (
|
||||
varDecl.value->type() == typeid(Identifier) ||
|
||||
@ -114,7 +114,7 @@ void WordSizeTransform::operator()(Block& _block)
|
||||
std::move(newRhs[i])
|
||||
}
|
||||
);
|
||||
return ret;
|
||||
return {std::move(ret)};
|
||||
}
|
||||
else
|
||||
yulAssert(false, "");
|
||||
@ -130,7 +130,7 @@ void WordSizeTransform::operator()(Block& _block)
|
||||
{
|
||||
if (assignment.value) visit(*assignment.value);
|
||||
rewriteIdentifierList(assignment.variableNames);
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
else if (
|
||||
assignment.value->type() == typeid(Identifier) ||
|
||||
@ -149,7 +149,7 @@ void WordSizeTransform::operator()(Block& _block)
|
||||
std::move(newRhs[i])
|
||||
}
|
||||
);
|
||||
return ret;
|
||||
return {std::move(ret)};
|
||||
}
|
||||
else
|
||||
yulAssert(false, "");
|
||||
@ -158,7 +158,7 @@ void WordSizeTransform::operator()(Block& _block)
|
||||
return handleSwitch(boost::get<Switch>(_s));
|
||||
else
|
||||
visit(_s);
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -174,7 +174,7 @@ void WordSizeTransform::rewriteVarDeclList(TypedNameList& _nameList)
|
||||
{
|
||||
iterateReplacing(
|
||||
_nameList,
|
||||
[&](TypedName const& _n) -> boost::optional<TypedNameList>
|
||||
[&](TypedName const& _n) -> std::optional<TypedNameList>
|
||||
{
|
||||
TypedNameList ret;
|
||||
for (auto newName: generateU64IdentifierNames(_n.name))
|
||||
@ -188,7 +188,7 @@ void WordSizeTransform::rewriteIdentifierList(vector<Identifier>& _ids)
|
||||
{
|
||||
iterateReplacing(
|
||||
_ids,
|
||||
[&](Identifier const& _id) -> boost::optional<vector<Identifier>>
|
||||
[&](Identifier const& _id) -> std::optional<vector<Identifier>>
|
||||
{
|
||||
vector<Identifier> ret;
|
||||
for (auto newId: m_variableMapping.at(_id.name))
|
||||
@ -202,7 +202,7 @@ void WordSizeTransform::rewriteFunctionCallArguments(vector<Expression>& _args)
|
||||
{
|
||||
iterateReplacing(
|
||||
_args,
|
||||
[&](Expression& _e) -> boost::optional<vector<Expression>>
|
||||
[&](Expression& _e) -> std::optional<vector<Expression>>
|
||||
{
|
||||
return expandValueToVector(_e);
|
||||
}
|
||||
|
@ -25,11 +25,11 @@
|
||||
#include <libyul/YulString.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace yul
|
||||
{
|
||||
|
@ -26,11 +26,11 @@
|
||||
#include <libyul/YulString.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace yul
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ void BlockFlattener::operator()(Block& _block)
|
||||
|
||||
iterateReplacing(
|
||||
_block.statements,
|
||||
[](Statement& _s) -> boost::optional<vector<Statement>>
|
||||
[](Statement& _s) -> std::optional<vector<Statement>>
|
||||
{
|
||||
if (_s.type() == typeid(Block))
|
||||
return std::move(boost::get<Block>(_s).statements);
|
||||
|
@ -24,10 +24,9 @@
|
||||
|
||||
#include <libdevcore/InvertibleMap.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
|
||||
namespace yul
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
|
||||
using OptionalStatements = boost::optional<vector<Statement>>;
|
||||
using OptionalStatements = std::optional<vector<Statement>>;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -354,7 +354,7 @@ bool DataFlowAnalyzer::inScope(YulString _variableName) const
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::optional<pair<YulString, YulString>> DataFlowAnalyzer::isSimpleStore(
|
||||
std::optional<pair<YulString, YulString>> DataFlowAnalyzer::isSimpleStore(
|
||||
dev::eth::Instruction _store,
|
||||
ExpressionStatement const& _statement
|
||||
) const
|
||||
|
@ -128,7 +128,7 @@ protected:
|
||||
/// Returns true iff the variable is in scope.
|
||||
bool inScope(YulString _variableName) const;
|
||||
|
||||
boost::optional<std::pair<YulString, YulString>> isSimpleStore(
|
||||
std::optional<std::pair<YulString, YulString>> isSimpleStore(
|
||||
dev::eth::Instruction _store,
|
||||
ExpressionStatement const& _statement
|
||||
) const;
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include <libyul/optimiser/NameDispenser.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <set>
|
||||
|
||||
namespace yul
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <libyul/AsmDataForward.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
|
||||
#include <set>
|
||||
|
||||
|
@ -85,8 +85,8 @@ void ExpressionSplitter::operator()(Block& _block)
|
||||
vector<Statement> saved;
|
||||
swap(saved, m_statementsToPrefix);
|
||||
|
||||
function<boost::optional<vector<Statement>>(Statement&)> f =
|
||||
[&](Statement& _statement) -> boost::optional<vector<Statement>> {
|
||||
function<std::optional<vector<Statement>>(Statement&)> f =
|
||||
[&](Statement& _statement) -> std::optional<vector<Statement>> {
|
||||
m_statementsToPrefix.clear();
|
||||
visit(_statement);
|
||||
if (m_statementsToPrefix.empty())
|
||||
|
@ -27,7 +27,7 @@ void ForLoopInitRewriter::operator()(Block& _block)
|
||||
{
|
||||
iterateReplacing(
|
||||
_block.statements,
|
||||
[&](Statement& _stmt) -> boost::optional<vector<Statement>>
|
||||
[&](Statement& _stmt) -> std::optional<vector<Statement>>
|
||||
{
|
||||
if (_stmt.type() == typeid(ForLoop))
|
||||
{
|
||||
|
@ -147,14 +147,14 @@ bool FullInliner::recursive(FunctionDefinition const& _fun) const
|
||||
|
||||
void InlineModifier::operator()(Block& _block)
|
||||
{
|
||||
function<boost::optional<vector<Statement>>(Statement&)> f = [&](Statement& _statement) -> boost::optional<vector<Statement>> {
|
||||
function<std::optional<vector<Statement>>(Statement&)> f = [&](Statement& _statement) -> std::optional<vector<Statement>> {
|
||||
visit(_statement);
|
||||
return tryInlineStatement(_statement);
|
||||
};
|
||||
iterateReplacing(_block.statements, f);
|
||||
}
|
||||
|
||||
boost::optional<vector<Statement>> InlineModifier::tryInlineStatement(Statement& _statement)
|
||||
std::optional<vector<Statement>> InlineModifier::tryInlineStatement(Statement& _statement)
|
||||
{
|
||||
// Only inline for expression statements, assignments and variable declarations.
|
||||
Expression* e = boost::apply_visitor(GenericFallbackReturnsVisitor<Expression*, ExpressionStatement, Assignment, VariableDeclaration>(
|
||||
|
@ -30,8 +30,8 @@
|
||||
#include <liblangutil/SourceLocation.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <set>
|
||||
|
||||
namespace yul
|
||||
@ -126,7 +126,7 @@ public:
|
||||
void operator()(Block& _block) override;
|
||||
|
||||
private:
|
||||
boost::optional<std::vector<Statement>> tryInlineStatement(Statement& _statement);
|
||||
std::optional<std::vector<Statement>> tryInlineStatement(Statement& _statement);
|
||||
std::vector<Statement> performInline(Statement& _statement, FunctionCall& _funCall);
|
||||
|
||||
YulString m_currentFunction;
|
||||
|
@ -35,7 +35,7 @@ void SSAReverser::operator()(Block& _block)
|
||||
walkVector(_block.statements);
|
||||
iterateReplacingWindow<2>(
|
||||
_block.statements,
|
||||
[&](Statement& _stmt1, Statement& _stmt2) -> boost::optional<vector<Statement>>
|
||||
[&](Statement& _stmt1, Statement& _stmt2) -> std::optional<vector<Statement>>
|
||||
{
|
||||
auto* varDecl = boost::get<VariableDeclaration>(&_stmt1);
|
||||
|
||||
|
@ -58,7 +58,7 @@ void IntroduceSSA::operator()(Block& _block)
|
||||
{
|
||||
iterateReplacing(
|
||||
_block.statements,
|
||||
[&](Statement& _s) -> boost::optional<vector<Statement>>
|
||||
[&](Statement& _s) -> std::optional<vector<Statement>>
|
||||
{
|
||||
if (_s.type() == typeid(VariableDeclaration))
|
||||
{
|
||||
@ -213,7 +213,7 @@ void IntroduceControlFlowSSA::operator()(Block& _block)
|
||||
|
||||
iterateReplacing(
|
||||
_block.statements,
|
||||
[&](Statement& _s) -> boost::optional<vector<Statement>>
|
||||
[&](Statement& _s) -> std::optional<vector<Statement>>
|
||||
{
|
||||
vector<Statement> toPrepend;
|
||||
for (YulString toReassign: m_variablesToReassign)
|
||||
@ -253,7 +253,7 @@ void IntroduceControlFlowSSA::operator()(Block& _block)
|
||||
else
|
||||
{
|
||||
toPrepend.emplace_back(std::move(_s));
|
||||
return toPrepend;
|
||||
return {std::move(toPrepend)};
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -64,7 +64,7 @@ bool SimplificationRules::isInitialized() const
|
||||
return !m_rules[uint8_t(dev::eth::Instruction::ADD)].empty();
|
||||
}
|
||||
|
||||
boost::optional<std::pair<dev::eth::Instruction, vector<Expression> const*>>
|
||||
std::optional<std::pair<dev::eth::Instruction, vector<Expression> const*>>
|
||||
SimplificationRules::instructionAndArguments(Dialect const& _dialect, Expression const& _expr)
|
||||
{
|
||||
if (_expr.type() == typeid(FunctionalInstruction))
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include <libyul/AsmData.h>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace yul
|
||||
@ -57,7 +57,7 @@ public:
|
||||
/// by the constructor, but we had some issues with static initialization.
|
||||
bool isInitialized() const;
|
||||
|
||||
static boost::optional<std::pair<dev::eth::Instruction, std::vector<Expression> const*>>
|
||||
static std::optional<std::pair<dev::eth::Instruction, std::vector<Expression> const*>>
|
||||
instructionAndArguments(Dialect const& _dialect, Expression const& _expr);
|
||||
|
||||
private:
|
||||
|
@ -28,7 +28,7 @@ using namespace std;
|
||||
using namespace dev;
|
||||
using namespace yul;
|
||||
|
||||
using OptionalStatements = boost::optional<vector<Statement>>;
|
||||
using OptionalStatements = std::optional<vector<Statement>>;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -54,7 +54,7 @@ OptionalStatements replaceConstArgSwitch(Switch& _switchStmt, u256 const& _const
|
||||
if (matchingCaseBlock)
|
||||
return make_vector<Statement>(std::move(*matchingCaseBlock));
|
||||
else
|
||||
return {{}};
|
||||
return optional<vector<Statement>>{vector<Statement>{}};
|
||||
}
|
||||
|
||||
}
|
||||
@ -80,8 +80,8 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
|
||||
return {};
|
||||
},
|
||||
[&](Switch& _switchStmt) -> OptionalStatements {
|
||||
if (boost::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
|
||||
return replaceConstArgSwitch(_switchStmt, constExprVal.get());
|
||||
if (std::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
|
||||
return replaceConstArgSwitch(_switchStmt, constExprVal.value());
|
||||
return {};
|
||||
},
|
||||
[&](ForLoop& _forLoop) -> OptionalStatements {
|
||||
@ -107,7 +107,7 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
|
||||
|
||||
bool StructuralSimplifier::expressionAlwaysTrue(Expression const& _expression)
|
||||
{
|
||||
if (boost::optional<u256> value = hasLiteralValue(_expression))
|
||||
if (std::optional<u256> value = hasLiteralValue(_expression))
|
||||
return *value != 0;
|
||||
else
|
||||
return false;
|
||||
@ -115,16 +115,16 @@ bool StructuralSimplifier::expressionAlwaysTrue(Expression const& _expression)
|
||||
|
||||
bool StructuralSimplifier::expressionAlwaysFalse(Expression const& _expression)
|
||||
{
|
||||
if (boost::optional<u256> value = hasLiteralValue(_expression))
|
||||
if (std::optional<u256> value = hasLiteralValue(_expression))
|
||||
return *value == 0;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::optional<dev::u256> StructuralSimplifier::hasLiteralValue(Expression const& _expression) const
|
||||
std::optional<dev::u256> StructuralSimplifier::hasLiteralValue(Expression const& _expression) const
|
||||
{
|
||||
if (_expression.type() == typeid(Literal))
|
||||
return valueOfLiteral(boost::get<Literal>(_expression));
|
||||
else
|
||||
return boost::optional<u256>();
|
||||
return std::optional<u256>();
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ private:
|
||||
void simplify(std::vector<Statement>& _statements);
|
||||
bool expressionAlwaysTrue(Expression const& _expression);
|
||||
bool expressionAlwaysFalse(Expression const& _expression);
|
||||
boost::optional<dev::u256> hasLiteralValue(Expression const& _expression) const;
|
||||
std::optional<dev::u256> hasLiteralValue(Expression const& _expression) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ void VarDeclInitializer::operator()(Block& _block)
|
||||
{
|
||||
ASTModifier::operator()(_block);
|
||||
|
||||
using OptionalStatements = boost::optional<vector<Statement>>;
|
||||
using OptionalStatements = std::optional<vector<Statement>>;
|
||||
GenericFallbackReturnsVisitor<OptionalStatements, VariableDeclaration> visitor{
|
||||
[](VariableDeclaration& _varDecl) -> OptionalStatements
|
||||
{
|
||||
|
@ -884,7 +884,7 @@ bool CommandLineInterface::processInput()
|
||||
if (m_args.count(g_strEVMVersion))
|
||||
{
|
||||
string versionOptionStr = m_args[g_strEVMVersion].as<string>();
|
||||
boost::optional<langutil::EVMVersion> versionOption = langutil::EVMVersion::fromString(versionOptionStr);
|
||||
std::optional<langutil::EVMVersion> versionOption = langutil::EVMVersion::fromString(versionOptionStr);
|
||||
if (!versionOption)
|
||||
{
|
||||
serr() << "Invalid option for --evm-version: " << versionOptionStr << endl;
|
||||
|
@ -150,7 +150,7 @@ private:
|
||||
bytes const& m_metadata;
|
||||
};
|
||||
|
||||
boost::optional<map<string, string>> parseCBORMetadata(bytes const& _metadata)
|
||||
std::optional<map<string, string>> parseCBORMetadata(bytes const& _metadata)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -21,9 +21,8 @@
|
||||
|
||||
#include <libdevcore/CommonData.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace dev
|
||||
@ -48,7 +47,7 @@ std::string bytecodeSansMetadata(std::string const& _bytecode);
|
||||
/// - bytes into hex strings
|
||||
/// - booleans into "true"/"false" strings
|
||||
/// - everything else is invalid
|
||||
boost::optional<std::map<std::string, std::string>> parseCBORMetadata(bytes const& _metadata);
|
||||
std::optional<std::map<std::string, std::string>> parseCBORMetadata(bytes const& _metadata);
|
||||
|
||||
/// Expects a serialised metadata JSON and returns true if the
|
||||
/// content is valid metadata.
|
||||
|
@ -184,7 +184,7 @@ bool EVMVersionRestrictedTestCase::validateSettings(langutil::EVMVersion _evmVer
|
||||
break;
|
||||
|
||||
versionString = versionString.substr(versionBegin);
|
||||
boost::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(versionString);
|
||||
std::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(versionString);
|
||||
if (!version)
|
||||
throw runtime_error("Invalid EVM version: \"" + versionString + "\"");
|
||||
|
||||
|
@ -34,7 +34,7 @@ BOOST_AUTO_TEST_SUITE(IterateReplacing)
|
||||
BOOST_AUTO_TEST_CASE(no_replacement)
|
||||
{
|
||||
vector<string> v{"abc", "def", "ghi"};
|
||||
function<boost::optional<vector<string>>(string&)> f = [](string&) -> boost::optional<vector<string>> { return {}; };
|
||||
function<std::optional<vector<string>>(string&)> f = [](string&) -> std::optional<vector<string>> { return {}; };
|
||||
iterateReplacing(v, f);
|
||||
vector<string> expectation{"abc", "def", "ghi"};
|
||||
BOOST_CHECK(v == expectation);
|
||||
@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(no_replacement)
|
||||
BOOST_AUTO_TEST_CASE(empty_input)
|
||||
{
|
||||
vector<string> v;
|
||||
function<boost::optional<vector<string>>(string&)> f = [](string&) -> boost::optional<vector<string>> { return {}; };
|
||||
function<std::optional<vector<string>>(string&)> f = [](string&) -> std::optional<vector<string>> { return {}; };
|
||||
iterateReplacing(v, f);
|
||||
vector<string> expectation;
|
||||
BOOST_CHECK(v == expectation);
|
||||
@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(empty_input)
|
||||
BOOST_AUTO_TEST_CASE(delete_some)
|
||||
{
|
||||
vector<string> v{"abc", "def", "ghi"};
|
||||
function<boost::optional<vector<string>>(string&)> f = [](string& _s) -> boost::optional<vector<string>> {
|
||||
function<std::optional<vector<string>>(string&)> f = [](string& _s) -> std::optional<vector<string>> {
|
||||
if (_s == "def")
|
||||
return vector<string>();
|
||||
else
|
||||
@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(delete_some)
|
||||
BOOST_AUTO_TEST_CASE(inject_some_start)
|
||||
{
|
||||
vector<string> v{"abc", "def", "ghi"};
|
||||
function<boost::optional<vector<string>>(string&)> f = [](string& _s) -> boost::optional<vector<string>> {
|
||||
function<std::optional<vector<string>>(string&)> f = [](string& _s) -> std::optional<vector<string>> {
|
||||
if (_s == "abc")
|
||||
return vector<string>{"x", "y"};
|
||||
else
|
||||
@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE(inject_some_start)
|
||||
BOOST_AUTO_TEST_CASE(inject_some_end)
|
||||
{
|
||||
vector<string> v{"abc", "def", "ghi"};
|
||||
function<boost::optional<vector<string>>(string&)> f = [](string& _s) -> boost::optional<vector<string>> {
|
||||
function<std::optional<vector<string>>(string&)> f = [](string& _s) -> std::optional<vector<string>> {
|
||||
if (_s == "ghi")
|
||||
return vector<string>{"x", "y"};
|
||||
else
|
||||
|
@ -34,11 +34,11 @@
|
||||
|
||||
#include <libevmasm/Assembly.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
@ -54,7 +54,7 @@ namespace test
|
||||
namespace
|
||||
{
|
||||
|
||||
boost::optional<Error> parseAndReturnFirstError(
|
||||
std::optional<Error> parseAndReturnFirstError(
|
||||
string const& _source,
|
||||
bool _assemble = false,
|
||||
bool _allowWarnings = true,
|
||||
|
@ -42,7 +42,7 @@ map<string, string> requireParsedCBORMetadata(bytes const& _bytecode)
|
||||
{
|
||||
bytes cborMetadata = dev::test::onlyMetadata(_bytecode);
|
||||
BOOST_REQUIRE(!cborMetadata.empty());
|
||||
boost::optional<map<string, string>> tmp = dev::test::parseCBORMetadata(cborMetadata);
|
||||
std::optional<map<string, string>> tmp = dev::test::parseCBORMetadata(cborMetadata);
|
||||
BOOST_REQUIRE(tmp);
|
||||
return *tmp;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
|
||||
/// @returns the number of instructions in the given bytecode, not taking the metadata hash
|
||||
/// into account.
|
||||
size_t numInstructions(bytes const& _bytecode, boost::optional<Instruction> _which = boost::optional<Instruction>{})
|
||||
size_t numInstructions(bytes const& _bytecode, std::optional<Instruction> _which = std::optional<Instruction>{})
|
||||
{
|
||||
bytes realCode = bytecodeSansMetadata(_bytecode);
|
||||
BOOST_REQUIRE_MESSAGE(!realCode.empty(), "Invalid or missing metadata in bytecode.");
|
||||
|
@ -141,14 +141,14 @@ string functionSignatureFromABI(Json::Value const& _functionABI)
|
||||
|
||||
}
|
||||
|
||||
boost::optional<dev::solidity::test::ParameterList> ContractABIUtils::parametersFromJsonOutputs(
|
||||
std::optional<dev::solidity::test::ParameterList> ContractABIUtils::parametersFromJsonOutputs(
|
||||
ErrorReporter& _errorReporter,
|
||||
Json::Value const& _contractABI,
|
||||
string const& _functionSignature
|
||||
)
|
||||
{
|
||||
if (!_contractABI)
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
|
||||
for (auto const& function: _contractABI)
|
||||
if (_functionSignature == functionSignatureFromABI(function))
|
||||
@ -177,17 +177,17 @@ boost::optional<dev::solidity::test::ParameterList> ContractABIUtils::parameters
|
||||
"Could not convert \"" + type +
|
||||
"\" to internal ABI type representation. Falling back to default encoding."
|
||||
);
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
finalParams += inplaceTypeParams;
|
||||
|
||||
inplaceTypeParams.clear();
|
||||
}
|
||||
return boost::optional<ParameterList>(finalParams + dynamicTypeParams);
|
||||
return std::optional<ParameterList>(finalParams + dynamicTypeParams);
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool ContractABIUtils::appendTypesFromName(
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
/// a list of internal type representations of isoltest.
|
||||
/// Creates parameters from Contract ABI and is used to generate values for
|
||||
/// auto-correction during interactive update routine.
|
||||
static boost::optional<ParameterList> parametersFromJsonOutputs(
|
||||
static std::optional<ParameterList> parametersFromJsonOutputs(
|
||||
ErrorReporter& _errorReporter,
|
||||
Json::Value const& _contractABI,
|
||||
std::string const& _functionSignature
|
||||
|
@ -24,11 +24,11 @@
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace dev;
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include <libdevcore/AnsiColorized.h>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/optional/optional.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
@ -124,12 +124,12 @@ string TestFunctionCall::format(
|
||||
|
||||
if (!matchesExpectation())
|
||||
{
|
||||
boost::optional<ParameterList> abiParams;
|
||||
std::optional<ParameterList> abiParams;
|
||||
|
||||
if (isFailure)
|
||||
{
|
||||
if (!output.empty())
|
||||
abiParams = boost::make_optional(ContractABIUtils::failureParameters(output));
|
||||
abiParams = ContractABIUtils::failureParameters(output);
|
||||
}
|
||||
else
|
||||
abiParams = ContractABIUtils::parametersFromJsonOutputs(
|
||||
@ -139,7 +139,7 @@ string TestFunctionCall::format(
|
||||
);
|
||||
|
||||
string bytesOutput = abiParams ?
|
||||
BytesUtils::formatRawBytes(output, abiParams.get(), _linePrefix) :
|
||||
BytesUtils::formatRawBytes(output, abiParams.value(), _linePrefix) :
|
||||
BytesUtils::formatRawBytes(
|
||||
output,
|
||||
ContractABIUtils::defaultParameters(ceil(output.size() / 32)),
|
||||
@ -208,7 +208,7 @@ string TestFunctionCall::formatBytesParameters(
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::optional<ParameterList> abiParams = ContractABIUtils::parametersFromJsonOutputs(
|
||||
std::optional<ParameterList> abiParams = ContractABIUtils::parametersFromJsonOutputs(
|
||||
_errorReporter,
|
||||
m_contractABI,
|
||||
_signature
|
||||
@ -216,17 +216,17 @@ string TestFunctionCall::formatBytesParameters(
|
||||
|
||||
if (abiParams)
|
||||
{
|
||||
boost::optional<ParameterList> preferredParams = ContractABIUtils::preferredParameters(
|
||||
std::optional<ParameterList> preferredParams = ContractABIUtils::preferredParameters(
|
||||
_errorReporter,
|
||||
_parameters,
|
||||
abiParams.get(),
|
||||
abiParams.value(),
|
||||
_bytes
|
||||
);
|
||||
|
||||
if (preferredParams)
|
||||
{
|
||||
ContractABIUtils::overwriteParameters(_errorReporter, preferredParams.get(), abiParams.get());
|
||||
os << BytesUtils::formatBytesRange(_bytes, preferredParams.get(), _highlight);
|
||||
ContractABIUtils::overwriteParameters(_errorReporter, preferredParams.value(), abiParams.value());
|
||||
os << BytesUtils::formatBytesRange(_bytes, preferredParams.value(), _highlight);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -27,11 +27,11 @@
|
||||
|
||||
#include <libsolidity/interface/OptimiserSettings.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
@ -63,7 +63,7 @@ std::pair<bool, ErrorList> parse(string const& _source)
|
||||
return {false, {}};
|
||||
}
|
||||
|
||||
boost::optional<Error> parseAndReturnFirstError(string const& _source, bool _allowWarnings = true)
|
||||
std::optional<Error> parseAndReturnFirstError(string const& _source, bool _allowWarnings = true)
|
||||
{
|
||||
bool success;
|
||||
ErrorList errors;
|
||||
|
@ -31,11 +31,11 @@
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
@ -72,7 +72,7 @@ bool parse(string const& _source, Dialect const& _dialect, ErrorReporter& errorR
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::optional<Error> parseAndReturnFirstError(string const& _source, Dialect const& _dialect, bool _allowWarnings = true)
|
||||
std::optional<Error> parseAndReturnFirstError(string const& _source, Dialect const& _dialect, bool _allowWarnings = true)
|
||||
{
|
||||
ErrorList errors;
|
||||
ErrorReporter errorReporter(errors);
|
||||
|
@ -350,7 +350,7 @@ void setupTerminal()
|
||||
#endif
|
||||
}
|
||||
|
||||
boost::optional<TestStats> runTestSuite(
|
||||
std::optional<TestStats> runTestSuite(
|
||||
TestCreator _testCaseCreator,
|
||||
TestOptions const& _options,
|
||||
fs::path const& _basePath,
|
||||
@ -364,7 +364,7 @@ boost::optional<TestStats> runTestSuite(
|
||||
if (!fs::exists(testPath) || !fs::is_directory(testPath))
|
||||
{
|
||||
cerr << _name << " tests not found. Use the --testpath argument." << endl;
|
||||
return {};
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
TestStats stats = TestTool::processPath(
|
||||
|
@ -31,6 +31,18 @@ void yulFuzzerUtil::interpret(
|
||||
InterpreterState state;
|
||||
state.maxTraceSize = _maxTraceSize;
|
||||
state.maxSteps = _maxSteps;
|
||||
// Add 64 bytes of pseudo-randomly generated calldata so that
|
||||
// calldata opcodes perform non trivial work.
|
||||
state.calldata = {
|
||||
0xe9, 0x96, 0x40, 0x7d, 0xa5, 0xda, 0xb0, 0x2d,
|
||||
0x97, 0xf5, 0xc3, 0x44, 0xd7, 0x65, 0x0a, 0xd8,
|
||||
0x2c, 0x14, 0x3a, 0xf3, 0xe7, 0x40, 0x0f, 0x1e,
|
||||
0x67, 0xce, 0x90, 0x44, 0x2e, 0x92, 0xdb, 0x88,
|
||||
0xb8, 0x43, 0x9c, 0x41, 0x42, 0x08, 0xf1, 0xd7,
|
||||
0x65, 0xe9, 0x7f, 0xeb, 0x7b, 0xb9, 0x56, 0x9f,
|
||||
0xc7, 0x60, 0x5f, 0x7c, 0xcd, 0xfb, 0x92, 0xcd,
|
||||
0x8e, 0xf3, 0x9b, 0xe4, 0x4f, 0x6c, 0x14, 0xde
|
||||
};
|
||||
Interpreter interpreter(state, _dialect);
|
||||
interpreter(*_ast);
|
||||
state.dumpTraceAndState(_os);
|
||||
|
Loading…
Reference in New Issue
Block a user