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/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"
17 using namespace llvm::codeview;
18 using namespace llvm::pdb;
20 NativeTypeArray::NativeTypeArray(NativeSession &Session, SymIndexId Id,
21 codeview::TypeIndex TI,
22 codeview::ArrayRecord Record)
23 : NativeRawSymbol(Session, PDB_SymType::ArrayType, Id), Record(Record),
25 NativeTypeArray::~NativeTypeArray() = default;
27 void NativeTypeArray::dump(raw_ostream &OS, int Indent,
28 PdbSymbolIdField ShowIdFields,
29 PdbSymbolIdField RecurseIdFields) const {
30 NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
32 dumpSymbolField(OS, "arrayIndexTypeId", getArrayIndexTypeId(), Indent);
33 dumpSymbolIdField(OS, "elementTypeId", getTypeId(), Indent, Session,
34 PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
36 dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
37 PdbSymbolIdField::LexicalParent, ShowIdFields,
39 dumpSymbolField(OS, "length", getLength(), Indent);
40 dumpSymbolField(OS, "count", getCount(), Indent);
41 dumpSymbolField(OS, "constType", isConstType(), Indent);
42 dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
43 dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
46 SymIndexId NativeTypeArray::getArrayIndexTypeId() const {
47 return Session.getSymbolCache().findSymbolByTypeIndex(Record.getIndexType());
50 bool NativeTypeArray::isConstType() const { return false; }
52 bool NativeTypeArray::isUnalignedType() const { return false; }
54 bool NativeTypeArray::isVolatileType() const { return false; }
56 uint32_t NativeTypeArray::getCount() const {
57 NativeRawSymbol &Element =
58 Session.getSymbolCache().getNativeSymbolById(getTypeId());
59 return getLength() / Element.getLength();
62 SymIndexId NativeTypeArray::getTypeId() const {
63 return Session.getSymbolCache().findSymbolByTypeIndex(
64 Record.getElementType());
67 uint64_t NativeTypeArray::getLength() const { return Record.Size; }