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 getUdtOptions(CVType CVT)19template <typename RecordT> static ClassOptions getUdtOptions(CVType CVT) { 20 RecordT Record; 21 if (auto EC = TypeDeserializer::deserializeAs<RecordT>(CVT, Record)) { 22 consumeError(std::move(EC)); 23 return ClassOptions::None; 24 } 25 return Record.getOptions(); 26 } 27 isUdtForwardRef(CVType CVT)28bool llvm::codeview::isUdtForwardRef(CVType CVT) { 29 ClassOptions UdtOptions = ClassOptions::None; 30 switch (CVT.kind()) { 31 case LF_STRUCTURE: 32 case LF_CLASS: 33 case LF_INTERFACE: 34 UdtOptions = getUdtOptions<ClassRecord>(std::move(CVT)); 35 break; 36 case LF_ENUM: 37 UdtOptions = getUdtOptions<EnumRecord>(std::move(CVT)); 38 break; 39 case LF_UNION: 40 UdtOptions = getUdtOptions<UnionRecord>(std::move(CVT)); 41 break; 42 default: 43 return false; 44 } 45 return (UdtOptions & ClassOptions::ForwardReference) != ClassOptions::None; 46 } 47 getModifiedType(const CVType & CVT)48TypeIndex llvm::codeview::getModifiedType(const CVType &CVT) { 49 assert(CVT.kind() == LF_MODIFIER); 50 SmallVector<TypeIndex, 1> Refs; 51 discoverTypeIndices(CVT, Refs); 52 return Refs.front(); 53 } 54