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

source code of llvm/lib/DebugInfo/PDB/Native/NativeTypeArray.cpp