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
10 #include "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h"
11 #include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
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
DIASectionContrib(const DIASession & PDBSession,CComPtr<IDiaSectionContrib> DiaSection)18 DIASectionContrib::DIASectionContrib(const DIASession &PDBSession,
19 CComPtr<IDiaSectionContrib> DiaSection)
20 : Session(PDBSession), Section(DiaSection) {}
21
getCompiland() const22 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);
28 return llvm::make_unique<PDBSymbolCompiland>(Session, std::move(RawSymbol));
29 }
30
31 template <typename ArgType>
32 ArgType
PrivateGetDIAValue(IDiaSectionContrib * Section,HRESULT (__stdcall IDiaSectionContrib::* Method)(ArgType *))33 PrivateGetDIAValue(IDiaSectionContrib *Section,
34 HRESULT (__stdcall IDiaSectionContrib::*Method)(ArgType *)) {
35 ArgType Value;
36 if (S_OK == (Section->*Method)(&Value))
37 return static_cast<ArgType>(Value);
38
39 return ArgType();
40 }
41
getAddressSection() const42 uint32_t DIASectionContrib::getAddressSection() const {
43 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressSection);
44 }
45
getAddressOffset() const46 uint32_t DIASectionContrib::getAddressOffset() const {
47 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressOffset);
48 }
49
getVirtualAddress() const50 uint64_t DIASectionContrib::getVirtualAddress() const {
51 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_virtualAddress);
52 }
53
getRelativeVirtualAddress() const54 uint32_t DIASectionContrib::getRelativeVirtualAddress() const {
55 return PrivateGetDIAValue(Section,
56 &IDiaSectionContrib::get_relativeVirtualAddress);
57 }
58
getLength() const59 uint32_t DIASectionContrib::getLength() const {
60 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_length);
61 }
62
isNotPaged() const63 bool DIASectionContrib::isNotPaged() const {
64 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notPaged);
65 }
66
hasCode() const67 bool DIASectionContrib::hasCode() const {
68 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code);
69 }
70
hasCode16Bit() const71 bool DIASectionContrib::hasCode16Bit() const {
72 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code16bit);
73 }
74
hasInitializedData() const75 bool DIASectionContrib::hasInitializedData() const {
76 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_initializedData);
77 }
78
hasUninitializedData() const79 bool DIASectionContrib::hasUninitializedData() const {
80 return PrivateGetDIAValue(Section,
81 &IDiaSectionContrib::get_uninitializedData);
82 }
83
isRemoved() const84 bool DIASectionContrib::isRemoved() const {
85 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_remove);
86 }
87
hasComdat() const88 bool DIASectionContrib::hasComdat() const {
89 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_comdat);
90 }
91
isDiscardable() const92 bool DIASectionContrib::isDiscardable() const {
93 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_discardable);
94 }
95
isNotCached() const96 bool DIASectionContrib::isNotCached() const {
97 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notCached);
98 }
99
isShared() const100 bool DIASectionContrib::isShared() const {
101 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_share);
102 }
103
isExecutable() const104 bool DIASectionContrib::isExecutable() const {
105 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_execute);
106 }
107
isReadable() const108 bool DIASectionContrib::isReadable() const {
109 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_read);
110 }
111
isWritable() const112 bool DIASectionContrib::isWritable() const {
113 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_write);
114 }
115
getDataCrc32() const116 uint32_t DIASectionContrib::getDataCrc32() const {
117 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_dataCrc);
118 }
119
getRelocationsCrc32() const120 uint32_t DIASectionContrib::getRelocationsCrc32() const {
121 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_relocationsCrc);
122 }
123
getCompilandId() const124 uint32_t DIASectionContrib::getCompilandId() const {
125 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_compilandId);
126 }
127