This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add YAML traits for ConstString and FileSpec
ClosedPublic

Authored by JDevlieghere on Mar 11 2020, 9:14 AM.

Details

Summary

Add YAML traits for ConstString and FileSpec so they can be serialized as part of ProcessInfo.

Diff Detail

Event Timeline

JDevlieghere created this revision.Mar 11 2020, 9:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2020, 9:14 AM
labath accepted this revision.Mar 12 2020, 2:53 AM

Looks fine, we just need to avoid ODR violations

lldb/include/lldb/Utility/FileSpec.h
446

FileSpec::Style is a typedef for llvm::sys::path::Style. Typedefs are not separate types so this code is defining a specialization for a type it does not own.

I think the simplest solution for that is to define a LLVM_YAML_STRONG_TYPEDEF(FileSpec::Style, MyStyle)
and then do something like

MyStyle style = f.m_style;
io.mapRequired("style", style);
f.m_style = style

in MappingTraits<FileSpec>

This revision is now accepted and ready to land.Mar 12 2020, 2:53 AM
labath added inline comments.Mar 12 2020, 2:57 AM
lldb/include/lldb/Utility/FileSpec.h
401

BTW, you can also friend a specific template instantiation: friend struct llvm::yaml::MappingTraits<FileSpec>.

This revision was automatically updated to reflect the committed changes.