1 //===- TypeRecordHelpers.cpp ------------------------------------*- 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/CodeView/TypeRecordHelpers.h"
11 #include "llvm/ADT/SmallVector.h"
12 #include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h"
13 #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
16 using namespace llvm::codeview;
18 template <typename RecordT> static ClassOptions getUdtOptions(CVType CVT) {
20 if (auto EC = TypeDeserializer::deserializeAs<RecordT>(CVT, Record)) {
21 consumeError(std::move(EC));
22 return ClassOptions::None;
24 return Record.getOptions();
27 bool llvm::codeview::isUdtForwardRef(CVType CVT) {
28 ClassOptions UdtOptions = ClassOptions::None;
33 UdtOptions = getUdtOptions<ClassRecord>(std::move(CVT));
36 UdtOptions = getUdtOptions<EnumRecord>(std::move(CVT));
39 UdtOptions = getUdtOptions<UnionRecord>(std::move(CVT));
44 return (UdtOptions & ClassOptions::ForwardReference) != ClassOptions::None;
47 TypeIndex llvm::codeview::getModifiedType(const CVType &CVT) {
48 assert(CVT.kind() == LF_MODIFIER);
49 SmallVector<TypeIndex, 1> Refs;
50 discoverTypeIndices(CVT, Refs);