diff options
author | chriseth <chris@ethereum.org> | 2017-05-30 22:45:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-30 22:45:36 +0800 |
commit | 254b55728f66ea164e9085700a294ac4837f2029 (patch) | |
tree | a4c464d4d40baaa260f071c1028f347bd287e44d /libsolidity/analysis/StaticAnalyzer.cpp | |
parent | 0066a08aa8f6c469cde7947ec50ca662a32123a0 (diff) | |
parent | 89b60ffbd4c2dde26fa5e9f1d750729b5c89373e (diff) | |
download | dexon-solidity-254b55728f66ea164e9085700a294ac4837f2029.tar.gz dexon-solidity-254b55728f66ea164e9085700a294ac4837f2029.tar.zst dexon-solidity-254b55728f66ea164e9085700a294ac4837f2029.zip |
Merge pull request #2264 from roadriverrail/refactor_error_log
Refactor error reporting
Diffstat (limited to 'libsolidity/analysis/StaticAnalyzer.cpp')
-rw-r--r-- | libsolidity/analysis/StaticAnalyzer.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index cfc863e0..375e9bde 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -22,6 +22,7 @@ #include <libsolidity/analysis/StaticAnalyzer.h> #include <libsolidity/ast/AST.h> +#include <libsolidity/interface/ErrorReporter.h> #include <memory> using namespace std; @@ -31,7 +32,7 @@ using namespace dev::solidity; bool StaticAnalyzer::analyze(SourceUnit const& _sourceUnit) { _sourceUnit.accept(*this); - return Error::containsOnlyWarnings(m_errors); + return Error::containsOnlyWarnings(m_errorReporter.errors()); } bool StaticAnalyzer::visit(ContractDefinition const& _contract) @@ -62,7 +63,7 @@ void StaticAnalyzer::endVisit(FunctionDefinition const&) m_nonPayablePublic = false; for (auto const& var: m_localVarUseCount) if (var.second == 0) - warning(var.first->location(), "Unused local variable"); + m_errorReporter.warning(var.first->location(), "Unused local variable"); m_localVarUseCount.clear(); } @@ -104,7 +105,11 @@ bool StaticAnalyzer::visit(Return const& _return) bool StaticAnalyzer::visit(ExpressionStatement const& _statement) { if (_statement.expression().annotation().isPure) - warning(_statement.location(), "Statement has no effect."); + m_errorReporter.warning( + _statement.location(), + "Statement has no effect." + ); + return true; } @@ -113,21 +118,14 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess) if (m_nonPayablePublic && !m_library) if (MagicType const* type = dynamic_cast<MagicType const*>(_memberAccess.expression().annotation().type.get())) if (type->kind() == MagicType::Kind::Message && _memberAccess.memberName() == "value") - warning(_memberAccess.location(), "\"msg.value\" used in non-payable function. Do you want to add the \"payable\" modifier to this function?"); + m_errorReporter.warning( + _memberAccess.location(), + "\"msg.value\" used in non-payable function. Do you want to add the \"payable\" modifier to this function?" + ); return true; } -void StaticAnalyzer::warning(SourceLocation const& _location, string const& _description) -{ - auto err = make_shared<Error>(Error::Type::Warning); - *err << - errinfo_sourceLocation(_location) << - errinfo_comment(_description); - - m_errors.push_back(err); -} - bool StaticAnalyzer::visit(InlineAssembly const& _inlineAssembly) { if (!m_currentFunction) @@ -145,4 +143,3 @@ bool StaticAnalyzer::visit(InlineAssembly const& _inlineAssembly) return true; } - |