From a59fc39f101449587bad937a92c0c9802c7d6438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 8 Aug 2023 17:17:37 +0200 Subject: [PATCH] Use printErrorInformation() over printExceptionInformation() where possible --- liblangutil/SourceReferenceFormatter.h | 4 ++++ solc/CommandLineInterface.cpp | 2 +- test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp | 5 +---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/liblangutil/SourceReferenceFormatter.h b/liblangutil/SourceReferenceFormatter.h index 8d3121a7a..91f1d7ddd 100644 --- a/liblangutil/SourceReferenceFormatter.h +++ b/liblangutil/SourceReferenceFormatter.h @@ -52,6 +52,10 @@ public: m_withErrorIds(_withErrorIds) {} + // WARNING: Use the xyzErrorInformation() variants over xyzExceptionInformation() when you + // do have access to an Error instance. Error is implicitly convertible to util::Exception + // but the conversion loses the error ID. + /// Prints source location if it is given. void printSourceLocation(SourceReference const& _ref); void printExceptionInformation(SourceReferenceExtractor::Message const& _msg); diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 7a28900b3..509279a71 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -827,7 +827,7 @@ void CommandLineInterface::compile() else { m_hasOutput = true; - formatter.printExceptionInformation(_error, Error::errorSeverity(_error.type())); + formatter.printErrorInformation(_error); solThrow(CommandLineExecutionError, ""); } } diff --git a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp index b1725a8fa..d1717a159 100644 --- a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp @@ -77,10 +77,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) Error::containsErrors(stack.errors()) ) { - SourceReferenceFormatter formatter(std::cout, stack, false, false); - - for (auto const& error: stack.errors()) - formatter.printExceptionInformation(*error, Error::errorSeverity(error->type())); + SourceReferenceFormatter{std::cout, stack, false, false}.printErrorInformation(stack.errors()); yulAssert(false, "Proto fuzzer generated malformed program"); }