Updates after code review

This commit is contained in:
wechman 2022-09-21 09:58:12 +02:00
parent 23bea46d04
commit 9ce1ded86f
5 changed files with 14 additions and 9 deletions

View File

@ -312,7 +312,7 @@ errorDefinition:
Semicolon;
/**
* User type operators.
* Customizable operators of user-defined types.
*/
userOp: Add | Sub | Mul | Div | Mod | BitAnd | BitOr | BitXor | BitNot | Equal | NotEqual | LessThan | GreaterThan | LessThanOrEqual | GreaterThanOrEqual | Shl | Sar | Exp | Not;
@ -320,7 +320,7 @@ userOp: Add | Sub | Mul | Div | Mod | BitAnd | BitOr | BitXor | BitNot | Equal |
* Using directive to bind library functions and free functions to types.
* Can occur within contracts and libraries and at the file level.
*/
usingDirective: Using (identifierPath (As userOp)? | (LBrace identifierPath (As userOp)? (Comma identifierPath (As userOp)?)* RBrace)) For (Mul | typeName) Global? Semicolon;
usingDirective: Using (identifierPath | (LBrace identifierPath (As userOp)? (Comma identifierPath (As userOp)?)* RBrace)) For (Mul | typeName) Global? Semicolon;
/**
* A type name can be an elementary type, a function type, a mapping type, a user-defined type
* (e.g. a contract or struct) or an array type.

View File

@ -81,6 +81,7 @@ bool ControlFlowBuilder::visit(BinaryOperation const& _operation)
_operation.leftExpression().accept(*this);
_operation.rightExpression().accept(*this);
solAssert(*_operation.annotation().userDefinedFunction);
m_currentNode->functionDefinition = *_operation.annotation().userDefinedFunction;
auto nextNode = newLabel();
@ -102,13 +103,15 @@ bool ControlFlowBuilder::visit(UnaryOperation const& _operation)
if (_operation.annotation().userDefinedFunction.set())
{
visitNode(_operation);
_operation.subExpression().accept(*this);
solAssert(*_operation.annotation().userDefinedFunction);
m_currentNode->functionDefinition = *_operation.annotation().userDefinedFunction;
auto nextNode = newLabel();
connect(m_currentNode, nextNode);
m_currentNode = nextNode;
return true;
return false;
}
return ASTConstVisitor::visit(_operation);

View File

@ -19,15 +19,11 @@
#include <libsolidity/analysis/ControlFlowGraph.h>
#include <libsolidity/analysis/ControlFlowBuilder.h>
#include <libsolutil/Visitor.h>
using namespace std;
using namespace solidity::util;
using namespace solidity::langutil;
using namespace solidity::frontend;
bool CFG::constructFlow(ASTNode const& _astRoot)
{
_astRoot.accept(*this);

View File

@ -98,8 +98,8 @@ struct CFGNode
std::vector<CFGNode*> entries;
/// Exit nodes. All CFG nodes to which control flow may continue after this node.
std::vector<CFGNode*> exits;
/// Function call done by this node
FunctionDefinition const* functionDefinition;
/// Resolved definition of the function called by this node
FunctionDefinition const* functionDefinition = nullptr;
/// Variable occurrences in the node.
std::vector<VariableOccurrence> variableOccurrences;
// Source location of this control flow block.

View File

@ -207,14 +207,20 @@ bool FunctionCallGraphBuilder::visit(MemberAccess const& _memberAccess)
bool FunctionCallGraphBuilder::visit(BinaryOperation const& _binaryOperation)
{
if (_binaryOperation.annotation().userDefinedFunction.set())
{
solAssert(*_binaryOperation.annotation().userDefinedFunction);
functionReferenced(**_binaryOperation.annotation().userDefinedFunction, true /* called directly */);
}
return true;
}
bool FunctionCallGraphBuilder::visit(UnaryOperation const& _unaryOperation)
{
if (_unaryOperation.annotation().userDefinedFunction.set())
{
solAssert(*_unaryOperation.annotation().userDefinedFunction);
functionReferenced(**_unaryOperation.annotation().userDefinedFunction, true /* called directly */);
}
return true;
}