summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/DebugInfo
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-07-17 20:28:06 +0000
committerReid Kleckner <rnk@google.com>2017-07-17 20:28:06 +0000
commita842cd75e2edf3b901835d4751f5ba3897da82dc (patch)
treea116afb5c722c19f07e28efd34763b83746868c7 /llvm/unittests/DebugInfo
parent0cf9e702bf813a571b54d5c35b793b14a66006fc (diff)
downloadbcm5719-llvm-a842cd75e2edf3b901835d4751f5ba3897da82dc.tar.gz
bcm5719-llvm-a842cd75e2edf3b901835d4751f5ba3897da82dc.zip
[codeview] Remove TypeServerHandler and PDBTypeServerHandler
Summary: Instead of wiring these through the CVTypeVisitor interface, clients should inspect the CVTypeArray before visiting it and potentially load up the type server's TPI stream if they need it. No tests relied on this functionality because LLD was the only client. Reviewers: ruiu Subscribers: mgorny, hiraditya, zturner, llvm-commits Differential Revision: https://reviews.llvm.org/D35394 llvm-svn: 308212
Diffstat (limited to 'llvm/unittests/DebugInfo')
-rw-r--r--llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp3
-rw-r--r--llvm/unittests/DebugInfo/PDB/CMakeLists.txt3
-rw-r--r--llvm/unittests/DebugInfo/PDB/TypeServerHandlerTest.cpp183
3 files changed, 2 insertions, 187 deletions
diff --git a/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp b/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp
index 92134513b75..04b7bb0ba93 100644
--- a/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp
+++ b/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp
@@ -13,7 +13,6 @@
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
#include "llvm/DebugInfo/CodeView/TypeSerializer.h"
-#include "llvm/DebugInfo/CodeView/TypeServerHandler.h"
#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
@@ -402,4 +401,4 @@ TEST_F(RandomAccessVisitorTest, CrossChunkName) {
StringRef Name = Types.getTypeName(IndexOne);
EXPECT_EQ("const FooClass", Name);
-} \ No newline at end of file
+}
diff --git a/llvm/unittests/DebugInfo/PDB/CMakeLists.txt b/llvm/unittests/DebugInfo/PDB/CMakeLists.txt
index 989cb396f67..583b065f464 100644
--- a/llvm/unittests/DebugInfo/PDB/CMakeLists.txt
+++ b/llvm/unittests/DebugInfo/PDB/CMakeLists.txt
@@ -10,11 +10,10 @@ set(DebugInfoPDBSources
StringTableBuilderTest.cpp
MSFBuilderTest.cpp
PDBApiTest.cpp
- TypeServerHandlerTest.cpp
)
add_llvm_unittest(DebugInfoPDBTests
${DebugInfoPDBSources}
)
-target_link_libraries(DebugInfoPDBTests LLVMTestingSupport) \ No newline at end of file
+target_link_libraries(DebugInfoPDBTests LLVMTestingSupport)
diff --git a/llvm/unittests/DebugInfo/PDB/TypeServerHandlerTest.cpp b/llvm/unittests/DebugInfo/PDB/TypeServerHandlerTest.cpp
deleted file mode 100644
index d09b9130ee2..00000000000
--- a/llvm/unittests/DebugInfo/PDB/TypeServerHandlerTest.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-//===- llvm/unittest/DebugInfo/PDB/TypeServerHandlerTest.cpp --------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/DebugInfo/CodeView/TypeServerHandler.h"
-#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
-#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
-#include "llvm/DebugInfo/CodeView/TypeSerializer.h"
-#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
-#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
-#include "llvm/Support/Allocator.h"
-#include "llvm/Support/Error.h"
-#include "llvm/Testing/Support/Error.h"
-
-#include "gtest/gtest.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-using namespace llvm::pdb;
-
-namespace {
-
-constexpr uint8_t Guid[] = {0x2a, 0x2c, 0x1c, 0x2a, 0xcb, 0x9e, 0x48, 0x18,
- 0x82, 0x82, 0x7a, 0x87, 0xc3, 0xfe, 0x16, 0xe8};
-StringRef GuidStr(reinterpret_cast<const char *>(Guid),
- llvm::array_lengthof(Guid));
-
-constexpr const char *Name = "Test Name";
-constexpr int Age = 1;
-
-class MockTypeServerHandler : public TypeServerHandler {
-public:
- explicit MockTypeServerHandler(bool HandleAlways)
- : HandleAlways(HandleAlways) {}
-
- Expected<bool> handle(TypeServer2Record &TS,
- TypeVisitorCallbacks &Callbacks) override {
- if (TS.Age != Age || TS.Guid != GuidStr || TS.Name != Name)
- return make_error<CodeViewError>(cv_error_code::corrupt_record,
- "Invalid TypeServer record!");
-
- if (Handled && !HandleAlways)
- return false;
-
- Handled = true;
- return true;
- }
-
- bool Handled = false;
- bool HandleAlways;
-};
-
-class MockTypeVisitorCallbacks : public TypeVisitorCallbacks {
-public:
- enum class State {
- Ready,
- VisitTypeBegin,
- VisitKnownRecord,
- VisitTypeEnd,
- };
- Error visitTypeBegin(CVType &CVT) override {
- if (S != State::Ready)
- return make_error<CodeViewError>(cv_error_code::unspecified,
- "Invalid visitor state!");
-
- S = State::VisitTypeBegin;
- return Error::success();
- }
-
- Error visitKnownRecord(CVType &CVT, TypeServer2Record &TS) override {
- if (S != State::VisitTypeBegin)
- return make_error<CodeViewError>(cv_error_code::unspecified,
- "Invalid visitor state!");
-
- S = State::VisitKnownRecord;
- return Error::success();
- }
-
- Error visitTypeEnd(CVType &CVT) override {
- if (S != State::VisitKnownRecord)
- return make_error<CodeViewError>(cv_error_code::unspecified,
- "Invalid visitor state!");
-
- S = State::VisitTypeEnd;
- return Error::success();
- }
-
- State S = State::Ready;
-};
-
-class TypeServerHandlerTest : public testing::Test {
-public:
- void SetUp() override {
- TypeServer2Record R(TypeRecordKind::TypeServer2);
- R.Age = Age;
- R.Guid = GuidStr;
- R.Name = Name;
-
- TypeTableBuilder Builder(Allocator);
- Builder.writeKnownType(R);
- TypeServerRecord.RecordData = Builder.records().front();
- TypeServerRecord.Type = TypeLeafKind::LF_TYPESERVER2;
- }
-
-protected:
- BumpPtrAllocator Allocator;
- CVType TypeServerRecord;
-};
-
-// Test that when no type server handler is registered, it gets handled by the
-// normal
-// visitor callbacks.
-TEST_F(TypeServerHandlerTest, VisitRecordNoTypeServer) {
- MockTypeVisitorCallbacks C2;
- MockTypeVisitorCallbacks C1;
- TypeVisitorCallbackPipeline Pipeline;
-
- Pipeline.addCallbackToPipeline(C1);
- Pipeline.addCallbackToPipeline(C2);
-
- EXPECT_THAT_ERROR(codeview::visitTypeRecord(TypeServerRecord, Pipeline),
- Succeeded());
-
- EXPECT_EQ(MockTypeVisitorCallbacks::State::VisitTypeEnd, C1.S);
- EXPECT_EQ(MockTypeVisitorCallbacks::State::VisitTypeEnd, C2.S);
-}
-
-// Test that when a TypeServerHandler is registered, it gets consumed by the
-// handler if and only if the handler returns true.
-TEST_F(TypeServerHandlerTest, VisitRecordWithTypeServerOnce) {
- MockTypeServerHandler Handler(false);
-
- MockTypeVisitorCallbacks C1;
-
- // Our mock server returns true the first time.
- EXPECT_THAT_ERROR(codeview::visitTypeRecord(TypeServerRecord, C1,
- codeview::VDS_BytesExternal,
- &Handler),
- Succeeded());
- EXPECT_TRUE(Handler.Handled);
- EXPECT_EQ(MockTypeVisitorCallbacks::State::Ready, C1.S);
-
- // And false the second time.
- EXPECT_THAT_ERROR(codeview::visitTypeRecord(TypeServerRecord, C1,
- codeview::VDS_BytesExternal,
- &Handler),
- Succeeded());
- EXPECT_TRUE(Handler.Handled);
- EXPECT_EQ(MockTypeVisitorCallbacks::State::VisitTypeEnd, C1.S);
-}
-
-// Test that when a type server handler is registered, if the handler keeps
-// returning true, it will keep getting consumed by the handler and not go
-// to the default processor.
-TEST_F(TypeServerHandlerTest, VisitRecordWithTypeServerAlways) {
- MockTypeServerHandler Handler(true);
-
- MockTypeVisitorCallbacks C1;
-
- EXPECT_THAT_ERROR(codeview::visitTypeRecord(TypeServerRecord, C1,
- codeview::VDS_BytesExternal,
- &Handler),
- Succeeded());
- EXPECT_TRUE(Handler.Handled);
- EXPECT_EQ(MockTypeVisitorCallbacks::State::Ready, C1.S);
-
- EXPECT_THAT_ERROR(codeview::visitTypeRecord(TypeServerRecord, C1,
- codeview::VDS_BytesExternal,
- &Handler),
- Succeeded());
- EXPECT_TRUE(Handler.Handled);
- EXPECT_EQ(MockTypeVisitorCallbacks::State::Ready, C1.S);
-}
-
-} // end anonymous namespace
OpenPOWER on IntegriCloud