aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/ErrorTest.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-03-25 21:56:35 +0000
committerLang Hames <lhames@gmail.com>2016-03-25 21:56:35 +0000
commitd0ac31a70694a8bf5604a151afa913b6a51078b9 (patch)
tree910f3ad7180240a29c81feedbaae2a715e1db31f /llvm/unittests/Support/ErrorTest.cpp
parentd6a04d79c7cc25419ffdaba9424a8ce1336813fb (diff)
downloadllvm-d0ac31a70694a8bf5604a151afa913b6a51078b9.zip
llvm-d0ac31a70694a8bf5604a151afa913b6a51078b9.tar.gz
llvm-d0ac31a70694a8bf5604a151afa913b6a51078b9.tar.bz2
[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
Diffstat (limited to 'llvm/unittests/Support/ErrorTest.cpp')
-rw-r--r--llvm/unittests/Support/ErrorTest.cpp6
1 files changed, 6 insertions, 0 deletions
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 @@ TEST(Error, UncheckedSuccess) {
}
#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.