1 //===- TypeReferenceTracker.h --------------------------------- *- 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 #ifndef LLVM_TOOLS_LLVMPDBDUMP_TYPEREFERENCETRACKER_H
10 #define LLVM_TOOLS_LLVMPDBDUMP_TYPEREFERENCETRACKER_H
12 #include "llvm/ADT/BitVector.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/DebugInfo/CodeView/CVRecord.h"
15 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
16 #include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
17 #include "llvm/DebugInfo/PDB/Native/InputFile.h"
18 #include "llvm/Support/Error.h"
25 /// Maintains bitvector to track whether a type was referenced by a symbol
27 class TypeReferenceTracker
{
29 TypeReferenceTracker(InputFile
&File
);
31 // Do the work of marking referenced types.
34 // Return true if a symbol record transitively references this type.
35 bool isTypeReferenced(codeview::TypeIndex TI
) {
36 return TI
.toArrayIndex() <= NumTypeRecords
&&
37 TypeReferenced
.test(TI
.toArrayIndex());
41 void addTypeRefsFromSymbol(const codeview::CVSymbol
&Sym
);
43 // Mark types on this list as referenced.
44 void addReferencedTypes(ArrayRef
<uint8_t> RecData
,
45 ArrayRef
<codeview::TiReference
> Refs
);
47 // Consume all types on the worklist.
48 void markReferencedTypes();
50 void addOneTypeRef(codeview::TiRefKind RefKind
, codeview::TypeIndex RefTI
);
53 codeview::LazyRandomTypeCollection
&Types
;
54 codeview::LazyRandomTypeCollection
*Ids
= nullptr;
55 TpiStream
*Tpi
= nullptr;
56 BitVector TypeReferenced
;
57 BitVector IdReferenced
;
58 SmallVector
<std::pair
<codeview::TiRefKind
, codeview::TypeIndex
>, 10>
60 uint32_t NumTypeRecords
= 0;
61 uint32_t NumIdRecords
= 0;
67 #endif // LLVM_TOOLS_LLVMPDBDUMP_TYPEREFERENCETRACKER_H