This is an archive of the discontinued LLVM Phabricator instance.

[lldb][SymbolFileDWARF] Support by-name lookup of global variables in inline namespaces
ClosedPublic

Authored by Michael137 on Feb 1 2023, 6:33 AM.

Details

Summary

Currently evaluating an expression involving a global variable inside
an inline namespace will fail to lookup said variable. This is because
the SymbolFileDWARF::FindGlobalVariables discards from consideration
all DIEs whose decl_context doesn't exactly match that of the lookup.

This patch relaxes this restriction by checking whether C++ rules
would permit the lookup.

The motivation for this is evaluating std::ranges expressions, which
heavily rely on global variables inside inline namespaces. E.g.,
std::views::all(...) is just an invocation of the operator()
on std::ranges::views::__cpo::all.

Testing

  • Added API tests

Diff Detail

Event Timeline

Michael137 created this revision.Feb 1 2023, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2023, 6:33 AM
Michael137 requested review of this revision.Feb 1 2023, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2023, 6:33 AM
Michael137 updated this revision to Diff 493938.Feb 1 2023, 7:17 AM
  • Add test-case for nested inline namespaces
aprantl added inline comments.Feb 1 2023, 9:50 AM
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
2232

From the textual description above it sounds like this is a C++ specific feature, but the change is in generic code. Is IsContainedInLookup() implemented in a language-specific way?

Michael137 updated this revision to Diff 494057.Feb 1 2023, 1:37 PM
  • Add comment
Michael137 updated this revision to Diff 494058.Feb 1 2023, 1:38 PM
  • Update commit message
aprantl accepted this revision.Feb 1 2023, 1:44 PM
This revision is now accepted and ready to land.Feb 1 2023, 1:44 PM