Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libdevcore/CommonData.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include <libdevcore/Common.h>

#include <boost/optional.hpp>
#include <optional>

#include <vector>
#include <type_traits>
Expand Down Expand Up @@ -277,7 +277,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)
{
Expand Down Expand Up @@ -305,7 +305,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)
{
Expand Down
4 changes: 2 additions & 2 deletions liblangutil/EVMVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <string>

#include <boost/optional.hpp>
#include <optional>
#include <boost/operators.hpp>


Expand All @@ -51,7 +51,7 @@ class EVMVersion:
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())
Expand Down
6 changes: 3 additions & 3 deletions liblangutil/Scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <liblangutil/Common.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/Scanner.h>
#include <boost/optional.hpp>
#include <optional>
#include <algorithm>
#include <ostream>
#include <tuple>
Expand Down Expand Up @@ -187,7 +187,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++)
Expand Down Expand Up @@ -694,7 +694,7 @@ bool Scanner::scanEscape()
break;
case 'u':
{
if (boost::optional<unsigned> codepoint = scanUnicode())
if (std::optional<unsigned> codepoint = scanUnicode())
addUnicodeAsUTF8(*codepoint);
else
return false;
Expand Down
2 changes: 1 addition & 1 deletion liblangutil/Scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class Scanner
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();
Expand Down
4 changes: 2 additions & 2 deletions libsolidity/analysis/ReferencesResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
Expand Down Expand Up @@ -323,7 +323,7 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly)
// Will be re-generated later with correct information
// We use the latest EVM version because we will re-run it anyway.
yul::AsmAnalysisInfo analysisInfo;
boost::optional<Error::Type> errorTypeForLoose = Error::Type::SyntaxError;
std::optional<Error::Type> errorTypeForLoose = Error::Type::SyntaxError;
yul::AsmAnalyzer(
analysisInfo,
errorsIgnored,
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/analysis/ViewPureChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,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)
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/analysis/ViewPureChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ViewPureChecker: private ASTConstVisitor
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;
Expand Down
8 changes: 4 additions & 4 deletions libsolidity/ast/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -903,22 +903,22 @@ class ElementaryTypeName: public TypeName
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;
void accept(ASTConstVisitor& _visitor) const override;

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
};

/**
Expand Down
4 changes: 2 additions & 2 deletions libsolidity/ast/ASTAnnotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <libsolidity/ast/ASTEnums.h>
#include <libsolidity/ast/ExperimentalFeatures.h>

#include <boost/optional.hpp>
#include <optional>

#include <map>
#include <memory>
Expand Down Expand Up @@ -183,7 +183,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
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/ast/ASTJsonConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,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)
{
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/ast/ASTJsonConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class ASTJsonConverter: public ASTConstVisitor
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
Expand Down
14 changes: 7 additions & 7 deletions libsolidity/ast/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1812,10 +1812,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{}};
Expand Down Expand Up @@ -2104,10 +2104,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{}};
Expand Down Expand Up @@ -2164,7 +2164,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.";

Expand All @@ -2177,13 +2177,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;
Expand Down
18 changes: 9 additions & 9 deletions libsolidity/ast/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <libdevcore/CommonIO.h>
#include <libdevcore/Result.h>

#include <boost/optional.hpp>
#include <optional>
#include <boost/rational.hpp>

#include <map>
Expand Down Expand Up @@ -769,8 +769,8 @@ class ArrayType: public ReferenceType
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;
};

/**
Expand Down Expand Up @@ -865,12 +865,12 @@ class StructType: public ReferenceType

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;
Expand Down Expand Up @@ -898,9 +898,9 @@ class StructType: public ReferenceType
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;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/codegen/CompilerContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void CompilerContext::appendInlineAssembly(
analyzerResult = yul::AsmAnalyzer(
analysisInfo,
errorReporter,
boost::none,
std::nullopt,
dialect,
identifierAccess.resolve
).analyze(*parserResult);
Expand Down
8 changes: 4 additions & 4 deletions libsolidity/codegen/YulUtilFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,11 +962,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, [&] {
Expand All @@ -983,11 +983,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();
}
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/codegen/YulUtilFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class YulUtilFunctions
/// 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.
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/codegen/ir/IRLValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/interface/CompilerStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion libsolidity/interface/CompilerStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class CompilerStack: boost::noncopyable
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.
Expand Down
Loading