[Support] Add Error::errorForOutParameter helper.

This helper method creates a pre-checked Error suitable for use as an out
parameter in a constructor. This avoids the need to have the constructor
check a known-good error before assigning to it.

llvm-svn: 264467
diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp
index 893bd68..1a0dd44 100644
--- a/llvm/unittests/Support/ErrorTest.cpp
+++ b/llvm/unittests/Support/ErrorTest.cpp
@@ -105,6 +105,12 @@
 }
 #endif
 
+// Test that errors to be used as out parameters are implicitly checked (
+// and thus destruct quietly).
+TEST(Error, ErrorAsOutParameter) {
+  Error E = Error::errorForOutParameter();
+}
+
 // Check that we abort on unhandled failure cases. (Force conversion to bool
 // to make sure that we don't accidentally treat checked errors as handled).
 // Test runs in debug mode only.