|
21 | 21 | #include "llvm/Testing/Support/Error.h" |
22 | 22 |
|
23 | 23 | #include "gtest/gtest.h" |
| 24 | +#include <algorithm> |
24 | 25 |
|
25 | 26 | using namespace llvm; |
26 | 27 | using namespace llvm::logicalview; |
@@ -133,6 +134,26 @@ void checkElementPropertiesClangCodeview(LVReader *Reader) { |
133 | 134 | const LVLines *Lines = Foo->getLines(); |
134 | 135 | ASSERT_NE(Lines, nullptr); |
135 | 136 | EXPECT_EQ(Lines->size(), 0x10u); |
| 137 | + |
| 138 | + // Check size of types in CompileUnit. |
| 139 | + const LVTypes *Types = CompileUnit->getTypes(); |
| 140 | + ASSERT_NE(Types, nullptr); |
| 141 | + EXPECT_EQ(Types->size(), 6u); |
| 142 | + |
| 143 | + const auto BoolType = |
| 144 | + std::find_if(Types->begin(), Types->end(), [](const LVElement *elt) { |
| 145 | + return elt->getName() == "bool"; |
| 146 | + }); |
| 147 | + ASSERT_NE(BoolType, Types->end()); |
| 148 | + const auto IntType = |
| 149 | + std::find_if(Types->begin(), Types->end(), [](const LVElement *elt) { |
| 150 | + return elt->getName() == "int"; |
| 151 | + }); |
| 152 | + ASSERT_NE(IntType, Types->end()); |
| 153 | + EXPECT_EQ(static_cast<LVType *>(*BoolType)->getBitSize(), 8u); |
| 154 | + EXPECT_EQ(static_cast<LVType *>(*BoolType)->getStorageSizeInBytes(), 1u); |
| 155 | + EXPECT_EQ(static_cast<LVType *>(*IntType)->getBitSize(), 32u); |
| 156 | + EXPECT_EQ(static_cast<LVType *>(*IntType)->getStorageSizeInBytes(), 4u); |
136 | 157 | } |
137 | 158 |
|
138 | 159 | // Check the logical elements basic properties (MSVC - Codeview). |
@@ -199,6 +220,26 @@ void checkElementPropertiesMsvcCodeview(LVReader *Reader) { |
199 | 220 | const LVLines *Lines = Foo->getLines(); |
200 | 221 | ASSERT_NE(Lines, nullptr); |
201 | 222 | EXPECT_EQ(Lines->size(), 0x0eu); |
| 223 | + |
| 224 | + // Check size of types in CompileUnit. |
| 225 | + const LVTypes *Types = CompileUnit->getTypes(); |
| 226 | + ASSERT_NE(Types, nullptr); |
| 227 | + EXPECT_EQ(Types->size(), 8u); |
| 228 | + |
| 229 | + const auto BoolType = |
| 230 | + std::find_if(Types->begin(), Types->end(), [](const LVElement *elt) { |
| 231 | + return elt->getName() == "bool"; |
| 232 | + }); |
| 233 | + ASSERT_NE(BoolType, Types->end()); |
| 234 | + const auto IntType = |
| 235 | + std::find_if(Types->begin(), Types->end(), [](const LVElement *elt) { |
| 236 | + return elt->getName() == "int"; |
| 237 | + }); |
| 238 | + ASSERT_NE(IntType, Types->end()); |
| 239 | + EXPECT_EQ(static_cast<LVType *>(*BoolType)->getBitSize(), 8u); |
| 240 | + EXPECT_EQ(static_cast<LVType *>(*BoolType)->getStorageSizeInBytes(), 1u); |
| 241 | + EXPECT_EQ(static_cast<LVType *>(*IntType)->getBitSize(), 32u); |
| 242 | + EXPECT_EQ(static_cast<LVType *>(*IntType)->getStorageSizeInBytes(), 4u); |
202 | 243 | } |
203 | 244 |
|
204 | 245 | // Check the logical elements basic properties (MSVC library - Codeview). |
|
0 commit comments