1 //===- llvm/unittest/DebugInfo/PDB/PDBApiTest.cpp -------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include <unordered_map> 11 12 #include "llvm/ADT/STLExtras.h" 13 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" 14 #include "llvm/DebugInfo/PDB/IPDBLineNumber.h" 15 #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" 16 #include "llvm/DebugInfo/PDB/IPDBSession.h" 17 #include "llvm/DebugInfo/PDB/IPDBSourceFile.h" 18 #include "llvm/DebugInfo/PDB/IPDBTable.h" 19 20 #include "llvm/DebugInfo/PDB/PDBSymbol.h" 21 #include "llvm/DebugInfo/PDB/PDBSymbolAnnotation.h" 22 #include "llvm/DebugInfo/PDB/PDBSymbolBlock.h" 23 #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" 24 #include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h" 25 #include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h" 26 #include "llvm/DebugInfo/PDB/PDBSymbolCustom.h" 27 #include "llvm/DebugInfo/PDB/PDBSymbolData.h" 28 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" 29 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" 30 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h" 31 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h" 32 #include "llvm/DebugInfo/PDB/PDBSymbolLabel.h" 33 #include "llvm/DebugInfo/PDB/PDBSymbolPublicSymbol.h" 34 #include "llvm/DebugInfo/PDB/PDBSymbolThunk.h" 35 #include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h" 36 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h" 37 #include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h" 38 #include "llvm/DebugInfo/PDB/PDBSymbolTypeCustom.h" 39 #include "llvm/DebugInfo/PDB/PDBSymbolTypeDimension.h" 40 #include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h" 41 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFriend.h" 42 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h" 43 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h" 44 #include "llvm/DebugInfo/PDB/PDBSymbolTypeManaged.h" 45 #include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h" 46 #include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h" 47 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" 48 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h" 49 #include "llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h" 50 #include "llvm/DebugInfo/PDB/PDBSymbolUnknown.h" 51 #include "llvm/DebugInfo/PDB/PDBSymbolUsingNamespace.h" 52 #include "llvm/DebugInfo/PDB/PDBTypes.h" 53 #include "gtest/gtest.h" 54 using namespace llvm; 55 using namespace llvm::pdb; 56 57 namespace { 58 59 #define MOCK_SYMBOL_ACCESSOR(Func) \ 60 decltype(std::declval<IPDBRawSymbol>().Func()) Func() const override { \ 61 typedef decltype(IPDBRawSymbol::Func()) ReturnType; \ 62 return ReturnType(); \ 63 } 64 65 class MockSession : public IPDBSession { 66 uint64_t getLoadAddress() const override { return 0; } 67 bool setLoadAddress(uint64_t Address) override { return false; } 68 std::unique_ptr<PDBSymbolExe> getGlobalScope() override { return nullptr; } 69 std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override { 70 return nullptr; 71 } 72 std::unique_ptr<IPDBSourceFile> 73 getSourceFileById(uint32_t SymbolId) const override { 74 return nullptr; 75 } 76 77 std::unique_ptr<PDBSymbol> 78 findSymbolByAddress(uint64_t Address, PDB_SymType Type) const override { 79 return nullptr; 80 } 81 std::unique_ptr<IPDBEnumLineNumbers> 82 findLineNumbers(const PDBSymbolCompiland &Compiland, 83 const IPDBSourceFile &File) const override { 84 return nullptr; 85 } 86 std::unique_ptr<IPDBEnumLineNumbers> 87 findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override { 88 return nullptr; 89 } 90 std::unique_ptr<IPDBEnumSourceFiles> 91 findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, 92 PDB_NameSearchFlags Flags) const override { 93 return nullptr; 94 } 95 std::unique_ptr<IPDBSourceFile> 96 findOneSourceFile(const PDBSymbolCompiland *Compiland, 97 llvm::StringRef Pattern, 98 PDB_NameSearchFlags Flags) const override { 99 return nullptr; 100 } 101 std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>> 102 findCompilandsForSourceFile(llvm::StringRef Pattern, 103 PDB_NameSearchFlags Flags) const override { 104 return nullptr; 105 } 106 std::unique_ptr<PDBSymbolCompiland> 107 findOneCompilandForSourceFile(llvm::StringRef Pattern, 108 PDB_NameSearchFlags Flags) const override { 109 return nullptr; 110 } 111 112 std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const override { 113 return nullptr; 114 } 115 std::unique_ptr<IPDBEnumSourceFiles> getSourceFilesForCompiland( 116 const PDBSymbolCompiland &Compiland) const override { 117 return nullptr; 118 } 119 120 std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const override { 121 return nullptr; 122 } 123 124 std::unique_ptr<IPDBEnumTables> getEnumTables() const override { 125 return nullptr; 126 } 127 }; 128 129 class MockRawSymbol : public IPDBRawSymbol { 130 public: 131 MockRawSymbol(PDB_SymType SymType) 132 : Type(SymType) {} 133 134 void dump(raw_ostream &OS, int Indent) const override {} 135 136 std::unique_ptr<IPDBEnumSymbols> 137 findChildren(PDB_SymType Type) const override { 138 return nullptr; 139 } 140 std::unique_ptr<IPDBEnumSymbols> 141 findChildren(PDB_SymType Type, StringRef Name, 142 PDB_NameSearchFlags Flags) const override { 143 return nullptr; 144 } 145 std::unique_ptr<IPDBEnumSymbols> 146 findChildrenByAddr(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, 147 uint32_t Section, uint32_t Offset) const override { 148 return nullptr; 149 } 150 std::unique_ptr<IPDBEnumSymbols> 151 findChildrenByVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, 152 uint64_t VA) const override { 153 return nullptr; 154 } 155 std::unique_ptr<IPDBEnumSymbols> 156 findChildrenByRVA(PDB_SymType Type, StringRef Name, PDB_NameSearchFlags Flags, 157 uint32_t RVA) const override { 158 return nullptr; 159 } 160 std::unique_ptr<IPDBEnumSymbols> 161 findInlineFramesByAddr(uint32_t Section, uint32_t Offset) const override { 162 return nullptr; 163 } 164 std::unique_ptr<IPDBEnumSymbols> 165 findInlineFramesByRVA(uint32_t RVA) const override { 166 return nullptr; 167 } 168 std::unique_ptr<IPDBEnumSymbols> 169 findInlineFramesByVA(uint64_t VA) const override { 170 return nullptr; 171 } 172 std::unique_ptr<IPDBEnumLineNumbers> findInlineeLines() const override { 173 return nullptr; 174 } 175 std::unique_ptr<IPDBEnumLineNumbers> 176 findInlineeLinesByAddr(uint32_t Section, uint32_t Offset, 177 uint32_t Length) const override { 178 return nullptr; 179 } 180 std::unique_ptr<IPDBEnumLineNumbers> 181 findInlineeLinesByRVA(uint32_t RVA, uint32_t Length) const override { 182 return nullptr; 183 } 184 std::unique_ptr<IPDBEnumLineNumbers> 185 findInlineeLinesByVA(uint64_t VA, uint32_t Length) const override { 186 return nullptr; 187 } 188 189 void getDataBytes(llvm::SmallVector<uint8_t, 32> &bytes) const override {} 190 void getFrontEndVersion(VersionInfo &Version) const override {} 191 void getBackEndVersion(VersionInfo &Version) const override {} 192 193 PDB_SymType getSymTag() const override { return Type; } 194 195 std::string getUndecoratedNameEx(PDB_UndnameFlags Flags) const override { 196 return {}; 197 } 198 199 std::unique_ptr<IPDBLineNumber> getSrcLineOnTypeDefn() const override { 200 return nullptr; 201 } 202 203 MOCK_SYMBOL_ACCESSOR(getAccess) 204 MOCK_SYMBOL_ACCESSOR(getAddressOffset) 205 MOCK_SYMBOL_ACCESSOR(getAddressSection) 206 MOCK_SYMBOL_ACCESSOR(getAge) 207 MOCK_SYMBOL_ACCESSOR(getArrayIndexTypeId) 208 MOCK_SYMBOL_ACCESSOR(getBaseDataOffset) 209 MOCK_SYMBOL_ACCESSOR(getBaseDataSlot) 210 MOCK_SYMBOL_ACCESSOR(getBaseSymbolId) 211 MOCK_SYMBOL_ACCESSOR(getBuiltinType) 212 MOCK_SYMBOL_ACCESSOR(getBitPosition) 213 MOCK_SYMBOL_ACCESSOR(getCallingConvention) 214 MOCK_SYMBOL_ACCESSOR(getClassParentId) 215 MOCK_SYMBOL_ACCESSOR(getCompilerName) 216 MOCK_SYMBOL_ACCESSOR(getCount) 217 MOCK_SYMBOL_ACCESSOR(getCountLiveRanges) 218 MOCK_SYMBOL_ACCESSOR(getLanguage) 219 MOCK_SYMBOL_ACCESSOR(getLexicalParentId) 220 MOCK_SYMBOL_ACCESSOR(getLibraryName) 221 MOCK_SYMBOL_ACCESSOR(getLiveRangeStartAddressOffset) 222 MOCK_SYMBOL_ACCESSOR(getLiveRangeStartAddressSection) 223 MOCK_SYMBOL_ACCESSOR(getLiveRangeStartRelativeVirtualAddress) 224 MOCK_SYMBOL_ACCESSOR(getLocalBasePointerRegisterId) 225 MOCK_SYMBOL_ACCESSOR(getLowerBoundId) 226 MOCK_SYMBOL_ACCESSOR(getMemorySpaceKind) 227 MOCK_SYMBOL_ACCESSOR(getName) 228 MOCK_SYMBOL_ACCESSOR(getNumberOfAcceleratorPointerTags) 229 MOCK_SYMBOL_ACCESSOR(getNumberOfColumns) 230 MOCK_SYMBOL_ACCESSOR(getNumberOfModifiers) 231 MOCK_SYMBOL_ACCESSOR(getNumberOfRegisterIndices) 232 MOCK_SYMBOL_ACCESSOR(getNumberOfRows) 233 MOCK_SYMBOL_ACCESSOR(getObjectFileName) 234 MOCK_SYMBOL_ACCESSOR(getOemId) 235 MOCK_SYMBOL_ACCESSOR(getOemSymbolId) 236 MOCK_SYMBOL_ACCESSOR(getOffsetInUdt) 237 MOCK_SYMBOL_ACCESSOR(getPlatform) 238 MOCK_SYMBOL_ACCESSOR(getRank) 239 MOCK_SYMBOL_ACCESSOR(getRegisterId) 240 MOCK_SYMBOL_ACCESSOR(getRegisterType) 241 MOCK_SYMBOL_ACCESSOR(getRelativeVirtualAddress) 242 MOCK_SYMBOL_ACCESSOR(getSamplerSlot) 243 MOCK_SYMBOL_ACCESSOR(getSignature) 244 MOCK_SYMBOL_ACCESSOR(getSizeInUdt) 245 MOCK_SYMBOL_ACCESSOR(getSlot) 246 MOCK_SYMBOL_ACCESSOR(getSourceFileName) 247 MOCK_SYMBOL_ACCESSOR(getStride) 248 MOCK_SYMBOL_ACCESSOR(getSubTypeId) 249 MOCK_SYMBOL_ACCESSOR(getSymbolsFileName) 250 MOCK_SYMBOL_ACCESSOR(getSymIndexId) 251 MOCK_SYMBOL_ACCESSOR(getTargetOffset) 252 MOCK_SYMBOL_ACCESSOR(getTargetRelativeVirtualAddress) 253 MOCK_SYMBOL_ACCESSOR(getTargetVirtualAddress) 254 MOCK_SYMBOL_ACCESSOR(getTargetSection) 255 MOCK_SYMBOL_ACCESSOR(getTextureSlot) 256 MOCK_SYMBOL_ACCESSOR(getTimeStamp) 257 MOCK_SYMBOL_ACCESSOR(getToken) 258 MOCK_SYMBOL_ACCESSOR(getTypeId) 259 MOCK_SYMBOL_ACCESSOR(getUavSlot) 260 MOCK_SYMBOL_ACCESSOR(getUndecoratedName) 261 MOCK_SYMBOL_ACCESSOR(getUnmodifiedTypeId) 262 MOCK_SYMBOL_ACCESSOR(getUpperBoundId) 263 MOCK_SYMBOL_ACCESSOR(getVirtualBaseDispIndex) 264 MOCK_SYMBOL_ACCESSOR(getVirtualBaseOffset) 265 MOCK_SYMBOL_ACCESSOR(getVirtualTableShapeId) 266 MOCK_SYMBOL_ACCESSOR(getDataKind) 267 MOCK_SYMBOL_ACCESSOR(getGuid) 268 MOCK_SYMBOL_ACCESSOR(getOffset) 269 MOCK_SYMBOL_ACCESSOR(getThisAdjust) 270 MOCK_SYMBOL_ACCESSOR(getVirtualBasePointerOffset) 271 MOCK_SYMBOL_ACCESSOR(getLocationType) 272 MOCK_SYMBOL_ACCESSOR(getMachineType) 273 MOCK_SYMBOL_ACCESSOR(getThunkOrdinal) 274 MOCK_SYMBOL_ACCESSOR(getLength) 275 MOCK_SYMBOL_ACCESSOR(getVirtualBaseTableType) 276 MOCK_SYMBOL_ACCESSOR(getLiveRangeLength) 277 MOCK_SYMBOL_ACCESSOR(getVirtualAddress) 278 MOCK_SYMBOL_ACCESSOR(getUdtKind) 279 MOCK_SYMBOL_ACCESSOR(hasConstructor) 280 MOCK_SYMBOL_ACCESSOR(hasCustomCallingConvention) 281 MOCK_SYMBOL_ACCESSOR(hasFarReturn) 282 MOCK_SYMBOL_ACCESSOR(isCode) 283 MOCK_SYMBOL_ACCESSOR(isCompilerGenerated) 284 MOCK_SYMBOL_ACCESSOR(isConstType) 285 MOCK_SYMBOL_ACCESSOR(isEditAndContinueEnabled) 286 MOCK_SYMBOL_ACCESSOR(isFunction) 287 MOCK_SYMBOL_ACCESSOR(getAddressTaken) 288 MOCK_SYMBOL_ACCESSOR(getNoStackOrdering) 289 MOCK_SYMBOL_ACCESSOR(hasAlloca) 290 MOCK_SYMBOL_ACCESSOR(hasAssignmentOperator) 291 MOCK_SYMBOL_ACCESSOR(hasCTypes) 292 MOCK_SYMBOL_ACCESSOR(hasCastOperator) 293 MOCK_SYMBOL_ACCESSOR(hasDebugInfo) 294 MOCK_SYMBOL_ACCESSOR(hasEH) 295 MOCK_SYMBOL_ACCESSOR(hasEHa) 296 MOCK_SYMBOL_ACCESSOR(hasFramePointer) 297 MOCK_SYMBOL_ACCESSOR(hasInlAsm) 298 MOCK_SYMBOL_ACCESSOR(hasInlineAttribute) 299 MOCK_SYMBOL_ACCESSOR(hasInterruptReturn) 300 MOCK_SYMBOL_ACCESSOR(hasLongJump) 301 MOCK_SYMBOL_ACCESSOR(hasManagedCode) 302 MOCK_SYMBOL_ACCESSOR(hasNestedTypes) 303 MOCK_SYMBOL_ACCESSOR(hasNoInlineAttribute) 304 MOCK_SYMBOL_ACCESSOR(hasNoReturnAttribute) 305 MOCK_SYMBOL_ACCESSOR(hasOptimizedCodeDebugInfo) 306 MOCK_SYMBOL_ACCESSOR(hasOverloadedOperator) 307 MOCK_SYMBOL_ACCESSOR(hasSEH) 308 MOCK_SYMBOL_ACCESSOR(hasSecurityChecks) 309 MOCK_SYMBOL_ACCESSOR(hasSetJump) 310 MOCK_SYMBOL_ACCESSOR(hasStrictGSCheck) 311 MOCK_SYMBOL_ACCESSOR(isAcceleratorGroupSharedLocal) 312 MOCK_SYMBOL_ACCESSOR(isAcceleratorPointerTagLiveRange) 313 MOCK_SYMBOL_ACCESSOR(isAcceleratorStubFunction) 314 MOCK_SYMBOL_ACCESSOR(isAggregated) 315 MOCK_SYMBOL_ACCESSOR(isIntroVirtualFunction) 316 MOCK_SYMBOL_ACCESSOR(isCVTCIL) 317 MOCK_SYMBOL_ACCESSOR(isConstructorVirtualBase) 318 MOCK_SYMBOL_ACCESSOR(isCxxReturnUdt) 319 MOCK_SYMBOL_ACCESSOR(isDataAligned) 320 MOCK_SYMBOL_ACCESSOR(isHLSLData) 321 MOCK_SYMBOL_ACCESSOR(isHotpatchable) 322 MOCK_SYMBOL_ACCESSOR(isIndirectVirtualBaseClass) 323 MOCK_SYMBOL_ACCESSOR(isInterfaceUdt) 324 MOCK_SYMBOL_ACCESSOR(isIntrinsic) 325 MOCK_SYMBOL_ACCESSOR(isLTCG) 326 MOCK_SYMBOL_ACCESSOR(isLocationControlFlowDependent) 327 MOCK_SYMBOL_ACCESSOR(isMSILNetmodule) 328 MOCK_SYMBOL_ACCESSOR(isMatrixRowMajor) 329 MOCK_SYMBOL_ACCESSOR(isManagedCode) 330 MOCK_SYMBOL_ACCESSOR(isMSILCode) 331 MOCK_SYMBOL_ACCESSOR(isMultipleInheritance) 332 MOCK_SYMBOL_ACCESSOR(isNaked) 333 MOCK_SYMBOL_ACCESSOR(isNested) 334 MOCK_SYMBOL_ACCESSOR(isOptimizedAway) 335 MOCK_SYMBOL_ACCESSOR(isPacked) 336 MOCK_SYMBOL_ACCESSOR(isPointerBasedOnSymbolValue) 337 MOCK_SYMBOL_ACCESSOR(isPointerToDataMember) 338 MOCK_SYMBOL_ACCESSOR(isPointerToMemberFunction) 339 MOCK_SYMBOL_ACCESSOR(isPureVirtual) 340 MOCK_SYMBOL_ACCESSOR(isRValueReference) 341 MOCK_SYMBOL_ACCESSOR(isRefUdt) 342 MOCK_SYMBOL_ACCESSOR(isReference) 343 MOCK_SYMBOL_ACCESSOR(isRestrictedType) 344 MOCK_SYMBOL_ACCESSOR(isReturnValue) 345 MOCK_SYMBOL_ACCESSOR(isSafeBuffers) 346 MOCK_SYMBOL_ACCESSOR(isScoped) 347 MOCK_SYMBOL_ACCESSOR(isSdl) 348 MOCK_SYMBOL_ACCESSOR(isSingleInheritance) 349 MOCK_SYMBOL_ACCESSOR(isSplitted) 350 MOCK_SYMBOL_ACCESSOR(isStatic) 351 MOCK_SYMBOL_ACCESSOR(hasPrivateSymbols) 352 MOCK_SYMBOL_ACCESSOR(isUnalignedType) 353 MOCK_SYMBOL_ACCESSOR(isUnreached) 354 MOCK_SYMBOL_ACCESSOR(isValueUdt) 355 MOCK_SYMBOL_ACCESSOR(isVirtual) 356 MOCK_SYMBOL_ACCESSOR(isVirtualBaseClass) 357 MOCK_SYMBOL_ACCESSOR(isVirtualInheritance) 358 MOCK_SYMBOL_ACCESSOR(isVolatileType) 359 MOCK_SYMBOL_ACCESSOR(getValue) 360 MOCK_SYMBOL_ACCESSOR(wasInlined) 361 MOCK_SYMBOL_ACCESSOR(getUnused) 362 363 private: 364 PDB_SymType Type; 365 }; 366 367 class PDBApiTest : public testing::Test { 368 public: 369 std::unordered_map<PDB_SymType, std::unique_ptr<PDBSymbol>> SymbolMap; 370 371 void SetUp() override { 372 Session.reset(new MockSession()); 373 374 InsertItemWithTag(PDB_SymType::None); 375 InsertItemWithTag(PDB_SymType::Exe); 376 InsertItemWithTag(PDB_SymType::Compiland); 377 InsertItemWithTag(PDB_SymType::CompilandDetails); 378 InsertItemWithTag(PDB_SymType::CompilandEnv); 379 InsertItemWithTag(PDB_SymType::Function); 380 InsertItemWithTag(PDB_SymType::Block); 381 InsertItemWithTag(PDB_SymType::Data); 382 InsertItemWithTag(PDB_SymType::Annotation); 383 InsertItemWithTag(PDB_SymType::Label); 384 InsertItemWithTag(PDB_SymType::PublicSymbol); 385 InsertItemWithTag(PDB_SymType::UDT); 386 InsertItemWithTag(PDB_SymType::Enum); 387 InsertItemWithTag(PDB_SymType::FunctionSig); 388 InsertItemWithTag(PDB_SymType::PointerType); 389 InsertItemWithTag(PDB_SymType::ArrayType); 390 InsertItemWithTag(PDB_SymType::BuiltinType); 391 InsertItemWithTag(PDB_SymType::Typedef); 392 InsertItemWithTag(PDB_SymType::BaseClass); 393 InsertItemWithTag(PDB_SymType::Friend); 394 InsertItemWithTag(PDB_SymType::FunctionArg); 395 InsertItemWithTag(PDB_SymType::FuncDebugStart); 396 InsertItemWithTag(PDB_SymType::FuncDebugEnd); 397 InsertItemWithTag(PDB_SymType::UsingNamespace); 398 InsertItemWithTag(PDB_SymType::VTableShape); 399 InsertItemWithTag(PDB_SymType::VTable); 400 InsertItemWithTag(PDB_SymType::Custom); 401 InsertItemWithTag(PDB_SymType::Thunk); 402 InsertItemWithTag(PDB_SymType::CustomType); 403 InsertItemWithTag(PDB_SymType::ManagedType); 404 InsertItemWithTag(PDB_SymType::Dimension); 405 InsertItemWithTag(PDB_SymType::Max); 406 } 407 408 template <class ExpectedType> void VerifyDyncast(PDB_SymType Tag) { 409 for (auto item = SymbolMap.begin(); item != SymbolMap.end(); ++item) { 410 EXPECT_EQ(item->first == Tag, llvm::isa<ExpectedType>(*item->second)); 411 } 412 } 413 414 void VerifyUnknownDyncasts() { 415 for (auto item = SymbolMap.begin(); item != SymbolMap.end(); ++item) { 416 bool should_match = false; 417 if (item->first == PDB_SymType::None || item->first >= PDB_SymType::Max) 418 should_match = true; 419 420 EXPECT_EQ(should_match, llvm::isa<PDBSymbolUnknown>(*item->second)); 421 } 422 } 423 424 private: 425 std::unique_ptr<IPDBSession> Session; 426 427 void InsertItemWithTag(PDB_SymType Tag) { 428 auto RawSymbol = llvm::make_unique<MockRawSymbol>(Tag); 429 auto Symbol = PDBSymbol::create(*Session, std::move(RawSymbol)); 430 SymbolMap.insert(std::make_pair(Tag, std::move(Symbol))); 431 } 432 }; 433 434 TEST_F(PDBApiTest, Dyncast) { 435 436 // Most of the types have a one-to-one mapping between Tag and concrete type. 437 VerifyDyncast<PDBSymbolExe>(PDB_SymType::Exe); 438 VerifyDyncast<PDBSymbolCompiland>(PDB_SymType::Compiland); 439 VerifyDyncast<PDBSymbolCompilandDetails>(PDB_SymType::CompilandDetails); 440 VerifyDyncast<PDBSymbolCompilandEnv>(PDB_SymType::CompilandEnv); 441 VerifyDyncast<PDBSymbolFunc>(PDB_SymType::Function); 442 VerifyDyncast<PDBSymbolBlock>(PDB_SymType::Block); 443 VerifyDyncast<PDBSymbolData>(PDB_SymType::Data); 444 VerifyDyncast<PDBSymbolAnnotation>(PDB_SymType::Annotation); 445 VerifyDyncast<PDBSymbolLabel>(PDB_SymType::Label); 446 VerifyDyncast<PDBSymbolPublicSymbol>(PDB_SymType::PublicSymbol); 447 VerifyDyncast<PDBSymbolTypeUDT>(PDB_SymType::UDT); 448 VerifyDyncast<PDBSymbolTypeEnum>(PDB_SymType::Enum); 449 VerifyDyncast<PDBSymbolTypeFunctionSig>(PDB_SymType::FunctionSig); 450 VerifyDyncast<PDBSymbolTypePointer>(PDB_SymType::PointerType); 451 VerifyDyncast<PDBSymbolTypeArray>(PDB_SymType::ArrayType); 452 VerifyDyncast<PDBSymbolTypeBuiltin>(PDB_SymType::BuiltinType); 453 VerifyDyncast<PDBSymbolTypeTypedef>(PDB_SymType::Typedef); 454 VerifyDyncast<PDBSymbolTypeBaseClass>(PDB_SymType::BaseClass); 455 VerifyDyncast<PDBSymbolTypeFriend>(PDB_SymType::Friend); 456 VerifyDyncast<PDBSymbolTypeFunctionArg>(PDB_SymType::FunctionArg); 457 VerifyDyncast<PDBSymbolFuncDebugStart>(PDB_SymType::FuncDebugStart); 458 VerifyDyncast<PDBSymbolFuncDebugEnd>(PDB_SymType::FuncDebugEnd); 459 VerifyDyncast<PDBSymbolUsingNamespace>(PDB_SymType::UsingNamespace); 460 VerifyDyncast<PDBSymbolTypeVTableShape>(PDB_SymType::VTableShape); 461 VerifyDyncast<PDBSymbolTypeVTable>(PDB_SymType::VTable); 462 VerifyDyncast<PDBSymbolCustom>(PDB_SymType::Custom); 463 VerifyDyncast<PDBSymbolThunk>(PDB_SymType::Thunk); 464 VerifyDyncast<PDBSymbolTypeCustom>(PDB_SymType::CustomType); 465 VerifyDyncast<PDBSymbolTypeManaged>(PDB_SymType::ManagedType); 466 VerifyDyncast<PDBSymbolTypeDimension>(PDB_SymType::Dimension); 467 468 VerifyUnknownDyncasts(); 469 } 470 471 } // end anonymous namespace 472