summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 15:06:44 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 15:06:44 +0000
commitb64793999546ed8adebaeebd9d8345d18db8927d (patch)
tree4357c27b561d73b0e089727c6ed659f2ceff5f47 /gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp
parentAdd support for UTF-8 DISPLAY-HINTs with octet length. For now only (diff)
downloadwireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.tar.xz
wireguard-openbsd-b64793999546ed8adebaeebd9d8345d18db8927d.zip
Remove LLVM 8.0.1 files.
Diffstat (limited to 'gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp')
-rw-r--r--gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp97
1 files changed, 0 insertions, 97 deletions
diff --git a/gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp b/gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp
deleted file mode 100644
index 3068e1c3405..00000000000
--- a/gnu/llvm/tools/clang/unittests/Basic/DiagnosticTest.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-//===- unittests/Basic/DiagnosticTest.cpp -- Diagnostic engine tests ------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Basic/Diagnostic.h"
-#include "clang/Basic/DiagnosticError.h"
-#include "clang/Basic/DiagnosticIDs.h"
-#include "gtest/gtest.h"
-
-using namespace llvm;
-using namespace clang;
-
-namespace {
-
-// Check that DiagnosticErrorTrap works with SuppressAllDiagnostics.
-TEST(DiagnosticTest, suppressAndTrap) {
- DiagnosticsEngine Diags(new DiagnosticIDs(),
- new DiagnosticOptions,
- new IgnoringDiagConsumer());
- Diags.setSuppressAllDiagnostics(true);
-
- {
- DiagnosticErrorTrap trap(Diags);
-
- // Diag that would set UncompilableErrorOccurred and ErrorOccurred.
- Diags.Report(diag::err_target_unknown_triple) << "unknown";
-
- // Diag that would set UnrecoverableErrorOccurred and ErrorOccurred.
- Diags.Report(diag::err_cannot_open_file) << "file" << "error";
-
- // Diag that would set FatalErrorOccurred
- // (via non-note following a fatal error).
- Diags.Report(diag::warn_mt_message) << "warning";
-
- EXPECT_TRUE(trap.hasErrorOccurred());
- EXPECT_TRUE(trap.hasUnrecoverableErrorOccurred());
- }
-
- EXPECT_FALSE(Diags.hasErrorOccurred());
- EXPECT_FALSE(Diags.hasFatalErrorOccurred());
- EXPECT_FALSE(Diags.hasUncompilableErrorOccurred());
- EXPECT_FALSE(Diags.hasUnrecoverableErrorOccurred());
-}
-
-// Check that SuppressAfterFatalError works as intended
-TEST(DiagnosticTest, suppressAfterFatalError) {
- for (unsigned Suppress = 0; Suppress != 2; ++Suppress) {
- DiagnosticsEngine Diags(new DiagnosticIDs(),
- new DiagnosticOptions,
- new IgnoringDiagConsumer());
- Diags.setSuppressAfterFatalError(Suppress);
-
- // Diag that would set UnrecoverableErrorOccurred and ErrorOccurred.
- Diags.Report(diag::err_cannot_open_file) << "file" << "error";
-
- // Diag that would set FatalErrorOccurred
- // (via non-note following a fatal error).
- Diags.Report(diag::warn_mt_message) << "warning";
-
- EXPECT_TRUE(Diags.hasErrorOccurred());
- EXPECT_TRUE(Diags.hasFatalErrorOccurred());
- EXPECT_TRUE(Diags.hasUncompilableErrorOccurred());
- EXPECT_TRUE(Diags.hasUnrecoverableErrorOccurred());
-
- // The warning should be emitted and counted only if we're not suppressing
- // after fatal errors.
- EXPECT_EQ(Diags.getNumWarnings(), Suppress ? 0u : 1u);
- }
-}
-
-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);
-}
-}