This is an archive of the discontinued LLVM Phabricator instance.

[lldb][NFC] Prevent slicing when converting DataExtractors
ClosedPublic

Authored by fdeazeve on Jun 27 2023, 1:18 PM.

Details

Summary

LLDB's implementation of DWARFDataExtractor has a method that returns a
llvm::DWARFDataExtractor. In some cases, like DebugNamesDWARFIndex::Create, we
were passing an LLVM::DWARFDataExtractor to a function that expects a
LLVM:DataExtractor by value. This is causing slicing of the derived class.

While slicing is not inherently bad, it can be dangerous if the constructor of
the derived class mutates the base class in a way that leaves it in an invalid
state after slicing.

Diff Detail

Event Timeline

fdeazeve created this revision.Jun 27 2023, 1:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2023, 1:18 PM
Herald added a subscriber: arphaman. · View Herald Transcript
fdeazeve requested review of this revision.Jun 27 2023, 1:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2023, 1:18 PM
fdeazeve added reviewers: JDevlieghere, Restricted Project.Jun 27 2023, 1:29 PM
JDevlieghere accepted this revision.Jun 27 2023, 2:07 PM

Thanks for addressing this. LGTM.

This revision is now accepted and ready to land.Jun 27 2023, 2:07 PM