xref: /llvm-project/llvm/lib/DebugInfo/PDB/DIA/DIASectionContrib.cpp (revision 7999b4fa48b31f67efa3662443a5c78343eb6f19)
1523de05aSAaron Smith //===- DIASectionContrib.cpp - DIA impl. of IPDBSectionContrib ---- C++ -*-===//
2523de05aSAaron Smith //
3523de05aSAaron Smith //                     The LLVM Compiler Infrastructure
4523de05aSAaron Smith //
5523de05aSAaron Smith // This file is distributed under the University of Illinois Open Source
6523de05aSAaron Smith // License. See LICENSE.TXT for details.
7523de05aSAaron Smith //
8523de05aSAaron Smith //===----------------------------------------------------------------------===//
9523de05aSAaron Smith 
10523de05aSAaron Smith #include "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h"
11c0a5c01aSAaron Smith #include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
12523de05aSAaron Smith #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
13523de05aSAaron Smith #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
14523de05aSAaron Smith 
15523de05aSAaron Smith using namespace llvm;
16523de05aSAaron Smith using namespace llvm::pdb;
17523de05aSAaron Smith 
18523de05aSAaron Smith DIASectionContrib::DIASectionContrib(const DIASession &PDBSession,
19523de05aSAaron Smith                                      CComPtr<IDiaSectionContrib> DiaSection)
20523de05aSAaron Smith   : Session(PDBSession), Section(DiaSection) {}
21523de05aSAaron Smith 
22523de05aSAaron Smith std::unique_ptr<PDBSymbolCompiland> DIASectionContrib::getCompiland() const {
23523de05aSAaron Smith   CComPtr<IDiaSymbol> Symbol;
24523de05aSAaron Smith   if (FAILED(Section->get_compiland(&Symbol)))
25523de05aSAaron Smith     return nullptr;
26523de05aSAaron Smith 
27523de05aSAaron Smith   auto RawSymbol = llvm::make_unique<DIARawSymbol>(Session, Symbol);
28*7999b4faSZachary Turner   return PDBSymbol::createAs<PDBSymbolCompiland>(Session, std::move(RawSymbol));
29523de05aSAaron Smith }
30523de05aSAaron Smith 
31523de05aSAaron Smith template <typename ArgType>
32c0a5c01aSAaron Smith ArgType
33c0a5c01aSAaron Smith PrivateGetDIAValue(IDiaSectionContrib *Section,
34523de05aSAaron Smith                    HRESULT (__stdcall IDiaSectionContrib::*Method)(ArgType *)) {
35523de05aSAaron Smith   ArgType Value;
36523de05aSAaron Smith   if (S_OK == (Section->*Method)(&Value))
37523de05aSAaron Smith     return static_cast<ArgType>(Value);
38523de05aSAaron Smith 
39523de05aSAaron Smith   return ArgType();
40523de05aSAaron Smith }
41523de05aSAaron Smith 
42523de05aSAaron Smith uint32_t DIASectionContrib::getAddressSection() const {
43523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressSection);
44523de05aSAaron Smith }
45523de05aSAaron Smith 
46523de05aSAaron Smith uint32_t DIASectionContrib::getAddressOffset() const {
47523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressOffset);
48523de05aSAaron Smith }
49523de05aSAaron Smith 
50523de05aSAaron Smith uint64_t DIASectionContrib::getVirtualAddress() const {
51523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_virtualAddress);
52523de05aSAaron Smith }
53523de05aSAaron Smith 
54523de05aSAaron Smith uint32_t DIASectionContrib::getRelativeVirtualAddress() const {
55523de05aSAaron Smith   return PrivateGetDIAValue(Section,
56523de05aSAaron Smith                             &IDiaSectionContrib::get_relativeVirtualAddress);
57523de05aSAaron Smith }
58c0a5c01aSAaron Smith 
59523de05aSAaron Smith uint32_t DIASectionContrib::getLength() const {
60523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_length);
61523de05aSAaron Smith }
62523de05aSAaron Smith 
63523de05aSAaron Smith bool DIASectionContrib::isNotPaged() const {
64523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notPaged);
65523de05aSAaron Smith }
66523de05aSAaron Smith 
67523de05aSAaron Smith bool DIASectionContrib::hasCode() const {
68523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code);
69523de05aSAaron Smith }
70523de05aSAaron Smith 
71523de05aSAaron Smith bool DIASectionContrib::hasCode16Bit() const {
72523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code16bit);
73523de05aSAaron Smith }
74523de05aSAaron Smith 
75523de05aSAaron Smith bool DIASectionContrib::hasInitializedData() const {
76523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_initializedData);
77523de05aSAaron Smith }
78523de05aSAaron Smith 
79523de05aSAaron Smith bool DIASectionContrib::hasUninitializedData() const {
80c0a5c01aSAaron Smith   return PrivateGetDIAValue(Section,
81c0a5c01aSAaron Smith                             &IDiaSectionContrib::get_uninitializedData);
82523de05aSAaron Smith }
83523de05aSAaron Smith 
84523de05aSAaron Smith bool DIASectionContrib::isRemoved() const {
85523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_remove);
86523de05aSAaron Smith }
87523de05aSAaron Smith 
88523de05aSAaron Smith bool DIASectionContrib::hasComdat() const {
89523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_comdat);
90523de05aSAaron Smith }
91523de05aSAaron Smith 
92523de05aSAaron Smith bool DIASectionContrib::isDiscardable() const {
93523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_discardable);
94523de05aSAaron Smith }
95523de05aSAaron Smith 
96523de05aSAaron Smith bool DIASectionContrib::isNotCached() const {
97523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notCached);
98523de05aSAaron Smith }
99523de05aSAaron Smith 
100523de05aSAaron Smith bool DIASectionContrib::isShared() const {
101523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_share);
102523de05aSAaron Smith }
103523de05aSAaron Smith 
104523de05aSAaron Smith bool DIASectionContrib::isExecutable() const {
105523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_execute);
106523de05aSAaron Smith }
107523de05aSAaron Smith 
108523de05aSAaron Smith bool DIASectionContrib::isReadable() const {
109523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_read);
110523de05aSAaron Smith }
111523de05aSAaron Smith 
112523de05aSAaron Smith bool DIASectionContrib::isWritable() const {
113523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_write);
114523de05aSAaron Smith }
115523de05aSAaron Smith 
116523de05aSAaron Smith uint32_t DIASectionContrib::getDataCrc32() const {
117523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_dataCrc);
118523de05aSAaron Smith }
119523de05aSAaron Smith 
120523de05aSAaron Smith uint32_t DIASectionContrib::getRelocationsCrc32() const {
121523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_relocationsCrc);
122523de05aSAaron Smith }
123523de05aSAaron Smith 
124523de05aSAaron Smith uint32_t DIASectionContrib::getCompilandId() const {
125523de05aSAaron Smith   return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_compilandId);
126523de05aSAaron Smith }
127