1523de05aSAaron Smith //===- DIASectionContrib.cpp - DIA impl. of IPDBSectionContrib ---- C++ -*-===//
2523de05aSAaron Smith //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6523de05aSAaron Smith //
7523de05aSAaron Smith //===----------------------------------------------------------------------===//
8523de05aSAaron Smith
9523de05aSAaron Smith #include "llvm/DebugInfo/PDB/DIA/DIASectionContrib.h"
10c0a5c01aSAaron Smith #include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
11523de05aSAaron Smith #include "llvm/DebugInfo/PDB/DIA/DIASession.h"
12523de05aSAaron Smith #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
13523de05aSAaron Smith
14523de05aSAaron Smith using namespace llvm;
15523de05aSAaron Smith using namespace llvm::pdb;
16523de05aSAaron Smith
DIASectionContrib(const DIASession & PDBSession,CComPtr<IDiaSectionContrib> DiaSection)17523de05aSAaron Smith DIASectionContrib::DIASectionContrib(const DIASession &PDBSession,
18523de05aSAaron Smith CComPtr<IDiaSectionContrib> DiaSection)
19523de05aSAaron Smith : Session(PDBSession), Section(DiaSection) {}
20523de05aSAaron Smith
getCompiland() const21523de05aSAaron Smith std::unique_ptr<PDBSymbolCompiland> DIASectionContrib::getCompiland() const {
22523de05aSAaron Smith CComPtr<IDiaSymbol> Symbol;
23523de05aSAaron Smith if (FAILED(Section->get_compiland(&Symbol)))
24523de05aSAaron Smith return nullptr;
25523de05aSAaron Smith
26*0eaee545SJonas Devlieghere auto RawSymbol = std::make_unique<DIARawSymbol>(Session, Symbol);
277999b4faSZachary Turner return PDBSymbol::createAs<PDBSymbolCompiland>(Session, std::move(RawSymbol));
28523de05aSAaron Smith }
29523de05aSAaron Smith
30523de05aSAaron Smith template <typename ArgType>
31c0a5c01aSAaron Smith ArgType
PrivateGetDIAValue(IDiaSectionContrib * Section,HRESULT (__stdcall IDiaSectionContrib::* Method)(ArgType *))32c0a5c01aSAaron Smith PrivateGetDIAValue(IDiaSectionContrib *Section,
33523de05aSAaron Smith HRESULT (__stdcall IDiaSectionContrib::*Method)(ArgType *)) {
34523de05aSAaron Smith ArgType Value;
35523de05aSAaron Smith if (S_OK == (Section->*Method)(&Value))
36523de05aSAaron Smith return static_cast<ArgType>(Value);
37523de05aSAaron Smith
38523de05aSAaron Smith return ArgType();
39523de05aSAaron Smith }
40523de05aSAaron Smith
getAddressSection() const41523de05aSAaron Smith uint32_t DIASectionContrib::getAddressSection() const {
42523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressSection);
43523de05aSAaron Smith }
44523de05aSAaron Smith
getAddressOffset() const45523de05aSAaron Smith uint32_t DIASectionContrib::getAddressOffset() const {
46523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressOffset);
47523de05aSAaron Smith }
48523de05aSAaron Smith
getVirtualAddress() const49523de05aSAaron Smith uint64_t DIASectionContrib::getVirtualAddress() const {
50523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_virtualAddress);
51523de05aSAaron Smith }
52523de05aSAaron Smith
getRelativeVirtualAddress() const53523de05aSAaron Smith uint32_t DIASectionContrib::getRelativeVirtualAddress() const {
54523de05aSAaron Smith return PrivateGetDIAValue(Section,
55523de05aSAaron Smith &IDiaSectionContrib::get_relativeVirtualAddress);
56523de05aSAaron Smith }
57c0a5c01aSAaron Smith
getLength() const58523de05aSAaron Smith uint32_t DIASectionContrib::getLength() const {
59523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_length);
60523de05aSAaron Smith }
61523de05aSAaron Smith
isNotPaged() const62523de05aSAaron Smith bool DIASectionContrib::isNotPaged() const {
63523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notPaged);
64523de05aSAaron Smith }
65523de05aSAaron Smith
hasCode() const66523de05aSAaron Smith bool DIASectionContrib::hasCode() const {
67523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code);
68523de05aSAaron Smith }
69523de05aSAaron Smith
hasCode16Bit() const70523de05aSAaron Smith bool DIASectionContrib::hasCode16Bit() const {
71523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code16bit);
72523de05aSAaron Smith }
73523de05aSAaron Smith
hasInitializedData() const74523de05aSAaron Smith bool DIASectionContrib::hasInitializedData() const {
75523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_initializedData);
76523de05aSAaron Smith }
77523de05aSAaron Smith
hasUninitializedData() const78523de05aSAaron Smith bool DIASectionContrib::hasUninitializedData() const {
79c0a5c01aSAaron Smith return PrivateGetDIAValue(Section,
80c0a5c01aSAaron Smith &IDiaSectionContrib::get_uninitializedData);
81523de05aSAaron Smith }
82523de05aSAaron Smith
isRemoved() const83523de05aSAaron Smith bool DIASectionContrib::isRemoved() const {
84523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_remove);
85523de05aSAaron Smith }
86523de05aSAaron Smith
hasComdat() const87523de05aSAaron Smith bool DIASectionContrib::hasComdat() const {
88523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_comdat);
89523de05aSAaron Smith }
90523de05aSAaron Smith
isDiscardable() const91523de05aSAaron Smith bool DIASectionContrib::isDiscardable() const {
92523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_discardable);
93523de05aSAaron Smith }
94523de05aSAaron Smith
isNotCached() const95523de05aSAaron Smith bool DIASectionContrib::isNotCached() const {
96523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notCached);
97523de05aSAaron Smith }
98523de05aSAaron Smith
isShared() const99523de05aSAaron Smith bool DIASectionContrib::isShared() const {
100523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_share);
101523de05aSAaron Smith }
102523de05aSAaron Smith
isExecutable() const103523de05aSAaron Smith bool DIASectionContrib::isExecutable() const {
104523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_execute);
105523de05aSAaron Smith }
106523de05aSAaron Smith
isReadable() const107523de05aSAaron Smith bool DIASectionContrib::isReadable() const {
108523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_read);
109523de05aSAaron Smith }
110523de05aSAaron Smith
isWritable() const111523de05aSAaron Smith bool DIASectionContrib::isWritable() const {
112523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_write);
113523de05aSAaron Smith }
114523de05aSAaron Smith
getDataCrc32() const115523de05aSAaron Smith uint32_t DIASectionContrib::getDataCrc32() const {
116523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_dataCrc);
117523de05aSAaron Smith }
118523de05aSAaron Smith
getRelocationsCrc32() const119523de05aSAaron Smith uint32_t DIASectionContrib::getRelocationsCrc32() const {
120523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_relocationsCrc);
121523de05aSAaron Smith }
122523de05aSAaron Smith
getCompilandId() const123523de05aSAaron Smith uint32_t DIASectionContrib::getCompilandId() const {
124523de05aSAaron Smith return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_compilandId);
125523de05aSAaron Smith }
126