diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-07-26 19:03:47 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-07-26 19:04:23 +0000 |
commit | 7fa27ce4a07f19b07799a767fc29416f3b625afb (patch) | |
tree | 27825c83636c4de341eb09a74f49f5d38a15d165 /llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp | |
parent | e3b557809604d036af6e00c60f012c2025b59a5e (diff) |
Diffstat (limited to 'llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp index fb503f3d3e7e..2f26025d01ec 100644 --- a/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp @@ -45,15 +45,6 @@ const char *const KindUnion = "Union"; //===----------------------------------------------------------------------===// // DWARF lexical block, such as: namespace, function, compile unit, module, etc. //===----------------------------------------------------------------------===// -LVScope::~LVScope() { - delete Types; - delete Symbols; - delete Scopes; - delete Lines; - delete Ranges; - delete Children; -} - // Return a string representation for the scope kind. const char *LVScope::kind() const { const char *Kind = KindUndefined; @@ -114,7 +105,7 @@ LVScopeDispatch LVScope::Dispatch = { void LVScope::addToChildren(LVElement *Element) { if (!Children) - Children = new LVElements(); + Children = std::make_unique<LVElements>(); Children->push_back(Element); } @@ -137,7 +128,7 @@ void LVScope::addElement(LVLine *Line) { assert(Line && "Invalid line."); assert(!Line->getParent() && "Line already inserted"); if (!Lines) - Lines = new LVAutoLines(); + Lines = std::make_unique<LVLines>(); // Add it to parent. Lines->push_back(Line); @@ -161,7 +152,7 @@ void LVScope::addObject(LVLocation *Location) { assert(Location && "Invalid location."); assert(!Location->getParent() && "Location already inserted"); if (!Ranges) - Ranges = new LVAutoLocations(); + Ranges = std::make_unique<LVLocations>(); // Add it to parent. Location->setParent(this); @@ -176,7 +167,7 @@ void LVScope::addElement(LVScope *Scope) { assert(Scope && "Invalid scope."); assert(!Scope->getParent() && "Scope already inserted"); if (!Scopes) - Scopes = new LVAutoScopes(); + Scopes = std::make_unique<LVScopes>(); // Add it to parent. Scopes->push_back(Scope); @@ -203,7 +194,7 @@ void LVScope::addElement(LVSymbol *Symbol) { assert(Symbol && "Invalid symbol."); assert(!Symbol->getParent() && "Symbol already inserted"); if (!Symbols) - Symbols = new LVAutoSymbols(); + Symbols = std::make_unique<LVSymbols>(); // Add it to parent. Symbols->push_back(Symbol); @@ -230,7 +221,7 @@ void LVScope::addElement(LVType *Type) { assert(Type && "Invalid type."); assert(!Type->getParent() && "Type already inserted"); if (!Types) - Types = new LVAutoTypes(); + Types = std::make_unique<LVTypes>(); // Add it to parent. Types->push_back(Type); @@ -255,7 +246,7 @@ void LVScope::addElement(LVType *Type) { // Add a pair of ranges. void LVScope::addObject(LVAddress LowerAddress, LVAddress UpperAddress) { // Pack the ranges into a Location object. - LVLocation *Location = new LVLocation(); + LVLocation *Location = getReader().createLocation(); Location->setLowerAddress(LowerAddress); Location->setUpperAddress(UpperAddress); Location->setIsAddressRange(); @@ -341,7 +332,7 @@ void LVScope::addMissingElements(LVScope *Reference) { // information that is incorrect for the element to be inserted. // As the symbol being added does not exist in the debug section, // use its parent scope offset, to indicate its DIE location. - LVSymbol *Symbol = new LVSymbol(); + LVSymbol *Symbol = getReader().createSymbol(); addElement(Symbol); Symbol->setOffset(getOffset()); Symbol->setIsOptimized(); @@ -598,6 +589,10 @@ Error LVScope::doPrint(bool Split, bool Match, bool Print, raw_ostream &OS, // split context, then switch to the reader output stream. raw_ostream *StreamSplit = &OS; + // Ignore the CU generated by the VS toolchain, when compiling to PDB. + if (getIsSystem() && !options().getAttributeSystem()) + return Error::success(); + // If 'Split', we use the scope name (CU name) as the ouput file; the // delimiters in the pathname, must be replaced by a normal character. if (getIsCompileUnit()) { @@ -690,7 +685,7 @@ void LVScope::sort() { if (SortFunction) { std::function<void(LVScope * Parent, LVSortFunction SortFunction)> Sort = [&](LVScope *Parent, LVSortFunction SortFunction) { - auto Traverse = [&](auto *Set, LVSortFunction SortFunction) { + auto Traverse = [&](auto &Set, LVSortFunction SortFunction) { if (Set) std::stable_sort(Set->begin(), Set->end(), SortFunction); }; @@ -877,7 +872,7 @@ bool LVScope::equalNumberOfChildren(const LVScope *Scope) const { } void LVScope::markMissingParents(const LVScope *Target, bool TraverseChildren) { - auto SetCompareState = [&](auto *Container) { + auto SetCompareState = [&](auto &Container) { if (Container) for (auto *Entry : *Container) Entry->setIsInCompare(); @@ -1356,8 +1351,7 @@ void LVScopeCompileUnit::addedElement(LVType *Type) { // Record unsuported DWARF tags. void LVScopeCompileUnit::addDebugTag(dwarf::Tag Target, LVOffset Offset) { - addItem<LVTagOffsetsMap, LVOffsetList, dwarf::Tag, LVOffset>(&DebugTags, - Target, Offset); + addItem<LVTagOffsetsMap, dwarf::Tag, LVOffset>(&DebugTags, Target, Offset); } // Record elements with invalid offsets. @@ -1390,8 +1384,7 @@ void LVScopeCompileUnit::addLineZero(LVLine *Line) { LVScope *Scope = Line->getParentScope(); LVOffset Offset = Scope->getOffset(); addInvalidOffset(Offset, Scope); - addItem<LVOffsetLinesMap, LVLines, LVOffset, LVLine *>(&LinesZero, Offset, - Line); + addItem<LVOffsetLinesMap, LVOffset, LVLine *>(&LinesZero, Offset, Line); } void LVScopeCompileUnit::printLocalNames(raw_ostream &OS, bool Full) const { @@ -1481,7 +1474,7 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const { PrintHeader(Header); for (LVOffsetLocationsMap::const_reference Entry : Map) { PrintElement(WarningOffsets, Entry.first); - for (const LVLocation *Location : *Entry.second) + for (const LVLocation *Location : Entry.second) OS << hexSquareString(Location->getOffset()) << " " << Location->getIntervalInfo() << "\n"; } @@ -1494,7 +1487,7 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const { OS << format("\n0x%02x", (unsigned)Entry.first) << ", " << dwarf::TagString(Entry.first) << "\n"; unsigned Count = 0; - for (const LVOffset &Offset : *Entry.second) + for (const LVOffset &Offset : Entry.second) PrintOffset(Count, Offset); OS << "\n"; } @@ -1519,7 +1512,7 @@ void LVScopeCompileUnit::printWarnings(raw_ostream &OS, bool Full) const { for (LVOffsetLinesMap::const_reference Entry : LinesZero) { PrintElement(WarningOffsets, Entry.first); unsigned Count = 0; - for (const LVLine *Line : *Entry.second) + for (const LVLine *Line : Entry.second) PrintOffset(Count, Line->getOffset()); OS << "\n"; } @@ -1795,6 +1788,8 @@ void LVScopeFunction::resolveReferences() { // DW_AT_external DW_FORM_flag_present // 00000070 DW_TAG_subprogram "bar" // DW_AT_specification DW_FORM_ref4 0x00000048 + // CodeView does not include any information at the class level to + // mark the member function as external. // If there is a reference linking the declaration and definition, mark // the definition as extern, to facilitate the logical view comparison. if (getHasReferenceSpecification()) { @@ -2030,6 +2025,28 @@ void LVScopeRoot::processRangeInformation() { } } +void LVScopeRoot::transformScopedName() { + // Recursively transform all names. + std::function<void(LVScope * Parent)> TraverseScope = [&](LVScope *Parent) { + auto Traverse = [&](const auto *Set) { + if (Set) + for (const auto &Entry : *Set) + Entry->setInnerComponent(); + }; + if (const LVScopes *Scopes = Parent->getScopes()) + for (LVScope *Scope : *Scopes) { + Scope->setInnerComponent(); + TraverseScope(Scope); + } + Traverse(Parent->getSymbols()); + Traverse(Parent->getTypes()); + Traverse(Parent->getLines()); + }; + + // Start traversing the scopes root and transform the element name. + TraverseScope(this); +} + bool LVScopeRoot::equals(const LVScope *Scope) const { return LVScope::equals(Scope); } |