This is an archive of the discontinued LLVM Phabricator instance.

[lldb][ClangExpression] Remove storage-class check when creating AsmLabel
ClosedPublic

Authored by Michael137 on Aug 19 2022, 7:21 AM.

Details

Summary

This check was put in place to prevent static functions
from translation units outside the one that the current
expression is evaluated from, from taking precedence over functions
in the global namespace. However, this is really a different
bug. LLDB lumps functions from all CUs into a single AST and
ends up picking the file-static even when C++ context rules
wouldn't allow that to happen.

This patch removes the check so we apply the AsmLabel to all
FunctionDecls we create from DWARF if we have a linkage name
available. This makes the code-path easier to reason about and
allows calling static functions in contexts where we previously
would've chosen the wrong function.

We also flip the XFAILs in the API test to reflect what effect
this change has.

Testing

  • Fixed API tests and added XFAIL

Diff Detail

Event Timeline

Michael137 created this revision.Aug 19 2022, 7:21 AM
Herald added a project: Restricted Project. · View Herald Transcript
Michael137 requested review of this revision.Aug 19 2022, 7:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2022, 7:21 AM
Michael137 added inline comments.Aug 19 2022, 7:22 AM
lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py
228–229

should probably move this to the appropriate test-function that isn't xfailed so we don't spin up an lldb instance just for this

Michael137 edited the summary of this revision. (Show Details)Aug 19 2022, 7:24 AM
  • Combine xfail tests cases
  • Remove redundant breakpoint
labath accepted this revision.Aug 22 2022, 12:31 AM

Yeah, fixing this correctly is not going to be trivial. Off the top of my head, I can think of two solutions (creating per-file ASTs for static objects, or putting all static objects from a given file into a special namespace) and each of them has a lot of drawbacks.

This revision is now accepted and ready to land.Aug 22 2022, 12:31 AM
  • Move one passing test case out of xfail