[PATCH] D68164: [Commandline] Clear error on raw_ostream when there is parsing error.
Yuanfang Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 15:11:39 PDT 2019
ychen created this revision.
ychen added reviewers: zturner, ruiu, pcc.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Otherwise report_fatal_error will be triggered in
raw_fd_ostream::~raw_fd_ostream for llvm::errs since it is a static object.
Exposed by llvm/test/Other/close-stderr.ll where 2>&- is used.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D68164
Files:
llvm/include/llvm/Support/raw_ostream.h
llvm/lib/Support/CommandLine.cpp
Index: llvm/lib/Support/CommandLine.cpp
===================================================================
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -1582,10 +1582,11 @@
// be processed once!
MoreHelp.clear();
- // If we had an error processing our arguments, don't let the program execute
if (ErrorParsing) {
- if (!IgnoreErrors)
+ if (!IgnoreErrors) {
+ Errs->clear_error();
exit(1);
+ }
return false;
}
return true;
Index: llvm/include/llvm/Support/raw_ostream.h
===================================================================
--- llvm/include/llvm/Support/raw_ostream.h
+++ llvm/include/llvm/Support/raw_ostream.h
@@ -296,6 +296,8 @@
// changeColor() has no effect until enable_colors() is called.
virtual void enable_colors(bool /*enable*/) {}
+ virtual void clear_error() {}
+
//===--------------------------------------------------------------------===//
// Subclass Interface
//===--------------------------------------------------------------------===//
@@ -480,7 +482,7 @@
/// Unless explicitly silenced."
/// - from The Zen of Python, by Tim Peters
///
- void clear_error() { EC = std::error_code(); }
+ void clear_error() override { EC = std::error_code(); }
};
/// This returns a reference to a raw_ostream for standard output. Use it like:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68164.222256.patch
Type: text/x-patch
Size: 1379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190927/5d3bb574/attachment.bin>
More information about the llvm-commits
mailing list