1 //===- NativeTypeArray.cpp - info about arrays ------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/DebugInfo/PDB/Native/NativeTypeArray.h"
11 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
12 #include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
13 #include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"
16 using namespace llvm::codeview
;
17 using namespace llvm::pdb
;
19 NativeTypeArray::NativeTypeArray(NativeSession
&Session
, SymIndexId Id
,
20 codeview::TypeIndex TI
,
21 codeview::ArrayRecord Record
)
22 : NativeRawSymbol(Session
, PDB_SymType::ArrayType
, Id
), Record(Record
),
24 NativeTypeArray::~NativeTypeArray() {}
26 void NativeTypeArray::dump(raw_ostream
&OS
, int Indent
,
27 PdbSymbolIdField ShowIdFields
,
28 PdbSymbolIdField RecurseIdFields
) const {
29 NativeRawSymbol::dump(OS
, Indent
, ShowIdFields
, RecurseIdFields
);
31 dumpSymbolField(OS
, "arrayIndexTypeId", getArrayIndexTypeId(), Indent
);
32 dumpSymbolIdField(OS
, "elementTypeId", getTypeId(), Indent
, Session
,
33 PdbSymbolIdField::Type
, ShowIdFields
, RecurseIdFields
);
35 dumpSymbolIdField(OS
, "lexicalParentId", 0, Indent
, Session
,
36 PdbSymbolIdField::LexicalParent
, ShowIdFields
,
38 dumpSymbolField(OS
, "length", getLength(), Indent
);
39 dumpSymbolField(OS
, "count", getCount(), Indent
);
40 dumpSymbolField(OS
, "constType", isConstType(), Indent
);
41 dumpSymbolField(OS
, "unalignedType", isUnalignedType(), Indent
);
42 dumpSymbolField(OS
, "volatileType", isVolatileType(), Indent
);
45 SymIndexId
NativeTypeArray::getArrayIndexTypeId() const {
46 return Session
.getSymbolCache().findSymbolByTypeIndex(Record
.getIndexType());
49 bool NativeTypeArray::isConstType() const { return false; }
51 bool NativeTypeArray::isUnalignedType() const { return false; }
53 bool NativeTypeArray::isVolatileType() const { return false; }
55 uint32_t NativeTypeArray::getCount() const {
56 NativeRawSymbol
&Element
=
57 Session
.getSymbolCache().getNativeSymbolById(getTypeId());
58 return getLength() / Element
.getLength();
61 SymIndexId
NativeTypeArray::getTypeId() const {
62 return Session
.getSymbolCache().findSymbolByTypeIndex(
63 Record
.getElementType());
66 uint64_t NativeTypeArray::getLength() const { return Record
.Size
; }