Merge remote-tracking branch 'origin/develop' into breaking

This commit is contained in:
chriseth
2020-06-15 17:11:41 +02:00
132 changed files with 1083 additions and 417 deletions
+16 -13
View File
@@ -68,7 +68,7 @@ struct OverrideGraph
std::map<OverrideProxy, int> nodes;
std::map<int, OverrideProxy> nodeInv;
std::map<int, std::set<int>> edges;
int numNodes = 2;
size_t numNodes = 2;
void addEdge(int _a, int _b)
{
edges[_a].insert(_b);
@@ -82,7 +82,7 @@ private:
auto it = nodes.find(_function);
if (it != nodes.end())
return it->second;
int currentNode = numNodes++;
int currentNode = static_cast<int>(numNodes++);
nodes[_function] = currentNode;
nodeInv[currentNode] = _function;
if (_function.overrides())
@@ -116,21 +116,24 @@ private:
std::vector<int> m_parent = std::vector<int>(m_graph.numNodes, -1);
std::set<OverrideProxy> m_cutVertices{};
void run(int _u = 0, int _depth = 0)
void run(size_t _u = 0, size_t _depth = 0)
{
m_visited.at(_u) = true;
m_depths.at(_u) = m_low.at(_u) = _depth;
for (int v: m_graph.edges.at(_u))
if (!m_visited.at(v))
m_depths.at(_u) = m_low.at(_u) = static_cast<int>(_depth);
for (int const v: m_graph.edges.at(static_cast<int>(_u)))
{
auto const vInd = static_cast<size_t>(v);
if (!m_visited.at(vInd))
{
m_parent[v] = _u;
run(v, _depth + 1);
if (m_low[v] >= m_depths[_u] && m_parent[_u] != -1)
m_cutVertices.insert(m_graph.nodeInv.at(_u));
m_low[_u] = min(m_low[_u], m_low[v]);
m_parent[vInd] = static_cast<int>(_u);
run(vInd, _depth + 1);
if (m_low[vInd] >= m_depths[_u] && m_parent[_u] != -1)
m_cutVertices.insert(m_graph.nodeInv.at(static_cast<int>(_u)));
m_low[_u] = min(m_low[_u], m_low[vInd]);
}
else if (v != m_parent[_u])
m_low[_u] = min(m_low[_u], m_depths[v]);
m_low[_u] = min(m_low[_u], m_depths[vInd]);
}
}
};
@@ -213,7 +216,7 @@ bool OverrideProxy::CompareBySignature::operator()(OverrideProxy const& _a, Over
size_t OverrideProxy::id() const
{
return std::visit(GenericVisitor{
[&](auto const* _item) -> size_t { return _item->id(); }
[&](auto const* _item) -> size_t { return static_cast<size_t>(_item->id()); }
}, m_item);
}
+17 -17
View File
@@ -668,7 +668,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
{
auto ref = _inlineAssembly.annotation().externalReferences.find(&_identifier);
if (ref == _inlineAssembly.annotation().externalReferences.end())
return size_t(-1);
return numeric_limits<size_t>::max();
Declaration const* declaration = ref->second.declaration;
solAssert(!!declaration, "");
bool requiresStorage = ref->second.isSlot || ref->second.isOffset;
@@ -678,7 +678,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (var->immutable())
{
m_errorReporter.typeError(3773_error, _identifier.location, "Assembly access to immutable variables is not supported.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
if (var->isConstant())
{
@@ -687,17 +687,17 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (var && !var->value())
{
m_errorReporter.typeError(3224_error, _identifier.location, "Constant has no value.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (_context == yul::IdentifierContext::LValue)
{
m_errorReporter.typeError(6252_error, _identifier.location, "Constant variables cannot be assigned to.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (requiresStorage)
{
m_errorReporter.typeError(6617_error, _identifier.location, "The suffixes _offset and _slot can only be used on non-constant storage variables.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (var && var->value() && !var->value()->annotation().type && !dynamic_cast<Literal const*>(var->value().get()))
{
@@ -725,19 +725,19 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (!var->isStateVariable() && !var->type()->dataStoredIn(DataLocation::Storage))
{
m_errorReporter.typeError(3622_error, _identifier.location, "The suffixes _offset and _slot can only be used on storage variables.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (_context == yul::IdentifierContext::LValue)
{
if (var->isStateVariable())
{
m_errorReporter.typeError(4713_error, _identifier.location, "State variables cannot be assigned to - you have to use \"sstore()\".");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (ref->second.isOffset)
{
m_errorReporter.typeError(9739_error, _identifier.location, "Only _slot can be assigned to.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else
solAssert(ref->second.isSlot, "");
@@ -746,12 +746,12 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
else if (!var->isConstant() && var->isStateVariable())
{
m_errorReporter.typeError(1408_error, _identifier.location, "Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (var->type()->dataStoredIn(DataLocation::Storage))
{
m_errorReporter.typeError(9068_error, _identifier.location, "You have to use the _slot or _offset suffix to access storage reference variables.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (var->type()->sizeOnStack() != 1)
{
@@ -759,21 +759,21 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
m_errorReporter.typeError(2370_error, _identifier.location, "Call data elements cannot be accessed directly. Copy to a local variable first or use \"calldataload\" or \"calldatacopy\" with manually determined offsets and sizes.");
else
m_errorReporter.typeError(9857_error, _identifier.location, "Only types that use one stack slot are supported.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
}
else if (requiresStorage)
{
m_errorReporter.typeError(7944_error, _identifier.location, "The suffixes _offset and _slot can only be used on storage variables.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (_context == yul::IdentifierContext::LValue)
{
if (dynamic_cast<MagicVariableDeclaration const*>(declaration))
return size_t(-1);
return numeric_limits<size_t>::max();
m_errorReporter.typeError(1990_error, _identifier.location, "Only local variables can be assigned to in inline assembly.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
if (_context == yul::IdentifierContext::RValue)
@@ -782,7 +782,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (dynamic_cast<FunctionDefinition const*>(declaration))
{
m_errorReporter.declarationError(2025_error, _identifier.location, "Access to functions is not allowed in inline assembly.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
else if (dynamic_cast<VariableDeclaration const*>(declaration))
{
@@ -792,11 +792,11 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
if (!contract->isLibrary())
{
m_errorReporter.typeError(4977_error, _identifier.location, "Expected a library.");
return size_t(-1);
return numeric_limits<size_t>::max();
}
}
else
return size_t(-1);
return numeric_limits<size_t>::max();
}
ref->second.valueSize = 1;
return size_t(1);