From 66a8c7d1ab5b744736d1355ba46c9e1d5f090ac8 Mon Sep 17 00:00:00 2001 From: a3d4 Date: Thu, 21 May 2020 00:04:26 +0200 Subject: [PATCH] Remove ReferencesResolver class-specific error reporting functions --- libsolidity/analysis/ReferencesResolver.cpp | 30 ++++++--------------- libsolidity/analysis/ReferencesResolver.h | 9 ------- 2 files changed, 8 insertions(+), 31 deletions(-) diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index ac3553f6b..073c0795a 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -119,7 +119,7 @@ bool ReferencesResolver::visit(Identifier const& _identifier) else errorMessage += " Did you mean " + std::move(suggestions) + "?"; } - declarationError(_identifier.location(), errorMessage); + m_errorReporter.declarationError(8051_error, _identifier.location(), errorMessage); } else if (declarations.size() == 1) _identifier.annotation().referencedDeclaration = declarations.front(); @@ -157,7 +157,7 @@ void ReferencesResolver::endVisit(UserDefinedTypeName const& _typeName) Declaration const* declaration = m_resolver.pathFromCurrentScope(_typeName.namePath()); if (!declaration) { - fatalDeclarationError(_typeName.location(), "Identifier not found or not unique."); + m_errorReporter.fatalDeclarationError(7556_error, _typeName.location(), "Identifier not found or not unique."); return; } @@ -209,14 +209,14 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) )); if (realName.empty()) { - declarationError(_identifier.location, "In variable names _slot and _offset can only be used as a suffix."); + m_errorReporter.declarationError(9553_error, _identifier.location, "In variable names _slot and _offset can only be used as a suffix."); return; } declarations = m_resolver.nameFromCurrentScope(realName); } if (declarations.size() > 1) { - declarationError(_identifier.location, "Multiple matching identifiers. Resolving overloaded identifiers is not supported."); + m_errorReporter.declarationError(8827_error, _identifier.location, "Multiple matching identifiers. Resolving overloaded identifiers is not supported."); return; } else if (declarations.size() == 0) @@ -224,7 +224,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) if (auto var = dynamic_cast(declarations.front())) if (var->isLocalVariable() && m_yulInsideFunction) { - declarationError(_identifier.location, "Cannot access local Solidity variables from inside an inline assembly function."); + m_errorReporter.declarationError(8477_error, _identifier.location, "Cannot access local Solidity variables from inside an inline assembly function."); return; } @@ -242,7 +242,7 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) string namePrefix = identifier.name.str().substr(0, identifier.name.str().find('.')); if (isSlot || isOffset) - declarationError(identifier.location, "In variable declarations _slot and _offset can not be used as a suffix."); + m_errorReporter.declarationError(8820_error, identifier.location, "In variable declarations _slot and _offset can not be used as a suffix."); else if ( auto declarations = m_resolver.nameFromCurrentScope(namePrefix); !declarations.empty() @@ -252,7 +252,8 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) for (auto const* decl: declarations) ssl.append("The shadowed declaration is here:", decl->location()); if (!ssl.infos.empty()) - declarationError( + m_errorReporter.declarationError( + 6005_error, identifier.location, ssl, namePrefix.size() < identifier.name.str().size() ? @@ -266,19 +267,4 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl) visit(*_varDecl.value); } -void ReferencesResolver::declarationError(SourceLocation const& _location, string const& _description) -{ - m_errorReporter.declarationError(8532_error, _location, _description); -} - -void ReferencesResolver::declarationError(SourceLocation const& _location, SecondarySourceLocation const& _ssl, string const& _description) -{ - m_errorReporter.declarationError(3881_error, _location, _ssl, _description); -} - -void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location, string const& _description) -{ - m_errorReporter.fatalDeclarationError(6546_error, _location, _description); -} - } diff --git a/libsolidity/analysis/ReferencesResolver.h b/libsolidity/analysis/ReferencesResolver.h index 7b8c1fff5..7da745cc5 100644 --- a/libsolidity/analysis/ReferencesResolver.h +++ b/libsolidity/analysis/ReferencesResolver.h @@ -88,15 +88,6 @@ private: void operator()(yul::Identifier const& _identifier) override; void operator()(yul::VariableDeclaration const& _varDecl) override; - /// Adds a new error to the list of errors. - void declarationError(langutil::SourceLocation const& _location, std::string const& _description); - - /// Adds a new error to the list of errors. - void declarationError(langutil::SourceLocation const& _location, langutil::SecondarySourceLocation const& _ssl, std::string const& _description); - - /// Adds a new error to the list of errors and throws to abort reference resolving. - void fatalDeclarationError(langutil::SourceLocation const& _location, std::string const& _description); - langutil::ErrorReporter& m_errorReporter; NameAndTypeResolver& m_resolver; langutil::EVMVersion m_evmVersion;