blob: 6f395a99e5838d37641712a991a0e77f091c0510 [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
10#include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
11#include "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h"
12#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);
28 return llvm::make_unique<PDBSymbolCompiland>(Session, std::move(RawSymbol));
29}
30
31template <typename ArgType>
32ArgType PrivateGetDIAValue(
33 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
42template <typename ArgType, typename RetType>
43RetType PrivateGetDIAValue(
44 IDiaSectionContrib *Section,
45 HRESULT(__stdcall IDiaSectionContrib::*Method)(ArgType *)) {
46 ArgType Value;
47 if (S_OK == (Section->*Method)(&Value))
48 return static_cast<RetType>(Value);
49
50 return RetType();
51}
52
53uint32_t DIASectionContrib::getAddressSection() const {
54 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressSection);
55}
56
57uint32_t DIASectionContrib::getAddressOffset() const {
58 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressOffset);
59}
60
61uint64_t DIASectionContrib::getVirtualAddress() const {
62 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_virtualAddress);
63}
64
65uint32_t DIASectionContrib::getRelativeVirtualAddress() const {
66 return PrivateGetDIAValue(Section,
67 &IDiaSectionContrib::get_relativeVirtualAddress);
68}
69uint32_t DIASectionContrib::getLength() const {
70 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_length);
71}
72
73bool DIASectionContrib::isNotPaged() const {
74 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notPaged);
75}
76
77bool DIASectionContrib::hasCode() const {
78 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code);
79}
80
81bool DIASectionContrib::hasCode16Bit() const {
82 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code16bit);
83}
84
85bool DIASectionContrib::hasInitializedData() const {
86 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_initializedData);
87}
88
89bool DIASectionContrib::hasUninitializedData() const {
90 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_uninitializedData);
91}
92
93bool DIASectionContrib::isRemoved() const {
94 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_remove);
95}
96
97bool DIASectionContrib::hasComdat() const {
98 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_comdat);
99}
100
101bool DIASectionContrib::isDiscardable() const {
102 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_discardable);
103}
104
105bool DIASectionContrib::isNotCached() const {
106 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notCached);
107}
108
109bool DIASectionContrib::isShared() const {
110 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_share);
111}
112
113bool DIASectionContrib::isExecutable() const {
114 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_execute);
115}
116
117bool DIASectionContrib::isReadable() const {
118 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_read);
119}
120
121bool DIASectionContrib::isWritable() const {
122 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_write);
123}
124
125uint32_t DIASectionContrib::getDataCrc32() const {
126 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_dataCrc);
127}
128
129uint32_t DIASectionContrib::getRelocationsCrc32() const {
130 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_relocationsCrc);
131}
132
133uint32_t DIASectionContrib::getCompilandId() const {
134 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_compilandId);
135}