xref: /llvm-project/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test calling std::String member functions.
3"""
4
5import lldb
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8from lldbsuite.test import lldbutil
9
10
11class ExprCommandCallFunctionTestCase(TestBase):
12    @expectedFailureAll(
13        compiler="icc", bugnumber="llvm.org/pr14437, fails with ICC 13.1"
14    )
15    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
16    @skipIf(compiler="clang", compiler_version=["<", "9.0"])
17    def test_with(self):
18        """Test calling std::String member function."""
19        self.build()
20        lldbutil.run_to_source_breakpoint(
21            self, "// break here", lldb.SBFileSpec("main.cpp")
22        )
23
24        self.expect("expression str", substrs=["Hello world"])
25
26        # Calling this function now succeeds, but we follow the typedef return type through to
27        # const char *, and thus don't invoke the Summary formatter.
28
29        # clang's libstdc++ on ios arm64 inlines std::string::c_str() always;
30        # skip this part of the test.
31        triple = self.dbg.GetSelectedPlatform().GetTriple()
32        do_cstr_test = True
33        if triple in [
34            "arm64-apple-ios",
35            "arm64e-apple-ios",
36            "arm64-apple-tvos",
37            "armv7k-apple-watchos",
38            "arm64-apple-bridgeos",
39            "arm64_32-apple-watchos",
40        ]:
41            do_cstr_test = False
42        if do_cstr_test:
43            self.expect("expression str.c_str()", substrs=["Hello world"])
44