Summary:
Currently when printing data types we include implicit scopes such as inline namespaces or anonymous namespaces.
This leads to command output like this (for `std::set<X>` with X being in an anonymous namespace):
```
(lldb) print my_set
(std::__1::set<(anonymous namespace)::X, std::__1::less<(anonymous namespace)::X>, std::__1::allocator<(anonymous namespace)::X> >) $0 = size=0 {}
```
This patch removes all the implicit scopes when printing type names in TypeSystemClang::GetDisplayTypeName
so that our output now looks like this:
```
(lldb) print my_set
(std::set<X, std::less<X>, std::allocator<X> >) $0 = size=0 {}
```
As previously GetDisplayTypeName and GetTypeName had the same output we actually often used the
two as if they are the same method (they were in fact using the same implementation), so this patch also
fixes the places where we actually want the display type name and not the actual type name.
Note that this doesn't touch the `GetTypeName` class that for example the data formatters use, so this patch
is only changes the way we display types to the user. The full type name can also still be found when passing
'-R' to see the raw output of a variable in case someone is somehow interested in that.
Partly fixes rdar://problem/59292534
Reviewers: shafik, jingham
Reviewed By: shafik
Subscribers: christof, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74478
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""
|
|
Test importing the 'std' C++ module and check if we can handle
|
|
prioritizing the conflicting functions from debug info and std
|
|
module.
|
|
|
|
See also import-std-module/basic/TestImportStdModule.py for
|
|
the same test on a 'clean' code base without conflicts.
|
|
"""
|
|
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
|
class TestImportStdModuleConflicts(TestBase):
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
@add_test_categories(["libc++"])
|
|
@skipIf(compiler=no_match("clang"))
|
|
def test(self):
|
|
self.build()
|
|
|
|
lldbutil.run_to_source_breakpoint(self,
|
|
"// Set break point at this line.", lldb.SBFileSpec("main.cpp"))
|
|
|
|
self.runCmd("settings set target.import-std-module true")
|
|
self.expect_expr("std::abs(-42)", result_type="int", result_value="42")
|
|
self.expect_expr("std::div(2, 1).quot", result_type="int", result_value="2")
|
|
self.expect_expr("(std::size_t)33U", result_type="std::size_t", result_value="33")
|
|
self.expect("expr char char_a = 'b'; char char_b = 'a'; std::swap(char_a, char_b); char_a",
|
|
substrs=["(char) $3 = 'a'"])
|