That works, I agree it doesn’t make sense to have descendants of ErrorSuccess.<br><br>Lgtm<br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 7, 2018 at 6:55 AM Alexandre Ganea via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">aganea updated this revision to Diff 164412.<br>
aganea added a reviewer: lhames.<br>
aganea added a comment.<br>
<br>
Updated diff. I made `ErrorSuccess` a `final` class. That makes things simpler and solves the issue for `Expected` as well.<br>
<br>
Please let me know if that sounds better.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D51490" rel="noreferrer" target="_blank">https://reviews.llvm.org/D51490</a><br>
<br>
Files:<br>
include/llvm/Support/Error.h<br>
unittests/Support/ErrorTest.cpp<br>
<br>
<br>
Index: unittests/Support/ErrorTest.cpp<br>
===================================================================<br>
--- unittests/Support/ErrorTest.cpp<br>
+++ unittests/Support/ErrorTest.cpp<br>
@@ -874,6 +874,9 @@<br>
},<br>
"");<br>
#endif<br>
+ // Not allowed, would fail at compile-time<br>
+ //consumeError(createFileError("file.bin", ErrorSuccess()));<br>
+<br>
Error E1 = make_error<CustomError>(1);<br>
Error FE1 = createFileError("file.bin", std::move(E1));<br>
EXPECT_EQ(toString(std::move(FE1)).compare("'file.bin': CustomError {1}"), 0);<br>
Index: include/llvm/Support/Error.h<br>
===================================================================<br>
--- include/llvm/Support/Error.h<br>
+++ include/llvm/Support/Error.h<br>
@@ -322,7 +322,7 @@<br>
/// Subclass of Error for the sole purpose of identifying the success path in<br>
/// the type system. This allows to catch invalid conversion to Expected<T> at<br>
/// compile time.<br>
-class ErrorSuccess : public Error {};<br>
+class ErrorSuccess final : public Error {};<br>
<br>
inline ErrorSuccess Error::success() { return ErrorSuccess(); }<br>
<br>
@@ -1171,8 +1171,7 @@<br>
/// show more detailed information to the user.<br>
class FileError final : public ErrorInfo<FileError> {<br>
<br>
- template <class Err><br>
- friend Error createFileError(std::string, Err);<br>
+ friend Error createFileError(std::string, Error);<br>
<br>
public:<br>
void log(raw_ostream &OS) const override {<br>
@@ -1207,11 +1206,12 @@<br>
<br>
/// Concatenate a source file path and/or name with an Error. The resulting<br>
/// Error is unchecked.<br>
-template <class Err><br>
-inline Error createFileError(std::string F, Err E) {<br>
+inline Error createFileError(std::string F, Error E) {<br>
return FileError::build(F, std::move(E));<br>
}<br>
<br>
+Error createFileError(std::string F, ErrorSuccess) = delete;<br>
+<br>
/// Helper for check-and-exit error handling.<br>
///<br>
/// For tool use only. NOT FOR USE IN LIBRARY CODE.<br>
<br>
<br>
</blockquote></div>