This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Fix printing a static bool struct member when using "image lookup -t"
ClosedPublic

Authored by DavidSpickett on Oct 4 2022, 9:00 AM.

Details

Summary

Fixes #58135

Somehow lldb was able to print the member on its own but when we try
to print the whole type found by "image lookup -t" lldb would crash.

This is because we'd encoded the initial value of the member as an integer.
Which isn't the end of the world because bool is integral for C++.
However, clang has a special AST node to handle literal bool and it
expected us to use that instead.

This adds a new codepath to handle static bool which uses cxxBoolLiteralExpr
and we get the member printed as you'd expect.

For testing I added a struct with just the bool because trying to print
all of "A" crashes as well. Presumably because one of the other member's
types isn't handled properly either.

So for now I just added the bool case, we can merge it with A later.

Diff Detail

Event Timeline

DavidSpickett created this revision.Oct 4 2022, 9:00 AM
Herald added a project: Restricted Project. · View Herald Transcript
DavidSpickett requested review of this revision.Oct 4 2022, 9:00 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 4 2022, 9:00 AM
shafik added inline comments.Oct 4 2022, 9:23 AM
clang/include/clang/AST/ExprCXX.h
733 ↗(On Diff #465034)

I think this makes sense but if we are going to do this refactor then we should clean up all the locations we are currently doing new (Context) CXXBoolLiteralExpr(....) as well.

Maybe that should be the initial PR and then this change would be a follow-up.

DavidSpickett added inline comments.Oct 5 2022, 12:35 AM
clang/include/clang/AST/ExprCXX.h
733 ↗(On Diff #465034)

Sounds good to me, I'll do that.

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
36

And just to be clear, this is TODO is resolved in the patch stacked on this one.

Rebase, Create moved to parent change.

aeubanks accepted this revision.Oct 6 2022, 2:38 PM
This revision is now accepted and ready to land.Oct 6 2022, 2:38 PM