This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add support for evaluating expressions in static member functions
AcceptedPublic

Authored by teemperor on Jun 10 2020, 4:53 AM.

Details

Summary

At the moment the expression parser doesn't support evaluating expressions in static member functions
and just pretends the expression is evaluated within a non-member function. This causes that all static
members are inaccessible when doing unqualified name lookup.

This patch adds support for evaluating in static member functions. It essentially just does the same setup
as what LLDB is already doing for non-static member functions (i.e., wrapping the expression in a fake
member function) with the difference that we now mark the wrapping function as static (to prevent
access to non-static members).

Diff Detail

Event Timeline

teemperor created this revision.Jun 10 2020, 4:53 AM
jarin accepted this revision.Nov 10 2020, 12:07 AM

This is looking great, thanks!

lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
179

Non-blocking comment: Perhaps this should fall back into the static method context (rather than the generic context). That way, at least the static members would be visible to the expression.

This revision is now accepted and ready to land.Nov 10 2020, 12:07 AM
shafik accepted this revision.Nov 10 2020, 7:03 PM

LGTM besides the minor comments.

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
1906

ontext -> context

lldb/test/API/lang/cpp/stopped_in_static_member_function/main.cpp
1

You might want to throw in a static constexpr and static const member variable as well.

This revision was automatically updated to reflect the committed changes.
teemperor marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 3:14 AM
teemperor reopened this revision.Jun 11 2021, 6:02 AM

Reopen because of the revert.

This revision is now accepted and ready to land.Jun 11 2021, 6:02 AM