summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2018-04-06 14:26:03 +0000
committerpatrick <patrick@openbsd.org>2018-04-06 14:26:03 +0000
commitbdabc2f19ffb9e20600dad6e8a300842a7bda50e (patch)
treec50e7b2e5449b074651bb82a58517a8ebc4a8cf7 /gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp
parentPrint a 'p' flag for file descriptors that were opened after pledge(2). (diff)
downloadwireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.tar.xz
wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.zip
Import LLVM 6.0.1 release including clang, lld and lldb.
"where is the kaboom?" deraadt@
Diffstat (limited to 'gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp')
-rw-r--r--gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp b/gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp
index 0111b172472..3068e1c3405 100644
--- a/gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp
+++ b/gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticError.h"
#include "clang/Basic/DiagnosticIDs.h"
#include "gtest/gtest.h"
@@ -72,4 +73,25 @@ TEST(DiagnosticTest, suppressAfterFatalError) {
}
}
+TEST(DiagnosticTest, diagnosticError) {
+ DiagnosticsEngine Diags(new DiagnosticIDs(), new DiagnosticOptions,
+ new IgnoringDiagConsumer());
+ PartialDiagnostic::StorageAllocator Alloc;
+ llvm::Expected<std::pair<int, int>> Value = DiagnosticError::create(
+ SourceLocation(), PartialDiagnostic(diag::err_cannot_open_file, Alloc)
+ << "file"
+ << "error");
+ ASSERT_TRUE(!Value);
+ llvm::Error Err = Value.takeError();
+ Optional<PartialDiagnosticAt> ErrDiag = DiagnosticError::take(Err);
+ llvm::cantFail(std::move(Err));
+ ASSERT_FALSE(!ErrDiag);
+ EXPECT_EQ(ErrDiag->first, SourceLocation());
+ EXPECT_EQ(ErrDiag->second.getDiagID(), diag::err_cannot_open_file);
+
+ Value = std::make_pair(20, 1);
+ ASSERT_FALSE(!Value);
+ EXPECT_EQ(*Value, std::make_pair(20, 1));
+ EXPECT_EQ(Value->first, 20);
+}
}