This is an archive of the discontinued LLVM Phabricator instance.

Add LLDB synthetic child and summary scripts for llvm::SmallVector, llvm::Optional, llvm::ErrorOr and llvm::Expected.
Needs ReviewPublic

Authored by clayborg on Dec 21 2021, 8:21 AM.

Details

Summary

This allows us to see the contents of the SmallVector just like std::vector and also adds a summary string that shows the size of the array.

For llvm::Optional, the value will show as llvm::None when it has no value, or it will show the value of the type T.

For llvm::Error or, it will show the std::error_code as a structure or the value if it has a value.

For llvm::Expected, it will show the dynamic classname of the contained error, or the value.

Diff Detail

Unit TestsFailed

Event Timeline

clayborg created this revision.Dec 21 2021, 8:21 AM
clayborg requested review of this revision.Dec 21 2021, 8:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 21 2021, 8:21 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

thanks for doing this. Just a few minor comments and i think this is good to go

clang/utils/ClangDataFormat.py
215–218

it's safe to return 0 here, as it'll be only invoked when there's a value, so there's a single child with index 0

221–223

wouldn' just

return self.value

be enough?

index is always going to be 0 if called

279

god bless you

331–335

you can just return 0

409–410

ditto

Seems fairly straight-forward (and definitely useful). Just a couple of quick comments.

clang/utils/ClangDataFormat.py
28–35

I believe it's necessary to anchor these regexes to avoid them matching things like std::vector<llvm::Optional<T>>

371–373

maybe access as valobj.GetChildMemberWithName('ErrorStorage').GetType().GetTemplateArgumentType(0) ?

How does this relate to the code in llvm/utils/lldbDataFormatters.py and should it be added there instead?