Merge pull request #5554 from ethereum/cp-SourceReferenceFormatter-refactor

[2/3] Refactor SourceReferenceFormatter (split-out data extraction & make use of new SourceLocation knowledge)
This commit is contained in:
chriseth
2018-12-06 14:01:39 +01:00
committed by GitHub
16 changed files with 234 additions and 126 deletions
+1 -2
View File
@@ -127,8 +127,7 @@ string AnalysisFramework::formatError(Error const& _error) const
{
return SourceReferenceFormatter::formatExceptionInformation(
_error,
(_error.type() == Error::Type::Warning) ? "Warning" : "Error",
[&](std::string const& _sourceName) -> Scanner const& { return m_compiler.scanner(_sourceName); }
(_error.type() == Error::Type::Warning) ? "Warning" : "Error"
);
}
+1 -2
View File
@@ -138,8 +138,7 @@ BOOST_AUTO_TEST_CASE(non_overlapping_filtered_costs)
if (first->first->location().intersects(second->first->location()))
{
BOOST_CHECK_MESSAGE(false, "Source locations should not overlap!");
auto scannerFromSource = [&](string const& _sourceName) -> Scanner const& { return m_compiler.scanner(_sourceName); };
SourceReferenceFormatter formatter(cout, scannerFromSource);
SourceReferenceFormatter formatter(cout);
formatter.printSourceLocation(&first->first->location());
formatter.printSourceLocation(&second->first->location());
@@ -72,8 +72,7 @@ public:
m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
if (!m_compiler.compile())
{
auto scannerFromSourceName = [&](std::string const& _sourceName) -> langutil::Scanner const& { return m_compiler.scanner(_sourceName); };
langutil::SourceReferenceFormatter formatter(std::cerr, scannerFromSourceName);
langutil::SourceReferenceFormatter formatter(std::cerr);
for (auto const& error: m_compiler.errors())
formatter.printExceptionInformation(