[lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName
authorMichael Buch <michaelbuch12@gmail.com>
Thu, 27 Oct 2022 10:10:28 +0000 (11:10 +0100)
committerMichael Buch <michaelbuch12@gmail.com>
Mon, 31 Oct 2022 12:25:19 +0000 (12:25 +0000)
commit031096d04d09ac4a93859d161fb42d1a1b308253
tree50643c002abec40b2e83a5c51e46746bbf698ee0
parent76f34ed2837880c1865202f28988b01c93ac4f89
[lldb][CPlusPlus] Implement CPlusPlusLanguage::GetFunctionDisplayName

This patch implements the `GetFunctionDisplayName` API which gets
used by the frame-formatting code to decide how to print a
function name.

Currently this API trivially returns `false`, so we try to parse
the demangled function base-name by hand. We try find the closing
parenthesis by doing a forward scan through the demangled name. However,
for arguments that contain parenthesis (e.g., function pointers)
this would leave garbage in the frame function name.

By re-using the `CPlusPlusLanguage` parser for this we offload the
need to parse function names to a component that knows how to do this
already.

We leave the existing parsing code in `FormatEntity` since it's used
in cases where a language-plugin is not available (and is not
necessarily C++ specific).

**Example**

For following function:
```
int foo(std::function<int(void)> const& func) { return 1; }
```

Before patch:
```
frame #0: 0x000000010000151c a.out`foo(func= Function = bar() )> const&) at sample.cpp:11:49
```

After patch:
```
frame #0: 0x000000010000151c a.out`foo(func= Function = bar() ) at sample.cpp:11:49
```

**Testing**

* Added shell test
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/test/Shell/Settings/Inputs/names.cpp [new file with mode: 0644]
lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test [new file with mode: 0644]