Only use SourceReferenceFormatterHuman

This commit is contained in:
Alex Beregszaszi 2020-11-02 14:29:33 +00:00 committed by chriseth
parent 1126838a31
commit 1dedba8538
22 changed files with 47 additions and 41 deletions

View File

@ -58,6 +58,14 @@ public:
return errorOutput.str();
}
static std::string formatErrorInformation(Error const& _error)
{
return formatExceptionInformation(
_error,
(_error.type() == Error::Type::Warning) ? "Warning" : "Error"
);
}
private:
util::AnsiColorized normalColored() const;
util::AnsiColorized frameColored() const;

View File

@ -45,7 +45,7 @@
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <boost/algorithm/string/replace.hpp>
@ -460,7 +460,7 @@ void CompilerContext::appendInlineAssembly(
_assembly + "\n"
"------------------ Errors: ----------------\n";
for (auto const& error: errorReporter.errors())
message += SourceReferenceFormatter::formatErrorInformation(*error);
message += SourceReferenceFormatterHuman::formatErrorInformation(*error);
message += "-------------------------------------------\n";
solAssert(false, message);

View File

@ -37,7 +37,7 @@
#include <libsolutil/Whiskers.h>
#include <libsolutil/StringUtils.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <boost/range/adaptor/map.hpp>
@ -60,7 +60,7 @@ pair<string, string> IRGenerator::run(
{
string errorMessage;
for (auto const& error: asmStack.errors())
errorMessage += langutil::SourceReferenceFormatter::formatErrorInformation(*error);
errorMessage += langutil::SourceReferenceFormatterHuman::formatErrorInformation(*error);
solAssert(false, ir + "\n\nInvalid IR generated:\n" + errorMessage + "\n");
}
asmStack.optimize();

View File

@ -27,7 +27,7 @@
#include <libyul/AssemblyStack.h>
#include <libyul/Exceptions.h>
#include <libyul/optimiser/Suite.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libevmasm/Instruction.h>
#include <libsmtutil/Exceptions.h>
#include <libsolutil/JSON.h>
@ -117,7 +117,8 @@ Json::Value formatErrorWithException(
)
{
string message;
string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _type);
// TODO: consider enabling color
string formattedMessage = SourceReferenceFormatterHuman::formatExceptionInformation(_exception, _type);
if (string const* description = boost::get_error_info<util::errinfo_comment>(_exception))
message = ((_message.length() > 0) ? (_message + ":") : "") + *description;

View File

@ -39,7 +39,7 @@
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
// The following headers are generated from the
// yul files placed in libyul/backends/wasm/polyfill.
@ -97,7 +97,7 @@ Object EVMToEwasmTranslator::run(Object const& _object)
message += ret.toString(&WasmDialect::instance());
message += "----------------------------------\n";
for (auto const& err: errors)
message += langutil::SourceReferenceFormatter::formatErrorInformation(*err);
message += langutil::SourceReferenceFormatterHuman::formatErrorInformation(*err);
yulAssert(false, message);
}
@ -131,7 +131,7 @@ void EVMToEwasmTranslator::parsePolyfill()
{
string message;
for (auto const& err: errors)
message += langutil::SourceReferenceFormatter::formatErrorInformation(*err);
message += langutil::SourceReferenceFormatterHuman::formatErrorInformation(*err);
yulAssert(false, message);
}

View File

@ -24,7 +24,7 @@
#include <test/Common.h>
#include <libsolidity/interface/CompilerStack.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libsolidity/ast/AST.h>
@ -149,7 +149,7 @@ string AnalysisFramework::formatErrors() const
string AnalysisFramework::formatError(Error const& _error) const
{
return SourceReferenceFormatter::formatErrorInformation(_error);
return SourceReferenceFormatterHuman::formatErrorInformation(_error);
}
ContractDefinition const* AnalysisFramework::retrieveContractByName(SourceUnit const& _source, string const& _name)

View File

@ -27,7 +27,6 @@
#include <libevmasm/PathGasMeter.h>
#include <libsolidity/ast/AST.h>
#include <libsolidity/interface/GasEstimator.h>
#include <liblangutil/SourceReferenceFormatter.h>
using namespace std;
using namespace solidity::langutil;

View File

@ -30,7 +30,7 @@
#include <liblangutil/Scanner.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libevmasm/Assembly.h>
@ -81,7 +81,7 @@ std::optional<Error> parseAndReturnFirstError(
{
string errors;
for (auto const& err: stack.errors())
errors += SourceReferenceFormatter::formatErrorInformation(*err);
errors += SourceReferenceFormatterHuman::formatErrorInformation(*err);
BOOST_FAIL("Found more than one error:\n" + errors);
}
error = e;

View File

@ -25,6 +25,8 @@
#include <iostream>
#include <boost/test/framework.hpp>
#include <test/libsolidity/SolidityExecutionFramework.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
using namespace solidity;
using namespace solidity::test;
@ -60,7 +62,7 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
for (auto const& error: m_compiler.errors())
if (error->type() == langutil::Error::Type::CodeGenerationError)
BOOST_THROW_EXCEPTION(*error);
langutil::SourceReferenceFormatter formatter(std::cerr);
langutil::SourceReferenceFormatterHuman formatter(std::cerr, true, false);
for (auto const& error: m_compiler.errors())
formatter.printErrorInformation(*error);

View File

@ -32,9 +32,6 @@
#include <libyul/AssemblyStack.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatter.h>
namespace solidity::frontend::test
{

View File

@ -23,7 +23,7 @@
#include <test/Common.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libyul/optimiser/Disambiguator.h>
#include <libyul/AsmParser.h>
@ -55,7 +55,7 @@ Dialect const& defaultDialect(bool _yul)
void yul::test::printErrors(ErrorList const& _errors)
{
SourceReferenceFormatter formatter(cout);
SourceReferenceFormatterHuman formatter(cout, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -31,7 +31,7 @@
#include <libyul/Object.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libsolutil/AnsiColorized.h>
@ -116,7 +116,7 @@ string EwasmTranslationTest::interpret()
void EwasmTranslationTest::printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatter formatter(_stream);
SourceReferenceFormatterHuman formatter(_stream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -24,7 +24,7 @@
#include <libevmasm/Instruction.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <boost/algorithm/string.hpp>
@ -96,7 +96,7 @@ TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _li
void ObjectCompilerTest::printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatter formatter(_stream);
SourceReferenceFormatterHuman formatter(_stream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -28,7 +28,7 @@
#include <libyul/AsmAnalysisInfo.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libsolutil/AnsiColorized.h>
@ -104,7 +104,7 @@ string YulInterpreterTest::interpret()
void YulInterpreterTest::printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatter formatter(_stream);
SourceReferenceFormatterHuman formatter(_stream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -73,7 +73,7 @@
#include <libyul/AsmAnalysis.h>
#include <libyul/AssemblyStack.h>
#include <libyul/CompilabilityChecker.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Scanner.h>
@ -496,7 +496,7 @@ void YulOptimizerTest::updateContext()
void YulOptimizerTest::printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatter formatter(_stream);
SourceReferenceFormatterHuman formatter(_stream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);

View File

@ -1,5 +1,8 @@
#include <test/tools/ossfuzz/abiV2FuzzerCommon.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
using namespace solidity::test::abiv2fuzzer;
SolidityCompilationFramework::SolidityCompilationFramework(langutil::EVMVersion _evmVersion)
@ -21,7 +24,7 @@ solidity::bytes SolidityCompilationFramework::compileContract(
m_compiler.setOptimiserSettings(_optimization);
if (!m_compiler.compile())
{
langutil::SourceReferenceFormatter formatter(std::cerr);
langutil::SourceReferenceFormatterHuman formatter(std::cerr, false, false);
for (auto const& error: m_compiler.errors())
formatter.printExceptionInformation(

View File

@ -4,9 +4,6 @@
#include <libyul/AssemblyStack.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsolutil/Keccak256.h>
namespace solidity::test::abiv2fuzzer

View File

@ -26,7 +26,6 @@
#include <liblangutil/Exceptions.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsolutil/CommonIO.h>
#include <libsolutil/CommonData.h>

View File

@ -28,7 +28,7 @@
#include <libyul/Exceptions.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <test/tools/ossfuzz/yulFuzzerCommon.h>
@ -44,7 +44,7 @@ namespace
{
void printErrors(ostream& _stream, ErrorList const& _errors)
{
SourceReferenceFormatter formatter(_stream);
SourceReferenceFormatterHuman formatter(_stream, false, false);
for (auto const& error: _errors)
formatter.printExceptionInformation(

View File

@ -30,7 +30,7 @@
#include <libyul/AsmParser.h>
#include <libyul/AsmPrinter.h>
#include <libyul/Object.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libyul/optimiser/Disambiguator.h>
#include <libyul/optimiser/OptimiserStep.h>
@ -64,7 +64,7 @@ class YulOpti
public:
void printErrors()
{
SourceReferenceFormatter formatter(cerr);
SourceReferenceFormatterHuman formatter(cerr, true, false);
for (auto const& error: m_errors)
formatter.printErrorInformation(*error);

View File

@ -31,7 +31,7 @@
#include <liblangutil/Exceptions.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libsolutil/CommonIO.h>
#include <libsolutil/CommonData.h>
@ -58,7 +58,7 @@ namespace
void printErrors(ErrorList const& _errors)
{
for (auto const& error: _errors)
SourceReferenceFormatter(cout).printErrorInformation(*error);
SourceReferenceFormatterHuman(cout, true, false).printErrorInformation(*error);
}
pair<shared_ptr<Block>, shared_ptr<AsmAnalysisInfo>> parse(string const& _source)

View File

@ -20,7 +20,7 @@
#include <liblangutil/CharStream.h>
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libyul/AsmAnalysis.h>
#include <libyul/AsmAnalysisInfo.h>
@ -59,7 +59,7 @@ ostream& operator<<(ostream& _stream, Program const& _program);
ostream& std::operator<<(ostream& _outputStream, ErrorList const& _errors)
{
SourceReferenceFormatter formatter(_outputStream);
SourceReferenceFormatterHuman formatter(_outputStream, true, false);
for (auto const& error: _errors)
formatter.printErrorInformation(*error);