mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add new info severity
This commit is contained in:
@@ -71,7 +71,7 @@ bool ContractLevelChecker::check(SourceUnit const& _sourceUnit)
|
||||
findDuplicateDefinitions(
|
||||
filterDeclarations<EventDefinition>(*_sourceUnit.annotation().exportedSymbols)
|
||||
);
|
||||
if (!Error::containsOnlyWarnings(m_errorReporter.errors()))
|
||||
if (Error::containsErrors(m_errorReporter.errors()))
|
||||
noErrors = false;
|
||||
for (ASTPointer<ASTNode> const& node: _sourceUnit.nodes())
|
||||
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||
@@ -97,7 +97,7 @@ bool ContractLevelChecker::check(ContractDefinition const& _contract)
|
||||
checkPayableFallbackWithoutReceive(_contract);
|
||||
checkStorageSize(_contract);
|
||||
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
return !Error::containsErrors(m_errorReporter.errors());
|
||||
}
|
||||
|
||||
void ContractLevelChecker::checkDuplicateFunctions(ContractDefinition const& _contract)
|
||||
|
||||
@@ -36,7 +36,7 @@ bool ControlFlowAnalyzer::run()
|
||||
for (auto& [pair, flow]: m_cfg.allFunctionFlows())
|
||||
analyze(*pair.function, pair.contract, *flow);
|
||||
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
return !Error::containsErrors(m_errorReporter.errors());
|
||||
}
|
||||
|
||||
void ControlFlowAnalyzer::analyze(FunctionDefinition const& _function, ContractDefinition const* _contract, FunctionFlow const& _flow)
|
||||
|
||||
@@ -27,7 +27,7 @@ using namespace solidity::frontend;
|
||||
bool CFG::constructFlow(ASTNode const& _astRoot)
|
||||
{
|
||||
_astRoot.accept(*this);
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
return !Error::containsErrors(m_errorReporter.errors());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ using namespace solidity::frontend;
|
||||
bool PostTypeChecker::check(ASTNode const& _astRoot)
|
||||
{
|
||||
_astRoot.accept(*this);
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
return !Error::containsErrors(m_errorReporter.errors());
|
||||
}
|
||||
|
||||
bool PostTypeChecker::finalize()
|
||||
{
|
||||
for (auto& checker: m_checkers)
|
||||
checker->finalize();
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
return !Error::containsErrors(m_errorReporter.errors());
|
||||
}
|
||||
|
||||
bool PostTypeChecker::visit(ContractDefinition const& _contractDefinition)
|
||||
|
||||
@@ -68,5 +68,5 @@ bool PostTypeContractLevelChecker::check(ContractDefinition const& _contract)
|
||||
errorHashes[hash][signature] = error->location();
|
||||
}
|
||||
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
return !Error::containsErrors(m_errorReporter.errors());
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ StaticAnalyzer::~StaticAnalyzer()
|
||||
bool StaticAnalyzer::analyze(SourceUnit const& _sourceUnit)
|
||||
{
|
||||
_sourceUnit.accept(*this);
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
return !Error::containsErrors(m_errorReporter.errors());
|
||||
}
|
||||
|
||||
bool StaticAnalyzer::visit(ContractDefinition const& _contract)
|
||||
|
||||
@@ -41,7 +41,7 @@ using namespace solidity::util;
|
||||
bool SyntaxChecker::checkSyntax(ASTNode const& _astRoot)
|
||||
{
|
||||
_astRoot.accept(*this);
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
return !Error::containsErrors(m_errorReporter.errors());
|
||||
}
|
||||
|
||||
bool SyntaxChecker::visit(SourceUnit const& _sourceUnit)
|
||||
|
||||
@@ -73,7 +73,7 @@ bool TypeChecker::checkTypeRequirements(SourceUnit const& _source)
|
||||
m_currentSourceUnit = &_source;
|
||||
_source.accept(*this);
|
||||
m_currentSourceUnit = nullptr;
|
||||
return Error::containsOnlyWarnings(m_errorReporter.errors());
|
||||
return !Error::containsErrors(m_errorReporter.errors());
|
||||
}
|
||||
|
||||
Type const* TypeChecker::type(Expression const& _expression) const
|
||||
|
||||
@@ -338,7 +338,7 @@ bool CompilerStack::parse()
|
||||
Source& source = m_sources[path];
|
||||
source.ast = parser.parse(*source.charStream);
|
||||
if (!source.ast)
|
||||
solAssert(!Error::containsOnlyWarnings(m_errorReporter.errors()), "Parser returned null but did not report error.");
|
||||
solAssert(Error::containsErrors(m_errorReporter.errors()), "Parser returned null but did not report error.");
|
||||
else
|
||||
{
|
||||
source.ast->annotation().path = path;
|
||||
@@ -357,7 +357,7 @@ bool CompilerStack::parse()
|
||||
m_stackState = Parsed;
|
||||
else
|
||||
m_stackState = ParsedAndImported;
|
||||
if (!Error::containsOnlyWarnings(m_errorReporter.errors()))
|
||||
if (Error::containsErrors(m_errorReporter.errors()))
|
||||
m_hasError = true;
|
||||
|
||||
storeContractDefinitions();
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace
|
||||
{
|
||||
|
||||
Json::Value formatError(
|
||||
bool _warning,
|
||||
Error::Severity _severity,
|
||||
string const& _type,
|
||||
string const& _component,
|
||||
string const& _message,
|
||||
@@ -62,7 +62,7 @@ Json::Value formatError(
|
||||
Json::Value error = Json::objectValue;
|
||||
error["type"] = _type;
|
||||
error["component"] = _component;
|
||||
error["severity"] = _warning ? "warning" : "error";
|
||||
error["severity"] = Error::formatErrorSeverityLowercase(_severity);
|
||||
error["message"] = _message;
|
||||
error["formattedMessage"] = (_formattedMessage.length() > 0) ? _formattedMessage : _message;
|
||||
if (_sourceLocation.isObject())
|
||||
@@ -76,7 +76,7 @@ Json::Value formatFatalError(string const& _type, string const& _message)
|
||||
{
|
||||
Json::Value output = Json::objectValue;
|
||||
output["errors"] = Json::arrayValue;
|
||||
output["errors"].append(formatError(false, _type, "general", _message));
|
||||
output["errors"].append(formatError(Error::Severity::Error, _type, "general", _message));
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ Json::Value formatSecondarySourceLocation(SecondarySourceLocation const* _second
|
||||
Json::Value formatErrorWithException(
|
||||
CharStreamProvider const& _charStreamProvider,
|
||||
util::Exception const& _exception,
|
||||
bool const& _warning,
|
||||
Error::Severity _severity,
|
||||
string const& _type,
|
||||
string const& _component,
|
||||
string const& _message,
|
||||
@@ -132,7 +132,7 @@ Json::Value formatErrorWithException(
|
||||
message = _message;
|
||||
|
||||
Json::Value error = formatError(
|
||||
_warning,
|
||||
_severity,
|
||||
_type,
|
||||
_component,
|
||||
message,
|
||||
@@ -660,7 +660,7 @@ std::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompiler:
|
||||
string content = sources[sourceName]["content"].asString();
|
||||
if (!hash.empty() && !hashMatchesContent(hash, content))
|
||||
ret.errors.append(formatError(
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"IOError",
|
||||
"general",
|
||||
"Mismatch between content and supplied hash for \"" + sourceName + "\""
|
||||
@@ -685,7 +685,7 @@ std::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompiler:
|
||||
{
|
||||
if (!hash.empty() && !hashMatchesContent(hash, result.responseOrErrorMessage))
|
||||
ret.errors.append(formatError(
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"IOError",
|
||||
"general",
|
||||
"Mismatch between content and supplied hash for \"" + sourceName + "\" at \"" + url.asString() + "\""
|
||||
@@ -705,7 +705,7 @@ std::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompiler:
|
||||
{
|
||||
/// If the import succeeded, let mark all the others as warnings, otherwise all of them are errors.
|
||||
ret.errors.append(formatError(
|
||||
found ? true : false,
|
||||
found ? Error::Severity::Warning : Error::Severity::Error,
|
||||
"IOError",
|
||||
"general",
|
||||
failure
|
||||
@@ -1058,7 +1058,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
errors.append(formatErrorWithException(
|
||||
compilerStack,
|
||||
*error,
|
||||
err.type() == Error::Type::Warning,
|
||||
Error::errorSeverity(err.type()),
|
||||
err.typeName(),
|
||||
"general",
|
||||
"",
|
||||
@@ -1072,7 +1072,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
errors.append(formatErrorWithException(
|
||||
compilerStack,
|
||||
_error,
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
_error.typeName(),
|
||||
"general",
|
||||
"Uncaught error: "
|
||||
@@ -1082,7 +1082,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
catch (FatalError const& _exception)
|
||||
{
|
||||
errors.append(formatError(
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"FatalError",
|
||||
"general",
|
||||
"Uncaught fatal error: " + boost::diagnostic_information(_exception)
|
||||
@@ -1093,7 +1093,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
errors.append(formatErrorWithException(
|
||||
compilerStack,
|
||||
_exception,
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"CompilerError",
|
||||
"general",
|
||||
"Compiler error (" + _exception.lineInfo() + ")"
|
||||
@@ -1104,7 +1104,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
errors.append(formatErrorWithException(
|
||||
compilerStack,
|
||||
_exception,
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"InternalCompilerError",
|
||||
"general",
|
||||
"Internal compiler error (" + _exception.lineInfo() + ")"
|
||||
@@ -1115,7 +1115,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
errors.append(formatErrorWithException(
|
||||
compilerStack,
|
||||
_exception,
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"UnimplementedFeatureError",
|
||||
"general",
|
||||
"Unimplemented feature (" + _exception.lineInfo() + ")"
|
||||
@@ -1126,7 +1126,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
errors.append(formatErrorWithException(
|
||||
compilerStack,
|
||||
_exception,
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"YulException",
|
||||
"general",
|
||||
"Yul exception"
|
||||
@@ -1137,7 +1137,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
errors.append(formatErrorWithException(
|
||||
compilerStack,
|
||||
_exception,
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"SMTLogicException",
|
||||
"general",
|
||||
"SMT logic exception"
|
||||
@@ -1146,7 +1146,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
catch (util::Exception const& _exception)
|
||||
{
|
||||
errors.append(formatError(
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"Exception",
|
||||
"general",
|
||||
"Exception during compilation: " + boost::diagnostic_information(_exception)
|
||||
@@ -1155,7 +1155,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
catch (std::exception const& _e)
|
||||
{
|
||||
errors.append(formatError(
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"Exception",
|
||||
"general",
|
||||
"Unknown exception during compilation" + (_e.what() ? ": " + string(_e.what()) : ".")
|
||||
@@ -1164,7 +1164,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
catch (...)
|
||||
{
|
||||
errors.append(formatError(
|
||||
false,
|
||||
Error::Severity::Error,
|
||||
"Exception",
|
||||
"general",
|
||||
"Unknown exception during compilation."
|
||||
@@ -1345,7 +1345,7 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
||||
errors.append(formatErrorWithException(
|
||||
stack,
|
||||
*error,
|
||||
err->type() == Error::Type::Warning,
|
||||
Error::errorSeverity(err->type()),
|
||||
err->typeName(),
|
||||
"general",
|
||||
""
|
||||
@@ -1357,7 +1357,7 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
|
||||
|
||||
// TODO: move this warning to AssemblyStack
|
||||
output["errors"] = Json::arrayValue;
|
||||
output["errors"].append(formatError(true, "Warning", "general", "Yul is still experimental. Please use the output with care."));
|
||||
output["errors"].append(formatError(Error::Severity::Warning, "Warning", "general", "Yul is still experimental. Please use the output with care."));
|
||||
|
||||
string contractName = stack.parserResult()->name.str();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user