Index: llvm/cmake/modules/AddLLVM.cmake =================================================================== --- llvm/cmake/modules/AddLLVM.cmake +++ llvm/cmake/modules/AddLLVM.cmake @@ -1006,7 +1006,8 @@ endif() include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include) - include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include) + include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include) + include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/gtestutil/include) if (NOT LLVM_ENABLE_THREADS) list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_PTHREAD=0) 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" @@ -25,6 +23,7 @@ #include "llvm/Support/BinaryItemStream.h" #include "llvm/Support/Error.h" +#include "gtestutil/ErrorChecking.h" #include "gtest/gtest.h" using namespace llvm; 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,7 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "ErrorChecking.h" #include "gtest/gtest.h" #include "llvm/DebugInfo/PDB/Native/HashTable.h" @@ -15,6 +14,8 @@ #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamWriter.h" +#include "gtestutil/ErrorChecking.h" + #include using namespace llvm; Index: llvm/unittests/DebugInfo/PDB/MSFBuilderTest.cpp =================================================================== --- llvm/unittests/DebugInfo/PDB/MSFBuilderTest.cpp +++ llvm/unittests/DebugInfo/PDB/MSFBuilderTest.cpp @@ -7,11 +7,10 @@ // //===----------------------------------------------------------------------===// -#include "ErrorChecking.h" - #include "llvm/DebugInfo/MSF/MSFBuilder.h" #include "llvm/DebugInfo/MSF/MSFCommon.h" +#include "gtestutil/ErrorChecking.h" #include "gtest/gtest.h" using namespace llvm; 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,8 @@ #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/BinaryStreamWriter.h" + +#include "gtestutil/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,14 +7,13 @@ // //===----------------------------------------------------------------------===// -#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 "gtestutil/ErrorChecking.h" #include "gtest/gtest.h" using namespace llvm; 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" @@ -21,6 +19,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/Error.h" +#include "gtestutil/ErrorChecking.h" #include "gtest/gtest.h" using namespace llvm; Index: llvm/unittests/Support/BinaryStreamTest.cpp =================================================================== --- llvm/unittests/Support/BinaryStreamTest.cpp +++ llvm/unittests/Support/BinaryStreamTest.cpp @@ -13,6 +13,8 @@ #include "llvm/Support/BinaryStreamReader.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/BinaryStreamWriter.h" + +#include "gtestutil/ErrorChecking.h" #include "gtest/gtest.h" #include @@ -21,30 +23,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 { Index: llvm/utils/unittest/gtestutil/include/gtestutil/ErrorChecking.h =================================================================== --- llvm/utils/unittest/gtestutil/include/gtestutil/ErrorChecking.h +++ llvm/utils/unittest/gtestutil/include/gtestutil/ErrorChecking.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_UNITTESTS_DEBUGINFO_CODEVIEW_ERRORCHECKING_H -#define LLVM_UNITTESTS_DEBUGINFO_CODEVIEW_ERRORCHECKING_H +#ifndef LLVM_GTEST_ERRORCHECKING_H +#define LLVM_GTEST_ERRORCHECKING_H #define EXPECT_NO_ERROR(Err) \ { \ @@ -18,6 +18,14 @@ 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; \