From d5f40c141b203eb12c4d6fa97418b1a8f0f789bd Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 12 Dec 2017 08:54:33 +0000 Subject: Limit the number of errors output in a single run to 256 --- libsolidity/interface/ErrorReporter.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libsolidity/interface/ErrorReporter.cpp') diff --git a/libsolidity/interface/ErrorReporter.cpp b/libsolidity/interface/ErrorReporter.cpp index e6171756..f7260d51 100644 --- a/libsolidity/interface/ErrorReporter.cpp +++ b/libsolidity/interface/ErrorReporter.cpp @@ -61,6 +61,8 @@ void ErrorReporter::warning( void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, string const& _description) { + abortIfExcessive(); + auto err = make_shared(_type); *err << errinfo_sourceLocation(_location) << @@ -71,6 +73,8 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, st void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, SecondarySourceLocation const& _secondaryLocation, string const& _description) { + abortIfExcessive(); + auto err = make_shared(_type); *err << errinfo_sourceLocation(_location) << @@ -80,6 +84,16 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, Se m_errorList.push_back(err); } +void ErrorReporter::abortIfExcessive() +{ + if (m_errorList.size() > 256) + { + auto err = make_shared(Error::Type::Warning); + *err << errinfo_comment("There are more than 256 errors. Aborting."); + m_errorList.push_back(err); + BOOST_THROW_EXCEPTION(FatalError()); + } +} void ErrorReporter::fatalError(Error::Type _type, SourceLocation const& _location, string const& _description) { -- cgit v1.2.3 From 0812d1189ad3d6ba6338ef7dc39aa61005d731e4 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 5 Apr 2018 15:14:31 +0200 Subject: Ignore warnings when limited errors to 256 --- libsolidity/interface/ErrorReporter.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'libsolidity/interface/ErrorReporter.cpp') diff --git a/libsolidity/interface/ErrorReporter.cpp b/libsolidity/interface/ErrorReporter.cpp index f7260d51..436cb64f 100644 --- a/libsolidity/interface/ErrorReporter.cpp +++ b/libsolidity/interface/ErrorReporter.cpp @@ -61,7 +61,8 @@ void ErrorReporter::warning( void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, string const& _description) { - abortIfExcessive(); + if (_type != Error::Type::Warning) + abortIfExcessive(); auto err = make_shared(_type); *err << @@ -73,7 +74,8 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, st void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, SecondarySourceLocation const& _secondaryLocation, string const& _description) { - abortIfExcessive(); + if (_type != Error::Type::Warning) + abortIfExcessive(); auto err = make_shared(_type); *err << @@ -86,7 +88,12 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, Se void ErrorReporter::abortIfExcessive() { - if (m_errorList.size() > 256) + unsigned errorCount = 0; + for (auto const& error: m_errorList) + if (error->type() != Error::Type::Warning) + errorCount++; + + if (errorCount > 256) { auto err = make_shared(Error::Type::Warning); *err << errinfo_comment("There are more than 256 errors. Aborting."); -- cgit v1.2.3 From 43d2954de83af5f64f526fd36f1cd5c3b5299498 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 5 Apr 2018 15:34:03 +0200 Subject: Do not abort excessive warnings, just ignore them. --- libsolidity/interface/ErrorReporter.cpp | 44 ++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'libsolidity/interface/ErrorReporter.cpp') diff --git a/libsolidity/interface/ErrorReporter.cpp b/libsolidity/interface/ErrorReporter.cpp index 436cb64f..368e25e0 100644 --- a/libsolidity/interface/ErrorReporter.cpp +++ b/libsolidity/interface/ErrorReporter.cpp @@ -61,8 +61,8 @@ void ErrorReporter::warning( void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, string const& _description) { - if (_type != Error::Type::Warning) - abortIfExcessive(); + if (checkForExcessiveErrors(_type)) + return; auto err = make_shared(_type); *err << @@ -74,8 +74,8 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, st void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, SecondarySourceLocation const& _secondaryLocation, string const& _description) { - if (_type != Error::Type::Warning) - abortIfExcessive(); + if (checkForExcessiveErrors(_type)) + return; auto err = make_shared(_type); *err << @@ -86,20 +86,36 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, Se m_errorList.push_back(err); } -void ErrorReporter::abortIfExcessive() +bool ErrorReporter::checkForExcessiveErrors(Error::Type _type) { - unsigned errorCount = 0; - for (auto const& error: m_errorList) - if (error->type() != Error::Type::Warning) - errorCount++; + if (_type == Error::Type::Warning) + { + m_warningCount++; + + if (m_warningCount == c_maxWarningsAllowed) + { + auto err = make_shared(Error::Type::Warning); + *err << errinfo_comment("There are more than 256 warnings. Ignoring the rest."); + m_errorList.push_back(err); + } - if (errorCount > 256) + if (m_warningCount >= c_maxWarningsAllowed) + return true; + } + else { - auto err = make_shared(Error::Type::Warning); - *err << errinfo_comment("There are more than 256 errors. Aborting."); - m_errorList.push_back(err); - BOOST_THROW_EXCEPTION(FatalError()); + m_errorCount++; + + if (m_errorCount > c_maxErrorsAllowed) + { + auto err = make_shared(Error::Type::Warning); + *err << errinfo_comment("There are more than 256 errors. Aborting."); + m_errorList.push_back(err); + BOOST_THROW_EXCEPTION(FatalError()); + } } + + return false; } void ErrorReporter::fatalError(Error::Type _type, SourceLocation const& _location, string const& _description) -- cgit v1.2.3