summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-02-25 01:20:08 +0000
committerZachary Turner <zturner@google.com>2017-02-25 01:20:08 +0000
commit3e2b6925b96788e577f5969ba394dea98e9b8586 (patch)
treedf7bc9f38329504af5e759e5b591f75222890eab
parentf003cd3344e87604a44d147058570761cd6ce133 (diff)
downloadbcm5719-llvm-3e2b6925b96788e577f5969ba394dea98e9b8586.tar.gz
bcm5719-llvm-3e2b6925b96788e577f5969ba394dea98e9b8586.zip
Re-enable BinaryStreamTest.StreamReaderObject.
I had an invalid pointer / size calculation that was causing a stack smash. Should be fixed now. llvm-svn: 296220
-rw-r--r--llvm/unittests/DebugInfo/PDB/BinaryStreamTest.cpp60
-rw-r--r--llvm/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp2
2 files changed, 28 insertions, 34 deletions
diff --git a/llvm/unittests/DebugInfo/PDB/BinaryStreamTest.cpp b/llvm/unittests/DebugInfo/PDB/BinaryStreamTest.cpp
index 2b735b0c051..a601a10d132 100644
--- a/llvm/unittests/DebugInfo/PDB/BinaryStreamTest.cpp
+++ b/llvm/unittests/DebugInfo/PDB/BinaryStreamTest.cpp
@@ -443,39 +443,33 @@ TEST_F(BinaryStreamTest, StreamReaderEnum) {
}
}
-//TEST_F(BinaryStreamTest, StreamReaderObject) {
-// struct Foo {
-// int X;
-// double Y;
-// char Z;
-// };
-//
-// std::vector<Foo> Foos;
-// Foos.push_back({-42, 42.42, 42});
-// Foos.push_back({100, 3.1415, -89});
-//
-// std::vector<uint8_t> Bytes;
-// Bytes.resize(2 * sizeof(Foo));
-// Foo *FPtr = reinterpret_cast<Foo *>(&Bytes[0]);
-// Foo *GPtr = FPtr + 1;
-//
-// ::memcpy(FPtr, &Foos[0], sizeof(Foo));
-// ::memcpy(GPtr + sizeof(Foo), &Foos[1], sizeof(Foo));
-//
-// initialize(Bytes, 0);
-//
-// for (auto IS : InputStreams) {
-// // 1. Reading object pointers.
-// BinaryStreamReader Reader(*IS);
-// const Foo *FPtrOut = nullptr;
-// const Foo *GPtrOut = nullptr;
-// ASSERT_NO_ERROR(Reader.readObject(FPtrOut));
-// ASSERT_NO_ERROR(Reader.readObject(GPtrOut));
-// EXPECT_EQ(0U, Reader.bytesRemaining());
-// EXPECT_EQ(0, ::memcmp(FPtr, FPtrOut, sizeof(Foo)));
-// EXPECT_EQ(0, ::memcmp(GPtr, GPtrOut, sizeof(Foo)));
-// }
-//}
+TEST_F(BinaryStreamTest, StreamReaderObject) {
+ struct Foo {
+ int X;
+ double Y;
+ char Z;
+ };
+
+ std::vector<Foo> Foos;
+ Foos.push_back({-42, 42.42, 42});
+ Foos.push_back({100, 3.1415, -89});
+
+ const uint8_t *Bytes = reinterpret_cast<const uint8_t *>(&Foos[0]);
+
+ initialize(makeArrayRef(Bytes, 2 * sizeof(Foo)), 0);
+
+ for (auto IS : InputStreams) {
+ // 1. Reading object pointers.
+ BinaryStreamReader Reader(*IS);
+ const Foo *FPtrOut = nullptr;
+ const Foo *GPtrOut = nullptr;
+ ASSERT_NO_ERROR(Reader.readObject(FPtrOut));
+ ASSERT_NO_ERROR(Reader.readObject(GPtrOut));
+ EXPECT_EQ(0U, Reader.bytesRemaining());
+ EXPECT_EQ(0, ::memcmp(&Foos[0], FPtrOut, sizeof(Foo)));
+ EXPECT_EQ(0, ::memcmp(&Foos[1], GPtrOut, sizeof(Foo)));
+ }
+}
TEST_F(BinaryStreamTest, StreamReaderStrings) {
std::vector<uint8_t> Bytes = {'O', 'n', 'e', '\0', 'T', 'w', 'o',
diff --git a/llvm/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp b/llvm/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp
index 9a713efd5be..fc938d4418d 100644
--- a/llvm/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp
+++ b/llvm/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp
@@ -37,7 +37,7 @@ public:
uint32_t block_size() const { return 1; }
uint32_t block_count() const { return Blocks.size(); }
- endianness getEndian() const { return little; }
+ endianness getEndian() const override { return little; }
Error readBytes(uint32_t Offset, uint32_t Size,
ArrayRef<uint8_t> &Buffer) override {
OpenPOWER on IntegriCloud