Line data Source code
1 : //===- TypeRecordHelpers.cpp ------------------------------------*- C++ -*-===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 :
10 : #include "llvm/DebugInfo/CodeView/TypeRecordHelpers.h"
11 :
12 : #include "llvm/ADT/SmallVector.h"
13 : #include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
14 : #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
15 :
16 : using namespace llvm;
17 : using namespace llvm::codeview;
18 :
19 348 : template <typename RecordT> static ClassOptions getUdtOptions(CVType CVT) {
20 : RecordT Record;
21 696 : if (auto EC = TypeDeserializer::deserializeAs<RecordT>(CVT, Record)) {
22 0 : consumeError(std::move(EC));
23 : return ClassOptions::None;
24 : }
25 348 : return Record.getOptions();
26 : }
27 7 :
28 : bool llvm::codeview::isUdtForwardRef(CVType CVT) {
29 14 : ClassOptions UdtOptions = ClassOptions::None;
30 0 : switch (CVT.kind()) {
31 : case LF_STRUCTURE:
32 : case LF_CLASS:
33 7 : case LF_INTERFACE:
34 : UdtOptions = getUdtOptions<ClassRecord>(std::move(CVT));
35 94 : break;
36 : case LF_ENUM:
37 188 : UdtOptions = getUdtOptions<EnumRecord>(std::move(CVT));
38 0 : break;
39 : case LF_UNION:
40 : UdtOptions = getUdtOptions<UnionRecord>(std::move(CVT));
41 94 : break;
42 : default:
43 247 : return false;
44 : }
45 494 : return (UdtOptions & ClassOptions::ForwardReference) != ClassOptions::None;
46 0 : }
47 :
48 : TypeIndex llvm::codeview::getModifiedType(const CVType &CVT) {
49 247 : assert(CVT.kind() == LF_MODIFIER);
50 : SmallVector<TypeIndex, 1> Refs;
51 : discoverTypeIndices(CVT, Refs);
52 753 : return Refs.front();
53 : }
|