mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not abort excessive warnings, just ignore them.
This commit is contained in:
parent
0812d1189a
commit
43d2954de8
@ -61,8 +61,8 @@ void ErrorReporter::warning(
|
|||||||
|
|
||||||
void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, string const& _description)
|
void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, string const& _description)
|
||||||
{
|
{
|
||||||
if (_type != Error::Type::Warning)
|
if (checkForExcessiveErrors(_type))
|
||||||
abortIfExcessive();
|
return;
|
||||||
|
|
||||||
auto err = make_shared<Error>(_type);
|
auto err = make_shared<Error>(_type);
|
||||||
*err <<
|
*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)
|
void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, SecondarySourceLocation const& _secondaryLocation, string const& _description)
|
||||||
{
|
{
|
||||||
if (_type != Error::Type::Warning)
|
if (checkForExcessiveErrors(_type))
|
||||||
abortIfExcessive();
|
return;
|
||||||
|
|
||||||
auto err = make_shared<Error>(_type);
|
auto err = make_shared<Error>(_type);
|
||||||
*err <<
|
*err <<
|
||||||
@ -86,14 +86,27 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, Se
|
|||||||
m_errorList.push_back(err);
|
m_errorList.push_back(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ErrorReporter::abortIfExcessive()
|
bool ErrorReporter::checkForExcessiveErrors(Error::Type _type)
|
||||||
{
|
{
|
||||||
unsigned errorCount = 0;
|
if (_type == Error::Type::Warning)
|
||||||
for (auto const& error: m_errorList)
|
{
|
||||||
if (error->type() != Error::Type::Warning)
|
m_warningCount++;
|
||||||
errorCount++;
|
|
||||||
|
|
||||||
if (errorCount > 256)
|
if (m_warningCount == c_maxWarningsAllowed)
|
||||||
|
{
|
||||||
|
auto err = make_shared<Error>(Error::Type::Warning);
|
||||||
|
*err << errinfo_comment("There are more than 256 warnings. Ignoring the rest.");
|
||||||
|
m_errorList.push_back(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_warningCount >= c_maxWarningsAllowed)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_errorCount++;
|
||||||
|
|
||||||
|
if (m_errorCount > c_maxErrorsAllowed)
|
||||||
{
|
{
|
||||||
auto err = make_shared<Error>(Error::Type::Warning);
|
auto err = make_shared<Error>(Error::Type::Warning);
|
||||||
*err << errinfo_comment("There are more than 256 errors. Aborting.");
|
*err << errinfo_comment("There are more than 256 errors. Aborting.");
|
||||||
@ -102,6 +115,9 @@ void ErrorReporter::abortIfExcessive()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ErrorReporter::fatalError(Error::Type _type, SourceLocation const& _location, string const& _description)
|
void ErrorReporter::fatalError(Error::Type _type, SourceLocation const& _location, string const& _description)
|
||||||
{
|
{
|
||||||
error(_type, _location, _description);
|
error(_type, _location, _description);
|
||||||
|
@ -102,9 +102,16 @@ private:
|
|||||||
SourceLocation const& _location = SourceLocation(),
|
SourceLocation const& _location = SourceLocation(),
|
||||||
std::string const& _description = std::string());
|
std::string const& _description = std::string());
|
||||||
|
|
||||||
void abortIfExcessive();
|
// @returns true if error shouldn't be stored
|
||||||
|
bool checkForExcessiveErrors(Error::Type _type);
|
||||||
|
|
||||||
ErrorList& m_errorList;
|
ErrorList& m_errorList;
|
||||||
|
|
||||||
|
unsigned m_errorCount = 0;
|
||||||
|
unsigned m_warningCount = 0;
|
||||||
|
|
||||||
|
const unsigned c_maxWarningsAllowed = 256;
|
||||||
|
const unsigned c_maxErrorsAllowed = 256;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user