blob: 8e233ca151617db68a73a35ea5c68f2084eb37db [file] [log] [blame]
Aaron Smith523de052018-03-22 04:08:15 +00001//===- 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 Smith523de052018-03-22 04:08:15 +000010#include "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h"
Aaron Smithc0a5c012018-04-10 15:25:04 +000011#include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
Aaron Smith523de052018-03-22 04:08:15 +000012#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
13#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
14
15using namespace llvm;
16using namespace llvm::pdb;
17
18DIASectionContrib::DIASectionContrib(const DIASession &PDBSession,
19 CComPtr<IDiaSectionContrib> DiaSection)
20 : Session(PDBSession), Section(DiaSection) {}
21
22std::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 Turner7999b4f2018-09-05 23:30:38 +000028 return PDBSymbol::createAs<PDBSymbolCompiland>(Session, std::move(RawSymbol));
Aaron Smith523de052018-03-22 04:08:15 +000029}
30
31template <typename ArgType>
Aaron Smithc0a5c012018-04-10 15:25:04 +000032ArgType
33PrivateGetDIAValue(IDiaSectionContrib *Section,
34 HRESULT (__stdcall IDiaSectionContrib::*Method)(ArgType *)) {
Aaron Smith523de052018-03-22 04:08:15 +000035 ArgType Value;
36 if (S_OK == (Section->*Method)(&Value))
37 return static_cast<ArgType>(Value);
38
39 return ArgType();
40}
41
Aaron Smith523de052018-03-22 04:08:15 +000042uint32_t DIASectionContrib::getAddressSection() const {
43 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressSection);
44}
45
46uint32_t DIASectionContrib::getAddressOffset() const {
47 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressOffset);
48}
49
50uint64_t DIASectionContrib::getVirtualAddress() const {
51 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_virtualAddress);
52}
53
54uint32_t DIASectionContrib::getRelativeVirtualAddress() const {
55 return PrivateGetDIAValue(Section,
56 &IDiaSectionContrib::get_relativeVirtualAddress);
57}
Aaron Smithc0a5c012018-04-10 15:25:04 +000058
Aaron Smith523de052018-03-22 04:08:15 +000059uint32_t DIASectionContrib::getLength() const {
60 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_length);
61}
62
63bool DIASectionContrib::isNotPaged() const {
64 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notPaged);
65}
66
67bool DIASectionContrib::hasCode() const {
68 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code);
69}
70
71bool DIASectionContrib::hasCode16Bit() const {
72 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code16bit);
73}
74
75bool DIASectionContrib::hasInitializedData() const {
76 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_initializedData);
77}
78
79bool DIASectionContrib::hasUninitializedData() const {
Aaron Smithc0a5c012018-04-10 15:25:04 +000080 return PrivateGetDIAValue(Section,
81 &IDiaSectionContrib::get_uninitializedData);
Aaron Smith523de052018-03-22 04:08:15 +000082}
83
84bool DIASectionContrib::isRemoved() const {
85 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_remove);
86}
87
88bool DIASectionContrib::hasComdat() const {
89 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_comdat);
90}
91
92bool DIASectionContrib::isDiscardable() const {
93 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_discardable);
94}
95
96bool DIASectionContrib::isNotCached() const {
97 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notCached);
98}
99
100bool DIASectionContrib::isShared() const {
101 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_share);
102}
103
104bool DIASectionContrib::isExecutable() const {
105 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_execute);
106}
107
108bool DIASectionContrib::isReadable() const {
109 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_read);
110}
111
112bool DIASectionContrib::isWritable() const {
113 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_write);
114}
115
116uint32_t DIASectionContrib::getDataCrc32() const {
117 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_dataCrc);
118}
119
120uint32_t DIASectionContrib::getRelocationsCrc32() const {
121 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_relocationsCrc);
122}
123
124uint32_t DIASectionContrib::getCompilandId() const {
125 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_compilandId);
126}