1 //===- DebugTypes.cpp -----------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "DebugTypes.h" 10 #include "InputFiles.h" 11 #include "llvm/DebugInfo/CodeView/TypeRecord.h" 12 13 using namespace lld; 14 using namespace lld::coff; 15 using namespace llvm; 16 using namespace llvm::codeview; 17 18 namespace { 19 class TypeServerSource : public TpiSource { 20 public: 21 TypeServerSource(ObjFile *F) : TpiSource(PDB, F) {} 22 }; 23 24 class UseTypeServerSource : public TpiSource { 25 public: 26 UseTypeServerSource(ObjFile *F, TypeServer2Record *TS) 27 : TpiSource(UsingPDB, F), TypeServerDependency(*TS) {} 28 29 // Information about the PDB type server dependency, that needs to be loaded 30 // in before merging this OBJ. 31 TypeServer2Record TypeServerDependency; 32 }; 33 34 class PrecompSource : public TpiSource { 35 public: 36 PrecompSource(ObjFile *F) : TpiSource(PCH, F) {} 37 }; 38 39 class UsePrecompSource : public TpiSource { 40 public: 41 UsePrecompSource(ObjFile *F, PrecompRecord *Precomp) 42 : TpiSource(UsingPCH, F), PrecompDependency(*Precomp) {} 43 44 // Information about the Precomp OBJ dependency, that needs to be loaded in 45 // before merging this OBJ. 46 PrecompRecord PrecompDependency; 47 }; 48 } // namespace 49 50 static std::vector<std::unique_ptr<TpiSource>> GC; 51 52 TpiSource::TpiSource(TpiKind K, ObjFile *F) : Kind(K), File(F) { 53 GC.push_back(std::unique_ptr<TpiSource>(this)); 54 } 55 56 TpiSource *coff::makeTpiSource(ObjFile *F) { 57 return new TpiSource(TpiSource::Regular, F); 58 } 59 60 TpiSource *coff::makeTypeServerSource(ObjFile *F) { 61 return new TypeServerSource(F); 62 } 63 64 TpiSource *coff::makeUseTypeServerSource(ObjFile *F, TypeServer2Record *TS) { 65 return new UseTypeServerSource(F, TS); 66 } 67 68 TpiSource *coff::makePrecompSource(ObjFile *F) { return new PrecompSource(F); } 69 70 TpiSource *coff::makeUsePrecompSource(ObjFile *F, PrecompRecord *Precomp) { 71 return new UsePrecompSource(F, Precomp); 72 } 73 74 namespace lld { 75 namespace coff { 76 template <> 77 const PrecompRecord &retrieveDependencyInfo(TpiSource *Source) { 78 assert(Source->Kind == TpiSource::UsingPCH); 79 return ((UsePrecompSource *)Source)->PrecompDependency; 80 } 81 82 template <> 83 const TypeServer2Record &retrieveDependencyInfo(TpiSource *Source) { 84 assert(Source->Kind == TpiSource::UsingPDB); 85 return ((UseTypeServerSource *)Source)->TypeServerDependency; 86 } 87 } // namespace coff 88 } // namespace lld 89