xref: /llvm-project/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py (revision edb0efca1e73ec5f791d9fe8c28f7c4c85a61c43)
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
10class ExprCommandCallFunctionTestCase(TestBase):
11
12    mydir = TestBase.compute_mydir(__file__)
13
14    @expectedFailureAll(
15        compiler="icc",
16        bugnumber="llvm.org/pr14437, fails with ICC 13.1")
17    @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
18    def test_with(self):
19        """Test calling std::String member function."""
20        self.build()
21        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
22
23        self.expect("print str",
24                    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 ["arm64-apple-ios", "arm64e-apple-ios", "arm64-apple-tvos", "armv7k-apple-watchos", "arm64-apple-bridgeos", "arm64_32-apple-watchos"]:
34            do_cstr_test = False
35        if do_cstr_test:
36            self.expect("print str.c_str()",
37                        substrs=['Hello world'])
38