diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-05 21:52:58 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-05 21:52:58 +0000 |
| commit | a2686713ef3a783b0735e93342ce3d7714f8816e (patch) | |
| tree | 2592b322cd81466b678d8b50ffab68d4738edbf8 /clang/unittests/Basic | |
| parent | be68a99f20ea2e6fb38e46b3675d3615a789bdfd (diff) | |
| download | bcm5719-llvm-a2686713ef3a783b0735e93342ce3d7714f8816e.tar.gz bcm5719-llvm-a2686713ef3a783b0735e93342ce3d7714f8816e.zip | |
Make DiagnosticErrorTrap work even if SuppressAllDiagnostics is enabled.
Patch by Brad King!
llvm-svn: 223525
Diffstat (limited to 'clang/unittests/Basic')
| -rw-r--r-- | clang/unittests/Basic/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang/unittests/Basic/DiagnosticTest.cpp | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/clang/unittests/Basic/CMakeLists.txt b/clang/unittests/Basic/CMakeLists.txt index b8f69bf357b..3cb3cb8d3c8 100644 --- a/clang/unittests/Basic/CMakeLists.txt +++ b/clang/unittests/Basic/CMakeLists.txt @@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS add_clang_unittest(BasicTests CharInfoTest.cpp + DiagnosticTest.cpp FileManagerTest.cpp SourceManagerTest.cpp VirtualFileSystemTest.cpp diff --git a/clang/unittests/Basic/DiagnosticTest.cpp b/clang/unittests/Basic/DiagnosticTest.cpp new file mode 100644 index 00000000000..fa2b56e0834 --- /dev/null +++ b/clang/unittests/Basic/DiagnosticTest.cpp @@ -0,0 +1,49 @@ +//===- 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/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()); +} + +} |

