Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp
Show All 36 Lines | TypeReferenceTracker::TypeReferenceTracker(InputFile &File) | ||||
if (Ids) { | if (Ids) { | ||||
NumIdRecords = getNumRecordsInCollection(*Ids); | NumIdRecords = getNumRecordsInCollection(*Ids); | ||||
IdReferenced.resize(NumIdRecords, false); | IdReferenced.resize(NumIdRecords, false); | ||||
} | } | ||||
// Get the TpiStream pointer for forward decl resolution if this is a pdb. | // Get the TpiStream pointer for forward decl resolution if this is a pdb. | ||||
// Build the hash map to enable resolving forward decls. | // Build the hash map to enable resolving forward decls. | ||||
if (File.isPdb()) { | if (File.isPdb()) { | ||||
Tpi = &cantFail(File.pdb().getPDBTpiStream()); | Tpi = &llvm_cantFail(File.pdb().getPDBTpiStream()); | ||||
Tpi->buildHashMap(); | Tpi->buildHashMap(); | ||||
} | } | ||||
} | } | ||||
void TypeReferenceTracker::mark() { | void TypeReferenceTracker::mark() { | ||||
// Walk type roots: | // Walk type roots: | ||||
// - globals | // - globals | ||||
// - modi symbols | // - modi symbols | ||||
// - LF_UDT_MOD_SRC_LINE? VC always links these in. | // - LF_UDT_MOD_SRC_LINE? VC always links these in. | ||||
for (SymbolGroup SG : File.symbol_groups()) { | for (SymbolGroup SG : File.symbol_groups()) { | ||||
if (File.isObj()) { | if (File.isObj()) { | ||||
for (const auto &SS : SG.getDebugSubsections()) { | for (const auto &SS : SG.getDebugSubsections()) { | ||||
// FIXME: Are there other type-referencing subsections? Inlinees? | // FIXME: Are there other type-referencing subsections? Inlinees? | ||||
// Probably for IDs. | // Probably for IDs. | ||||
if (SS.kind() != DebugSubsectionKind::Symbols) | if (SS.kind() != DebugSubsectionKind::Symbols) | ||||
continue; | continue; | ||||
CVSymbolArray Symbols; | CVSymbolArray Symbols; | ||||
BinaryStreamReader Reader(SS.getRecordData()); | BinaryStreamReader Reader(SS.getRecordData()); | ||||
cantFail(Reader.readArray(Symbols, Reader.getLength())); | llvm_cantFail(Reader.readArray(Symbols, Reader.getLength())); | ||||
for (const CVSymbol &S : Symbols) | for (const CVSymbol &S : Symbols) | ||||
addTypeRefsFromSymbol(S); | addTypeRefsFromSymbol(S); | ||||
} | } | ||||
} else if (SG.hasDebugStream()) { | } else if (SG.hasDebugStream()) { | ||||
for (const CVSymbol &S : SG.getPdbModuleStream().getSymbolArray()) | for (const CVSymbol &S : SG.getPdbModuleStream().getSymbolArray()) | ||||
addTypeRefsFromSymbol(S); | addTypeRefsFromSymbol(S); | ||||
} | } | ||||
} | } | ||||
// Walk globals and mark types referenced from globals. | // Walk globals and mark types referenced from globals. | ||||
if (File.isPdb() && File.pdb().hasPDBGlobalsStream()) { | if (File.isPdb() && File.pdb().hasPDBGlobalsStream()) { | ||||
SymbolStream &SymStream = cantFail(File.pdb().getPDBSymbolStream()); | SymbolStream &SymStream = llvm_cantFail(File.pdb().getPDBSymbolStream()); | ||||
GlobalsStream &GS = cantFail(File.pdb().getPDBGlobalsStream()); | GlobalsStream &GS = llvm_cantFail(File.pdb().getPDBGlobalsStream()); | ||||
for (uint32_t PubSymOff : GS.getGlobalsTable()) { | for (uint32_t PubSymOff : GS.getGlobalsTable()) { | ||||
CVSymbol Sym = SymStream.readRecord(PubSymOff); | CVSymbol Sym = SymStream.readRecord(PubSymOff); | ||||
addTypeRefsFromSymbol(Sym); | addTypeRefsFromSymbol(Sym); | ||||
} | } | ||||
} | } | ||||
// FIXME: Should we walk Ids? | // FIXME: Should we walk Ids? | ||||
} | } | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | if (Tpi) { | ||||
default: | default: | ||||
break; | break; | ||||
case LF_CLASS: | case LF_CLASS: | ||||
case LF_INTERFACE: | case LF_INTERFACE: | ||||
case LF_STRUCTURE: | case LF_STRUCTURE: | ||||
case LF_UNION: | case LF_UNION: | ||||
case LF_ENUM: | case LF_ENUM: | ||||
addOneTypeRef(TiRefKind::TypeRef, | addOneTypeRef(TiRefKind::TypeRef, | ||||
cantFail(Tpi->findFullDeclForForwardRef(RefTI))); | llvm_cantFail(Tpi->findFullDeclForForwardRef(RefTI))); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |