Aaron Smith | 523de05 | 2018-03-22 04:08:15 +0000 | [diff] [blame] | 1 | //===- DIASectionContrib.cpp - DIA impl. of IPDBSectionContrib ---- C++ -*-===// |
| 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 | |
Aaron Smith | 523de05 | 2018-03-22 04:08:15 +0000 | [diff] [blame] | 10 | #include "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h" |
Aaron Smith | c0a5c01 | 2018-04-10 15:25:04 +0000 | [diff] [blame] | 11 | #include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h" |
Aaron Smith | 523de05 | 2018-03-22 04:08:15 +0000 | [diff] [blame] | 12 | #include "llvm/DebugInfo/PDB/DIA/DIASession.h" |
| 13 | #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" |
| 14 | |
| 15 | using namespace llvm; |
| 16 | using namespace llvm::pdb; |
| 17 | |
| 18 | DIASectionContrib::DIASectionContrib(const DIASession &PDBSession, |
| 19 | CComPtr<IDiaSectionContrib> DiaSection) |
| 20 | : Session(PDBSession), Section(DiaSection) {} |
| 21 | |
| 22 | std::unique_ptr<PDBSymbolCompiland> DIASectionContrib::getCompiland() const { |
| 23 | CComPtr<IDiaSymbol> Symbol; |
| 24 | if (FAILED(Section->get_compiland(&Symbol))) |
| 25 | return nullptr; |
| 26 | |
| 27 | auto RawSymbol = llvm::make_unique<DIARawSymbol>(Session, Symbol); |
Zachary Turner | 7999b4f | 2018-09-05 23:30:38 +0000 | [diff] [blame] | 28 | return PDBSymbol::createAs<PDBSymbolCompiland>(Session, std::move(RawSymbol)); |
Aaron Smith | 523de05 | 2018-03-22 04:08:15 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | template <typename ArgType> |
Aaron Smith | c0a5c01 | 2018-04-10 15:25:04 +0000 | [diff] [blame] | 32 | ArgType |
| 33 | PrivateGetDIAValue(IDiaSectionContrib *Section, |
| 34 | HRESULT (__stdcall IDiaSectionContrib::*Method)(ArgType *)) { |
Aaron Smith | 523de05 | 2018-03-22 04:08:15 +0000 | [diff] [blame] | 35 | ArgType Value; |
| 36 | if (S_OK == (Section->*Method)(&Value)) |
| 37 | return static_cast<ArgType>(Value); |
| 38 | |
| 39 | return ArgType(); |
| 40 | } |
| 41 | |
Aaron Smith | 523de05 | 2018-03-22 04:08:15 +0000 | [diff] [blame] | 42 | uint32_t DIASectionContrib::getAddressSection() const { |
| 43 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressSection); |
| 44 | } |
| 45 | |
| 46 | uint32_t DIASectionContrib::getAddressOffset() const { |
| 47 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressOffset); |
| 48 | } |
| 49 | |
| 50 | uint64_t DIASectionContrib::getVirtualAddress() const { |
| 51 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_virtualAddress); |
| 52 | } |
| 53 | |
| 54 | uint32_t DIASectionContrib::getRelativeVirtualAddress() const { |
| 55 | return PrivateGetDIAValue(Section, |
| 56 | &IDiaSectionContrib::get_relativeVirtualAddress); |
| 57 | } |
Aaron Smith | c0a5c01 | 2018-04-10 15:25:04 +0000 | [diff] [blame] | 58 | |
Aaron Smith | 523de05 | 2018-03-22 04:08:15 +0000 | [diff] [blame] | 59 | uint32_t DIASectionContrib::getLength() const { |
| 60 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_length); |
| 61 | } |
| 62 | |
| 63 | bool DIASectionContrib::isNotPaged() const { |
| 64 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notPaged); |
| 65 | } |
| 66 | |
| 67 | bool DIASectionContrib::hasCode() const { |
| 68 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code); |
| 69 | } |
| 70 | |
| 71 | bool DIASectionContrib::hasCode16Bit() const { |
| 72 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code16bit); |
| 73 | } |
| 74 | |
| 75 | bool DIASectionContrib::hasInitializedData() const { |
| 76 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_initializedData); |
| 77 | } |
| 78 | |
| 79 | bool DIASectionContrib::hasUninitializedData() const { |
Aaron Smith | c0a5c01 | 2018-04-10 15:25:04 +0000 | [diff] [blame] | 80 | return PrivateGetDIAValue(Section, |
| 81 | &IDiaSectionContrib::get_uninitializedData); |
Aaron Smith | 523de05 | 2018-03-22 04:08:15 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | bool DIASectionContrib::isRemoved() const { |
| 85 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_remove); |
| 86 | } |
| 87 | |
| 88 | bool DIASectionContrib::hasComdat() const { |
| 89 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_comdat); |
| 90 | } |
| 91 | |
| 92 | bool DIASectionContrib::isDiscardable() const { |
| 93 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_discardable); |
| 94 | } |
| 95 | |
| 96 | bool DIASectionContrib::isNotCached() const { |
| 97 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notCached); |
| 98 | } |
| 99 | |
| 100 | bool DIASectionContrib::isShared() const { |
| 101 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_share); |
| 102 | } |
| 103 | |
| 104 | bool DIASectionContrib::isExecutable() const { |
| 105 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_execute); |
| 106 | } |
| 107 | |
| 108 | bool DIASectionContrib::isReadable() const { |
| 109 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_read); |
| 110 | } |
| 111 | |
| 112 | bool DIASectionContrib::isWritable() const { |
| 113 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_write); |
| 114 | } |
| 115 | |
| 116 | uint32_t DIASectionContrib::getDataCrc32() const { |
| 117 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_dataCrc); |
| 118 | } |
| 119 | |
| 120 | uint32_t DIASectionContrib::getRelocationsCrc32() const { |
| 121 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_relocationsCrc); |
| 122 | } |
| 123 | |
| 124 | uint32_t DIASectionContrib::getCompilandId() const { |
| 125 | return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_compilandId); |
| 126 | } |