Add formattors for libc++ std::optional and tests to verify the new Formattors.
jingham friss jasonmolenda EricWF JDevlieghere davide
- rGc53d36847ebd: Add libc++ data formatters for std::optional.
rG1d44c46539fa: Recommit [DataFormatters] Add formatter for C++17 std::optional.
rG1d4a78ef0422: [DataFormatters] Add formatter for C++17 std::optional.
rLLDB339828: Add libc++ data formatters for std::optional.
rL339828: Add libc++ data formatters for std::optional.
rLLDB338156: Recommit [DataFormatters] Add formatter for C++17 std::optional.
rLLDB337959: [DataFormatters] Add formatter for C++17 std::optional.
rL338156: Recommit [DataFormatters] Add formatter for C++17 std::optional.
rL337959: [DataFormatters] Add formatter for C++17 std::optional.
Some comments. Jonas looked at many formatters recently so he's in a good position to take a look.
commented out code?
You don't really need to se all these breakpoints.
Please sort this.
Can you use StringRef?
Please clang-format this patch.
Please remove this commented out code.
if you want to log diagnostics, you might consider using the LOG facility and then add these to the data formatters channel.
It seems a little odd to choose to represent this as an array with 1 element. I think I would be confused by that. You can maybe choose a better name like "value" for your cloned object. But it looks like it is also possible to make a Synthetic Child Provider that just replaces the value of the object with the value provided by the synthetic child provider. That's done in the Python front end by saying you have no children and then providing a the "get_value" method. It must be possible to do this from C++ as well, but it will take a little thought to figure out how that works. But that would be the most natural way to present this, I think.
you can do this more cleanly with:
(self.target, _, _, bkpt) = lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.cpp"))
I don't think you need this cleanup, you aren't adding any formatters, you're just testing built-in ones.
If you want to log this, get the formatters log channel and put the text there. Then somebody will see this when they turn on the log. An fprintf like this won't help anybody.
- Applying clang-formt
- Refactoring OptionalFrontEnd to produce out that makes the underlying data look like an array
- Removing commented out code and left in debugging
- Using StringRef instead of const char *
This looks like a good idea, I will try it out and let you know.
Thank you for catching, I meant to remove this.
Probably last round of comments. Thanks for your patience!
you don't need this, it's implicit (-O0)
I do wonder if you need a decorator to indicate that this is a libcxx only test (and skip everywhere the library isn't supported).
I'm a little nervous about this regex, but I think it's fine and I'll let Jim take another look in case I missed something.
This is really obscure to somebody who doesn't understand the type internally. Can you add a comment explaining the structure? (here or in the synthetic)
This looks fine. I agree with Davide that putting some description of the type you are formatting in comments somewhere would be make things easier for somebody else who might have to fix this (or to you when you've totally forgotten how this worked a year from now...)
I'm okay with this if you fix the things Davide asked about (except the regex, that looks right to me.)
Yes, you do need to mark this or you will get spurious failures at least on Windows, which turns off the libcxx category.
That looks right to me, it's catching the type or a reference to it.
- -O0 is not needed in Makefile
- engaged is not friendly terminology so switching to "Has Value"
- Switching test away from lldbinline style due to bug w/ .categories files which does not work on these tests
@davide One more pass
Switched back to the old style tests due to the .categories bug we discussed earlier.
That is a good point, I am looking at the cppreference page for it and I think maybe has_value might be an improvement.
a11963323fc Recommit [DataFormatters] Add formatter for C++17 std::optional.
Authentication realm: https://llvm.org:443 LLVM Subversion repository
Password for 'davide': ***
Transmitting file data .........done
Committed revision 338156.
Committed a11963323fc to svn.
I'm afraid I had to revert this again. It broke an ubuntu lldb-cmake bot which builds with clang-3.5 (which has no -std=c++17 support flag, as 17 wasn't there yet).
I'd recommend to update this patch with another decorator to skip places where -std=c++17 is not available doesn't work, and then we'll try again.
Bot logs for completeness:
Session logs for test failures/errors/unexpected successes will go into directory 'logs-clang-3.5-i386' Command invoked: /lldb-buildbot/lldbSlave/buildWorkingDir/scripts/../llvm/tools/lldb/test/dotest.py -A i386 -C clang-3.5 -v -s logs-clang-3.5-i386 -u CXXFLAGS -u CFLAGS --env ARCHIVER=ar --env OBJCOPY=objcopy --executable /lldb-buildbot/lldbSlave/buildWorkingDir/scripts/../build/bin/lldb --channel gdb-remote packets --channel lldb all --skip-category watchpoint --skip-category lldb-mi --results-port 43584 -S fnmac --inferior -p TestDataFormatterLibcxxOptional.py /lldb-buildbot/lldbSlave/buildWorkingDir/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional --event-add-entries worker_index=4:int Configuration: arch=i386 compiler=/usr/bin/clang-3.5 ---------------------------------------------------------------------- Collected 4 tests 1: test_with_run_command_dsym (TestDataFormatterLibcxxOptional.LibcxxOptionalDataFormatterTestCase) Test that that file and class static variables display correctly. ... skipped 'test case does not fall in any category of interest for this run' 2: test_with_run_command_dwarf (TestDataFormatterLibcxxOptional.LibcxxOptionalDataFormatterTestCase) Test that that file and class static variables display correctly. ... 3: test_with_run_command_dwo (TestDataFormatterLibcxxOptional.LibcxxOptionalDataFormatterTestCase) Test that that file and class static variables display correctly. ... 4: test_with_run_command_gmodules (TestDataFormatterLibcxxOptional.LibcxxOptionalDataFormatterTestCase) Test that that file and class static variables display correctly. ... skipped 'test case does not fall in any category of interest for this run' ====================================================================== ERROR: test_with_run_command_dwarf (TestDataFormatterLibcxxOptional.LibcxxOptionalDataFormatterTestCase) Test that that file and class static variables display correctly. ---------------------------------------------------------------------- Error when building test subject. Build Command: make VPATH=/lldb-buildbot/lldbSlave/buildWorkingDir/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional -C /lldb-buildbot/lldbSlave/buildWorkingDir/scripts/lldb-test-build.noindex/functionalities/data-formatter/data-formatter-stl/libcxx/optional/TestDataFormatterLibcxxOptional.test_with_run_command_dwarf -I /lldb-buildbot/lldbSlave/buildWorkingDir/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional -f /lldb-buildbot/lldbSlave/buildWorkingDir/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/optional/Makefile MAKE_DSYM=NO ARCH=i386 CC="/usr/bin/clang-3.5" Build Command Output: error: invalid value 'c++17' in '-std=c++17' error: invalid value 'c++17' in '-std=c++17' make: *** [main.o] Error 1
Thanks for looking out for the bots.
I am afraid the compiler check will not be enough here. After that, you'll run into the issue of the system libc++ not being recent enough to contain std::optional. I suppose this could be handled by including some other header first (to make sure __config is evaluated) and then checking the _LIBCPP_VERSION macro.
I am sorry that this is so annoying. It's surprising that this is the first time we're running into this, but I guess this is the first data formatter for something that hasn't been implemented in libc++ since forever.
Could you add another line for gcc here? The -std=c++17 flag seems to be supported starting with gcc-5.1.
Also a comment that this is due to the -std flag would be helpful to people looking at this in the future.
Replace by self.skipTest(...). This way, the test will be properly marked as skipped.
these need to be guarded by the #if too (i'd just move then into the main function).
- Adding comments
- Changing from exit to self.skipTest
- Adding skip for gcc
Adding a comment makes sense.
So @add_test_categories(["libc++"]) won't skip for gcc bots then?
Thanks for the patience. I've tried the patch out on our end. You shouldn't have any problems now.
It won't because it doesn't make sense to do that. Gcc is perfectly capable of using libc++. The only tricky thing is that it doesn't have the magic -stdlib argument, so you have to specify the include paths and libraries explicitly (which our makefiles do).
This could be simplified to bool has_optional = HAVE_OPTIONAL;
@labath Addressed comment, thank you for helping out.
Good point I did not realize this before!
I see this test failing on Linux right now (bots are down, so I can't confirm that the official bots fail as well). The failure is because of the last decorator which was not part of the review:
It looks like this only works correctly when mac_ver returns a meaningful result (a.k.a. on mac platforms), so linux is broken.
Another thing that I noticed is that the name of the test class (LibcxxOptionalDataFormatterTestCase) was re-used from another test. This has caused problems in the past with test overriding each other's results because they share the same class and test name (as these do).