This is an archive of the discontinued LLVM Phabricator instance.

[llvm][utils] Fix llvm::Optional summary provider
ClosedPublic

Authored by kastiglione on Mar 18 2022, 2:29 PM.

Details

Summary

Returning None from a Python type summary results in a summary string of "None". To indicate no summary string, the implementation should return the empty string.

This change fixes a bug where the summary provider for llvm::Optional would incorrectly show None. This would happen when the underlying type itself had no summary provider. Now, when the underlying type has a summary string, that string is used, but when there is no summary, then the Optional will also have no summary (return '').

Diff Detail

Event Timeline

kastiglione created this revision.Mar 18 2022, 2:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2022, 2:29 PM
kastiglione requested review of this revision.Mar 18 2022, 2:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2022, 2:29 PM
aprantl accepted this revision.Mar 18 2022, 4:11 PM
This revision is now accepted and ready to land.Mar 18 2022, 4:11 PM
This revision was landed with ongoing or failed builds.Mar 21 2022, 10:03 AM
This revision was automatically updated to reflect the committed changes.
shafik added a subscriber: shafik.Mar 21 2022, 1:11 PM

Do we have any tests for these?

We don't at the moment. We could add a test to the LLDB testsuite that compiles a test program against Support. There's some CMake trickery necessary for this, which is probably why we've shied away from it thus far.

There's some CMake trickery

Can you shed some more light on this? Am I understanding right: these formatters are llvm, but the test would be in lldb? It seems weird that something in llvm/ would only have tests in lldb/. Would it be bad to move this file into lldb, and then we can test there? With llvm being a monorepo, a source checkout should have access at any path. Maybe the issue would be llvm installations and packages that don't include lldb too?

There's some CMake trickery

Can you shed some more light on this? Am I understanding right: these formatters are llvm, but the test would be in lldb? It seems weird that something in llvm/ would only have tests in lldb/.

You need an LLDB in order to test the dataformatter, that's why I thought the test makes most sense there. The other natural place would be cross-project-tests/.

Would it be bad to move this file into lldb, and then we can test there?

It's nice & consistent to have the LLDB data formatters next to the GDB dataformatters, but I don't very strong feelings about this.

With llvm being a monorepo, a source checkout should have access at any path. Maybe the issue would be llvm installations and packages that don't include lldb too?

The test would need to build a debuginfo-enabled binary that links against Support (which, I now realize, does not need debug info), So maybe this is not going to be much more complicated than any unit tests we are building.