Index: llvm/include/llvm/gtest/ErrorChecking.h =================================================================== --- /dev/null +++ llvm/include/llvm/gtest/ErrorChecking.h @@ -0,0 +1,69 @@ +//===- ErrorChecking.h - Helpers for verifying llvm::Errors -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_GTEST_ERRORCHECKING_H +#define LLVM_GTEST_ERRORCHECKING_H + +#define EXPECT_NO_ERROR(Err) \ + { \ + auto E = Err; \ + EXPECT_FALSE(static_cast(E)); \ + if (E) \ + consumeError(std::move(E)); \ + } + +#define ASSERT_NO_ERROR(Err) \ + { \ + auto E = Err; \ + ASSERT_FALSE(static_cast(E)); \ + if (E) \ + consumeError(std::move(E)); \ + } + +#define EXPECT_ERROR(Err) \ + { \ + auto E = Err; \ + EXPECT_TRUE(static_cast(E)); \ + if (E) \ + consumeError(std::move(E)); \ + } + +#define EXPECT_EXPECTED(Exp) \ + { \ + auto E = Exp.takeError(); \ + EXPECT_FALSE(static_cast(E)); \ + if (E) { \ + consumeError(std::move(E)); \ + return; \ + } \ + } + +#define EXPECT_EXPECTED_EQ(Val, Exp) \ + { \ + auto Result = Exp; \ + auto E = Result.takeError(); \ + EXPECT_FALSE(static_cast(E)); \ + if (E) { \ + consumeError(std::move(E)); \ + return; \ + } \ + EXPECT_EQ(Val, *Result); \ + } + +#define EXPECT_UNEXPECTED(Exp) \ + { \ + auto E = Exp.takeError(); \ + EXPECT_TRUE(static_cast(E)); \ + if (E) { \ + consumeError(std::move(E)); \ + return; \ + } \ + } + +#endif Index: llvm/unittests/DebugInfo/CodeView/ErrorChecking.h =================================================================== --- llvm/unittests/DebugInfo/CodeView/ErrorChecking.h +++ /dev/null @@ -1,61 +0,0 @@ -//===- ErrorChecking.h - Helpers for verifying llvm::Errors -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_UNITTESTS_DEBUGINFO_CODEVIEW_ERRORCHECKING_H -#define LLVM_UNITTESTS_DEBUGINFO_CODEVIEW_ERRORCHECKING_H - -#define EXPECT_NO_ERROR(Err) \ - { \ - auto E = Err; \ - EXPECT_FALSE(static_cast(E)); \ - if (E) \ - consumeError(std::move(E)); \ - } - -#define EXPECT_ERROR(Err) \ - { \ - auto E = Err; \ - EXPECT_TRUE(static_cast(E)); \ - if (E) \ - consumeError(std::move(E)); \ - } - -#define EXPECT_EXPECTED(Exp) \ - { \ - auto E = Exp.takeError(); \ - EXPECT_FALSE(static_cast(E)); \ - if (E) { \ - consumeError(std::move(E)); \ - return; \ - } \ - } - -#define EXPECT_EXPECTED_EQ(Val, Exp) \ - { \ - auto Result = Exp; \ - auto E = Result.takeError(); \ - EXPECT_FALSE(static_cast(E)); \ - if (E) { \ - consumeError(std::move(E)); \ - return; \ - } \ - EXPECT_EQ(Val, *Result); \ - } - -#define EXPECT_UNEXPECTED(Exp) \ - { \ - auto E = Exp.takeError(); \ - EXPECT_TRUE(static_cast(E)); \ - if (E) { \ - consumeError(std::move(E)); \ - return; \ - } \ - } - -#endif Index: llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp =================================================================== --- llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp +++ llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "ErrorChecking.h" - #include "llvm/ADT/SmallBitVector.h" #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" #include "llvm/DebugInfo/CodeView/RandomAccessTypeVisitor.h" @@ -23,6 +21,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryItemStream.h" #include "llvm/Support/Error.h" +#include "llvm/gtest/ErrorChecking.h" #include "gtest/gtest.h" Index: llvm/unittests/DebugInfo/PDB/ErrorChecking.h =================================================================== --- llvm/unittests/DebugInfo/PDB/ErrorChecking.h +++ /dev/null @@ -1,61 +0,0 @@ -//===- ErrorChecking.h - Helpers for verifying llvm::Errors -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_UNITTESTS_DEBUGINFO_PDB_ERRORCHECKING_H -#define LLVM_UNITTESTS_DEBUGINFO_PDB_ERRORCHECKING_H - -#define EXPECT_NO_ERROR(Err) \ - { \ - auto E = Err; \ - EXPECT_FALSE(static_cast(E)); \ - if (E) \ - consumeError(std::move(E)); \ - } - -#define EXPECT_ERROR(Err) \ - { \ - auto E = Err; \ - EXPECT_TRUE(static_cast(E)); \ - if (E) \ - consumeError(std::move(E)); \ - } - -#define EXPECT_EXPECTED(Exp) \ - { \ - auto E = Exp.takeError(); \ - EXPECT_FALSE(static_cast(E)); \ - if (E) { \ - consumeError(std::move(E)); \ - return; \ - } \ - } - -#define EXPECT_EXPECTED_EQ(Val, Exp) \ - { \ - auto Result = Exp; \ - auto E = Result.takeError(); \ - EXPECT_FALSE(static_cast(E)); \ - if (E) { \ - consumeError(std::move(E)); \ - return; \ - } \ - EXPECT_EQ(Val, *Result); \ - } - -#define EXPECT_UNEXPECTED(Exp) \ - { \ - auto E = Exp.takeError(); \ - EXPECT_TRUE(static_cast(E)); \ - if (E) { \ - consumeError(std::move(E)); \ - return; \ - } \ - } - -#endif Index: llvm/unittests/DebugInfo/PDB/HashTableTest.cpp =================================================================== --- llvm/unittests/DebugInfo/PDB/HashTableTest.cpp +++ llvm/unittests/DebugInfo/PDB/HashTableTest.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "ErrorChecking.h" #include "gtest/gtest.h" #include "llvm/DebugInfo/PDB/Native/HashTable.h" #include "llvm/Support/BinaryByteStream.h" #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/gtest/ErrorChecking.h" #include Index: llvm/unittests/DebugInfo/PDB/MSFBuilderTest.cpp =================================================================== --- llvm/unittests/DebugInfo/PDB/MSFBuilderTest.cpp +++ llvm/unittests/DebugInfo/PDB/MSFBuilderTest.cpp @@ -7,10 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "ErrorChecking.h" - #include "llvm/DebugInfo/MSF/MSFBuilder.h" #include "llvm/DebugInfo/MSF/MSFCommon.h" +#include "llvm/gtest/ErrorChecking.h" #include "gtest/gtest.h" Index: llvm/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp =================================================================== --- llvm/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp +++ llvm/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "ErrorChecking.h" - #include "llvm/DebugInfo/MSF/IMSFFile.h" #include "llvm/DebugInfo/MSF/MSFError.h" #include "llvm/DebugInfo/MSF/MSFStreamLayout.h" @@ -17,6 +15,7 @@ #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/gtest/ErrorChecking.h" #include "gtest/gtest.h" #include Index: llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp =================================================================== --- llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp +++ llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp @@ -7,13 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "ErrorChecking.h" - #include "llvm/DebugInfo/PDB/Native/PDBStringTable.h" #include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h" #include "llvm/Support/BinaryByteStream.h" #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/gtest/ErrorChecking.h" #include "gtest/gtest.h" Index: llvm/unittests/DebugInfo/PDB/TypeServerHandlerTest.cpp =================================================================== --- llvm/unittests/DebugInfo/PDB/TypeServerHandlerTest.cpp +++ llvm/unittests/DebugInfo/PDB/TypeServerHandlerTest.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "ErrorChecking.h" - #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeRecordMapping.h" @@ -20,6 +18,7 @@ #include "llvm/DebugInfo/PDB/Native/RawTypes.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Error.h" +#include "llvm/gtest/ErrorChecking.h" #include "gtest/gtest.h" Index: llvm/unittests/Support/BinaryStreamTest.cpp =================================================================== --- llvm/unittests/Support/BinaryStreamTest.cpp +++ llvm/unittests/Support/BinaryStreamTest.cpp @@ -13,6 +13,7 @@ #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/BinaryStreamWriter.h" +#include "llvm/gtest/ErrorChecking.h" #include "gtest/gtest.h" #include @@ -20,30 +21,6 @@ using namespace llvm; using namespace llvm::support; -#define EXPECT_NO_ERROR(Err) \ - { \ - auto E = Err; \ - EXPECT_FALSE(static_cast(E)); \ - if (E) \ - consumeError(std::move(E)); \ - } - -#define ASSERT_NO_ERROR(Err) \ - { \ - auto E = Err; \ - ASSERT_FALSE(static_cast(E)); \ - if (E) \ - consumeError(std::move(E)); \ - } - -#define EXPECT_ERROR(Err) \ - { \ - auto E = Err; \ - EXPECT_TRUE(static_cast(E)); \ - if (E) \ - consumeError(std::move(E)); \ - } - namespace { class BrokenStream : public WritableBinaryStream {