From 89b60ffbd4c2dde26fa5e9f1d750729b5c89373e Mon Sep 17 00:00:00 2001 From: Rhett Aultman Date: Thu, 11 May 2017 06:26:35 -0700 Subject: Refactor error reporting This commit introduces ErrorReporter, a utility class which consolidates all of the error logging functionality into a common set of functions. It also replaces all direct interactions with an ErrorList with calls to an ErrorReporter. This commit resolves issue #2209 --- test/libjulia/Parser.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test/libjulia') diff --git a/test/libjulia/Parser.cpp b/test/libjulia/Parser.cpp index b82c446a..afeb95f8 100644 --- a/test/libjulia/Parser.cpp +++ b/test/libjulia/Parser.cpp @@ -45,16 +45,16 @@ namespace test namespace { -bool parse(string const& _source, ErrorList& errors) +bool parse(string const& _source, ErrorReporter& errorReporter) { try { auto scanner = make_shared(CharStream(_source)); - auto parserResult = assembly::Parser(errors, true).parse(scanner); + auto parserResult = assembly::Parser(errorReporter, true).parse(scanner); if (parserResult) { assembly::AsmAnalysisInfo analysisInfo; - return (assembly::AsmAnalyzer(analysisInfo, errors, true)).analyze(*parserResult); + return (assembly::AsmAnalyzer(analysisInfo, errorReporter, true)).analyze(*parserResult); } } catch (FatalError const&) @@ -67,7 +67,8 @@ bool parse(string const& _source, ErrorList& errors) boost::optional parseAndReturnFirstError(string const& _source, bool _allowWarnings = true) { ErrorList errors; - if (!parse(_source, errors)) + ErrorReporter errorReporter(errors); + if (!parse(_source, errorReporter)) { BOOST_REQUIRE_EQUAL(errors.size(), 1); return *errors.front(); -- cgit