Remove code duplication in source references formatter.

This commit is contained in:
chriseth
2016-04-01 00:54:12 +02:00
parent c67926cf2b
commit ea7325d2d2
3 changed files with 37 additions and 34 deletions
+3 -2
View File
@@ -120,8 +120,9 @@ 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!");
SourceReferenceFormatter::printSourceLocation(cout, first->first->location(), m_compiler.scanner());
SourceReferenceFormatter::printSourceLocation(cout, second->first->location(), m_compiler.scanner());
auto scannerFromSource = [&](string const&) -> Scanner const& { return m_compiler.scanner(); };
SourceReferenceFormatter::printSourceLocation(cout, &first->first->location(), scannerFromSource);
SourceReferenceFormatter::printSourceLocation(cout, &second->first->location(), scannerFromSource);
}
}
}