mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
ViewPureChecker: Extract reportFunctionCallMutability() helper from endVisit(FunctionCall)
This commit is contained in:
parent
27df07c4ce
commit
edb4bfa398
@ -323,16 +323,23 @@ ViewPureChecker::MutabilityAndLocation const& ViewPureChecker::modifierMutabilit
|
||||
return m_inferredMutability.at(&_modifier);
|
||||
}
|
||||
|
||||
void ViewPureChecker::reportFunctionCallMutability(StateMutability _mutability, langutil::SourceLocation const& _location)
|
||||
{
|
||||
// We only require "nonpayable" to call a payable function.
|
||||
if (_mutability == StateMutability::Payable)
|
||||
_mutability = StateMutability::NonPayable;
|
||||
reportMutability(_mutability, _location);
|
||||
}
|
||||
|
||||
void ViewPureChecker::endVisit(FunctionCall const& _functionCall)
|
||||
{
|
||||
if (*_functionCall.annotation().kind != FunctionCallKind::FunctionCall)
|
||||
return;
|
||||
|
||||
StateMutability mutability = dynamic_cast<FunctionType const&>(*_functionCall.expression().annotation().type).stateMutability();
|
||||
// We only require "nonpayable" to call a payble function.
|
||||
if (mutability == StateMutability::Payable)
|
||||
mutability = StateMutability::NonPayable;
|
||||
reportMutability(mutability, _functionCall.location());
|
||||
reportFunctionCallMutability(
|
||||
dynamic_cast<FunctionType const&>(*_functionCall.expression().annotation().type).stateMutability(),
|
||||
_functionCall.location()
|
||||
);
|
||||
}
|
||||
|
||||
bool ViewPureChecker::visit(MemberAccess const& _memberAccess)
|
||||
|
@ -73,6 +73,8 @@ private:
|
||||
std::optional<langutil::SourceLocation> const& _nestedLocation = {}
|
||||
);
|
||||
|
||||
void reportFunctionCallMutability(StateMutability _mutability, langutil::SourceLocation const& _location);
|
||||
|
||||
/// Determines the mutability of modifier if not already cached.
|
||||
MutabilityAndLocation const& modifierMutability(ModifierDefinition const& _modifier);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user