xref: /llvm-project/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py (revision 4cc8f2a017c76af25234afc7c380550e9c93135c)
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    @expectedFailureAll(
13        compiler="icc",
14        bugnumber="llvm.org/pr14437, fails with ICC 13.1")
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(self, "// break here", lldb.SBFileSpec("main.cpp"))
21
22        self.expect("print str",
23                    substrs=['Hello world'])
24
25        # Calling this function now succeeds, but we follow the typedef return type through to
26        # const char *, and thus don't invoke the Summary formatter.
27
28        # clang's libstdc++ on ios arm64 inlines std::string::c_str() always;
29        # skip this part of the test.
30        triple = self.dbg.GetSelectedPlatform().GetTriple()
31        do_cstr_test = True
32        if triple in ["arm64-apple-ios", "arm64e-apple-ios", "arm64-apple-tvos", "armv7k-apple-watchos", "arm64-apple-bridgeos", "arm64_32-apple-watchos"]:
33            do_cstr_test = False
34        if do_cstr_test:
35            self.expect("print str.c_str()",
36                        substrs=['Hello world'])
37