aboutsummaryrefslogtreecommitdiff
path: root/lib/DebugInfo/PDB/Native/NativeTypeArray.cpp
blob: 80d455ad66e9585964a53c0b3ae115bf5be52652 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//===- NativeTypeArray.cpp - info about arrays ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/DebugInfo/PDB/Native/NativeTypeArray.h"

#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h"
#include "llvm/DebugInfo/PDB/Native/NativeTypeEnum.h"

using namespace llvm;
using namespace llvm::codeview;
using namespace llvm::pdb;

NativeTypeArray::NativeTypeArray(NativeSession &Session, SymIndexId Id,
                                 codeview::TypeIndex TI,
                                 codeview::ArrayRecord Record)
    : NativeRawSymbol(Session, PDB_SymType::ArrayType, Id), Record(Record),
      Index(TI) {}
NativeTypeArray::~NativeTypeArray() {}

void NativeTypeArray::dump(raw_ostream &OS, int Indent,
                           PdbSymbolIdField ShowIdFields,
                           PdbSymbolIdField RecurseIdFields) const {
  NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);

  dumpSymbolField(OS, "arrayIndexTypeId", getArrayIndexTypeId(), Indent);
  dumpSymbolIdField(OS, "elementTypeId", getTypeId(), Indent, Session,
                    PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);

  dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
                    PdbSymbolIdField::LexicalParent, ShowIdFields,
                    RecurseIdFields);
  dumpSymbolField(OS, "length", getLength(), Indent);
  dumpSymbolField(OS, "count", getCount(), Indent);
  dumpSymbolField(OS, "constType", isConstType(), Indent);
  dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
  dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
}

SymIndexId NativeTypeArray::getArrayIndexTypeId() const {
  return Session.getSymbolCache().findSymbolByTypeIndex(Record.getIndexType());
}

bool NativeTypeArray::isConstType() const { return false; }

bool NativeTypeArray::isUnalignedType() const { return false; }

bool NativeTypeArray::isVolatileType() const { return false; }

uint32_t NativeTypeArray::getCount() const {
  NativeRawSymbol &Element =
      Session.getSymbolCache().getNativeSymbolById(getTypeId());
  return getLength() / Element.getLength();
}

SymIndexId NativeTypeArray::getTypeId() const {
  return Session.getSymbolCache().findSymbolByTypeIndex(
      Record.getElementType());
}

uint64_t NativeTypeArray::getLength() const { return Record.Size; }