This is an archive of the discontinued LLVM Phabricator instance.

Implement formatter for std::vector<bool, ...> of libstdc++ in Python.
ClosedPublic

Authored by sivachandra on Mar 17 2015, 12:08 PM.

Details

Summary

The existing formatter in C++ has been removed as it was not being used.
The associated test TestDataFormatterStdVBool.py has been enabled for
both Clang and GCC on Linux.

Diff Detail

Event Timeline

sivachandra retitled this revision from to Implement formatter for std::vector<bool, ...> of libstdc++ in Python..
sivachandra edited the test plan for this revision. (Show Details)
sivachandra updated this object.
sivachandra added a subscriber: Unknown Object (MLST).

Fix an indent in the Python changes.

Setting the Python changes in perspective: Though it appears in the diff as if I have added a formatter for std::vector<non-bool> as well, I have only moved it into an implementation class StdVectorSynthProvider.StdVectorImplementation. What I have really added is the class StdVectorSynthProvider.StdVBoolImplementation. The main class StdVectorSynthProvider has been refactored to reflect the common parts.

clayborg requested changes to this revision.Mar 17 2015, 12:52 PM
clayborg edited edge metadata.

Why did you move code from C++ into Python? We want this to be in C++ so it works on systems without python.

This revision now requires changes to proceed.Mar 17 2015, 12:52 PM

The existing formatter for std::vector<bool, ...> from libstdc++ is not used. If I run "type synthetic list", I see this:

...
-----------------------
Category: gnu-libstdc++ (enabled)
-----------------------
Regex-based synthetic providers (slower): 
^std::_Rb_tree_iterator<.+>$:  Generator at 0x7f13f9f0c310 - std::map iterator synthetic children
^__gnu_cxx::__normal_iterator<.+>$:  Generator at 0x7f13f9f0c390 - std::vector iterator synthetic children
^std::vector<.+>(( )?&)?$:  Python class lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider
^std::map<.+> >(( )?&)?$:  Python class lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider
^std::list<.+>(( )?&)?$:  Python class lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider
...

Formatters for map iterator and vector iterator are implemented in C++, but the formatters for std::vector, std::list and std::map are all implemented in Python. The approach I have taken is to extend the existing std::vector formatter (Python) to handle std::vector<bool, ...> as a special case. Since the c++ implementation of std::vector<bool, ...> is anyway not used, I removed it.

Do you suggest that we should actually be moving the Python formatters into C++?

clayborg accepted this revision.Mar 17 2015, 1:52 PM
clayborg edited edge metadata.

As long as the C++ code you removed was not being used that is ok.

Just spoke with Enrico Granata, our data formatters guys, and he said everything looks good.

This revision is now accepted and ready to land.Mar 17 2015, 1:52 PM
sivachandra edited edge metadata.

Mention in the commit message that the removed c++ implementation
of the formatter was not being used.

sivachandra updated this object.Mar 17 2015, 2:23 PM
sivachandra closed this revision.Mar 17 2015, 2:25 PM