1 //===- DIASectionContrib.cpp - DIA impl. of IPDBSectionContrib ---- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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"
16 using namespace llvm::pdb;
18 DIASectionContrib::DIASectionContrib(const DIASession &PDBSession,
19 CComPtr<IDiaSectionContrib> DiaSection)
20 : Session(PDBSession), Section(DiaSection) {}
22 std::unique_ptr<PDBSymbolCompiland> DIASectionContrib::getCompiland() const {
23 CComPtr<IDiaSymbol> Symbol;
24 if (FAILED(Section->get_compiland(&Symbol)))
27 auto RawSymbol = llvm::make_unique<DIARawSymbol>(Session, Symbol);
28 return llvm::make_unique<PDBSymbolCompiland>(Session, std::move(RawSymbol));
31 template <typename ArgType>
33 PrivateGetDIAValue(IDiaSectionContrib *Section,
34 HRESULT (__stdcall IDiaSectionContrib::*Method)(ArgType *)) {
36 if (S_OK == (Section->*Method)(&Value))
37 return static_cast<ArgType>(Value);
42 uint32_t DIASectionContrib::getAddressSection() const {
43 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressSection);
46 uint32_t DIASectionContrib::getAddressOffset() const {
47 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_addressOffset);
50 uint64_t DIASectionContrib::getVirtualAddress() const {
51 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_virtualAddress);
54 uint32_t DIASectionContrib::getRelativeVirtualAddress() const {
55 return PrivateGetDIAValue(Section,
56 &IDiaSectionContrib::get_relativeVirtualAddress);
59 uint32_t DIASectionContrib::getLength() const {
60 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_length);
63 bool DIASectionContrib::isNotPaged() const {
64 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notPaged);
67 bool DIASectionContrib::hasCode() const {
68 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code);
71 bool DIASectionContrib::hasCode16Bit() const {
72 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_code16bit);
75 bool DIASectionContrib::hasInitializedData() const {
76 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_initializedData);
79 bool DIASectionContrib::hasUninitializedData() const {
80 return PrivateGetDIAValue(Section,
81 &IDiaSectionContrib::get_uninitializedData);
84 bool DIASectionContrib::isRemoved() const {
85 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_remove);
88 bool DIASectionContrib::hasComdat() const {
89 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_comdat);
92 bool DIASectionContrib::isDiscardable() const {
93 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_discardable);
96 bool DIASectionContrib::isNotCached() const {
97 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_notCached);
100 bool DIASectionContrib::isShared() const {
101 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_share);
104 bool DIASectionContrib::isExecutable() const {
105 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_execute);
108 bool DIASectionContrib::isReadable() const {
109 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_read);
112 bool DIASectionContrib::isWritable() const {
113 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_write);
116 uint32_t DIASectionContrib::getDataCrc32() const {
117 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_dataCrc);
120 uint32_t DIASectionContrib::getRelocationsCrc32() const {
121 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_relocationsCrc);
124 uint32_t DIASectionContrib::getCompilandId() const {
125 return PrivateGetDIAValue(Section, &IDiaSectionContrib::get_compilandId);