Merge pull request #8921 from a3d4/partfix-5819-remove-erroroccurred-flag-continued

Remove a dedicated error flag from DeclarationTypeChecker and other classes, continued
This commit is contained in:
chriseth 2020-05-20 13:23:37 +02:00 committed by GitHub
commit 678a801daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 19 deletions

View File

@ -34,10 +34,9 @@ using namespace solidity::frontend;
bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit) bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit)
{ {
m_errorOccured = false; auto errorWatcher = m_errorReporter.errorWatcher();
_sourceUnit.accept(*this); _sourceUnit.accept(*this);
return errorWatcher.ok();
return !m_errorOccured;
} }
bool DocStringAnalyser::visit(ContractDefinition const& _contract) bool DocStringAnalyser::visit(ContractDefinition const& _contract)
@ -152,8 +151,7 @@ void DocStringAnalyser::parseDocStrings(
DocStringParser parser; DocStringParser parser;
if (_node.documentation() && !_node.documentation()->text()->empty()) if (_node.documentation() && !_node.documentation()->text()->empty())
{ {
if (!parser.parse(*_node.documentation()->text(), m_errorReporter)) parser.parse(*_node.documentation()->text(), m_errorReporter);
m_errorOccured = true;
_annotation.docTags = parser.tags(); _annotation.docTags = parser.tags();
} }
@ -210,6 +208,5 @@ void DocStringAnalyser::parseDocStrings(
void DocStringAnalyser::appendError(SourceLocation const& _location, string const& _description) void DocStringAnalyser::appendError(SourceLocation const& _location, string const& _description)
{ {
m_errorOccured = true;
m_errorReporter.docstringParsingError(7816_error, _location, _description); m_errorReporter.docstringParsingError(7816_error, _location, _description);
} }

View File

@ -83,7 +83,6 @@ private:
void appendError(langutil::SourceLocation const& _location, std::string const& _description); void appendError(langutil::SourceLocation const& _location, std::string const& _description);
bool m_errorOccured = false;
langutil::ErrorReporter& m_errorReporter; langutil::ErrorReporter& m_errorReporter;
}; };

View File

@ -44,8 +44,9 @@ namespace solidity::frontend
bool ReferencesResolver::resolve(ASTNode const& _root) bool ReferencesResolver::resolve(ASTNode const& _root)
{ {
auto errorWatcher = m_errorReporter.errorWatcher();
_root.accept(*this); _root.accept(*this);
return !m_errorOccurred; return errorWatcher.ok();
} }
bool ReferencesResolver::visit(Block const& _block) bool ReferencesResolver::visit(Block const& _block)
@ -267,19 +268,16 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
void ReferencesResolver::declarationError(SourceLocation const& _location, string const& _description) void ReferencesResolver::declarationError(SourceLocation const& _location, string const& _description)
{ {
m_errorOccurred = true;
m_errorReporter.declarationError(8532_error, _location, _description); m_errorReporter.declarationError(8532_error, _location, _description);
} }
void ReferencesResolver::declarationError(SourceLocation const& _location, SecondarySourceLocation const& _ssl, string const& _description) void ReferencesResolver::declarationError(SourceLocation const& _location, SecondarySourceLocation const& _ssl, string const& _description)
{ {
m_errorOccurred = true;
m_errorReporter.declarationError(3881_error, _location, _ssl, _description); m_errorReporter.declarationError(3881_error, _location, _ssl, _description);
} }
void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location, string const& _description) void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location, string const& _description)
{ {
m_errorOccurred = true;
m_errorReporter.fatalDeclarationError(6546_error, _location, _description); m_errorReporter.fatalDeclarationError(6546_error, _location, _description);
} }

View File

@ -103,7 +103,6 @@ private:
/// Stack of return parameters. /// Stack of return parameters.
std::vector<ParameterList const*> m_returnParameters; std::vector<ParameterList const*> m_returnParameters;
bool const m_resolveInsideCode; bool const m_resolveInsideCode;
bool m_errorOccurred = false;
InlineAssemblyAnnotation* m_yulAnnotation = nullptr; InlineAssemblyAnnotation* m_yulAnnotation = nullptr;
bool m_yulInsideFunction = false; bool m_yulInsideFunction = false;

View File

@ -77,10 +77,9 @@ string::const_iterator skipWhitespace(
} }
bool DocStringParser::parse(string const& _docString, ErrorReporter& _errorReporter) void DocStringParser::parse(string const& _docString, ErrorReporter& _errorReporter)
{ {
m_errorReporter = &_errorReporter; m_errorReporter = &_errorReporter;
m_errorsOccurred = false;
m_lastTag = nullptr; m_lastTag = nullptr;
auto currPos = _docString.begin(); auto currPos = _docString.begin();
@ -119,7 +118,6 @@ bool DocStringParser::parse(string const& _docString, ErrorReporter& _errorRepor
currPos = nlPos + 1; currPos = nlPos + 1;
} }
} }
return !m_errorsOccurred;
} }
DocStringParser::iter DocStringParser::parseDocTagLine(iter _pos, iter _end, bool _appending) DocStringParser::iter DocStringParser::parseDocTagLine(iter _pos, iter _end, bool _appending)
@ -194,6 +192,5 @@ void DocStringParser::newTag(string const& _tagName)
void DocStringParser::appendError(string const& _description) void DocStringParser::appendError(string const& _description)
{ {
m_errorsOccurred = true;
m_errorReporter->docstringParsingError(9440_error, _description); m_errorReporter->docstringParsingError(9440_error, _description);
} }

View File

@ -37,8 +37,7 @@ class DocStringParser
{ {
public: public:
/// Parse the given @a _docString and stores the parsed components internally. /// Parse the given @a _docString and stores the parsed components internally.
/// @returns false on error and appends the error to @a _errors. void parse(std::string const& _docString, langutil::ErrorReporter& _errorReporter);
bool parse(std::string const& _docString, langutil::ErrorReporter& _errorReporter);
std::multimap<std::string, DocTag> const& tags() const { return m_docTags; } std::multimap<std::string, DocTag> const& tags() const { return m_docTags; }
@ -65,7 +64,6 @@ private:
std::multimap<std::string, DocTag> m_docTags; std::multimap<std::string, DocTag> m_docTags;
DocTag* m_lastTag = nullptr; DocTag* m_lastTag = nullptr;
langutil::ErrorReporter* m_errorReporter = nullptr; langutil::ErrorReporter* m_errorReporter = nullptr;
bool m_errorsOccurred = false;
}; };
} }