1//===- NativeTypeArray.cpp - info about arrays ------------------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/DebugInfo/PDB/Native/NativeTypeArray.h"
10
11#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
12#include "llvm/DebugInfo/PDB/Native/SymbolCache.h"
13#include "llvm/DebugInfo/PDB/PDBExtras.h"
14
15using namespace llvm;
16using namespace llvm::codeview;
17using namespace llvm::pdb;
18
19NativeTypeArray::NativeTypeArray(NativeSession &Session, SymIndexId Id,
20 codeview::TypeIndex TI,
21 codeview::ArrayRecord Record)
22 : NativeRawSymbol(Session, PDB_SymType::ArrayType, Id), Record(Record),
23 Index(TI) {}
24NativeTypeArray::~NativeTypeArray() = default;
25
26void NativeTypeArray::dump(raw_ostream &OS, int Indent,
27 PdbSymbolIdField ShowIdFields,
28 PdbSymbolIdField RecurseIdFields) const {
29 NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
30
31 dumpSymbolField(OS, Name: "arrayIndexTypeId", Value: getArrayIndexTypeId(), Indent);
32 dumpSymbolIdField(OS, Name: "elementTypeId", Value: getTypeId(), Indent, Session,
33 FieldId: PdbSymbolIdField::Type, ShowFlags: ShowIdFields, RecurseFlags: RecurseIdFields);
34
35 dumpSymbolIdField(OS, Name: "lexicalParentId", Value: 0, Indent, Session,
36 FieldId: PdbSymbolIdField::LexicalParent, ShowFlags: ShowIdFields,
37 RecurseFlags: RecurseIdFields);
38 dumpSymbolField(OS, Name: "length", Value: getLength(), Indent);
39 dumpSymbolField(OS, Name: "count", Value: getCount(), Indent);
40 dumpSymbolField(OS, Name: "constType", Value: isConstType(), Indent);
41 dumpSymbolField(OS, Name: "unalignedType", Value: isUnalignedType(), Indent);
42 dumpSymbolField(OS, Name: "volatileType", Value: isVolatileType(), Indent);
43}
44
45SymIndexId NativeTypeArray::getArrayIndexTypeId() const {
46 return Session.getSymbolCache().findSymbolByTypeIndex(TI: Record.getIndexType());
47}
48
49bool NativeTypeArray::isConstType() const { return false; }
50
51bool NativeTypeArray::isUnalignedType() const { return false; }
52
53bool NativeTypeArray::isVolatileType() const { return false; }
54
55uint32_t NativeTypeArray::getCount() const {
56 NativeRawSymbol &Element =
57 Session.getSymbolCache().getNativeSymbolById(SymbolId: getTypeId());
58 return getLength() / Element.getLength();
59}
60
61SymIndexId NativeTypeArray::getTypeId() const {
62 return Session.getSymbolCache().findSymbolByTypeIndex(
63 TI: Record.getElementType());
64}
65
66uint64_t NativeTypeArray::getLength() const { return Record.Size; }
67