xref: /llvm-project/lldb/test/API/commands/expression/call-function/TestCallStdStringFunction.py (revision 948b36d2582c9cde913e434bd22814f01e85bdd6)
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    @skipIf(compiler="clang", compiler_version=['<', '9.0'])
19    def test_with(self):
20        """Test calling std::String member function."""
21        self.build()
22        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
23
24        self.expect("print str",
25                    substrs=['Hello world'])
26
27        # Calling this function now succeeds, but we follow the typedef return type through to
28        # const char *, and thus don't invoke the Summary formatter.
29
30        # clang's libstdc++ on ios arm64 inlines std::string::c_str() always;
31        # skip this part of the test.
32        triple = self.dbg.GetSelectedPlatform().GetTriple()
33        do_cstr_test = True
34        if triple in ["arm64-apple-ios", "arm64e-apple-ios", "arm64-apple-tvos", "armv7k-apple-watchos", "arm64-apple-bridgeos", "arm64_32-apple-watchos"]:
35            do_cstr_test = False
36        if do_cstr_test:
37            self.expect("print str.c_str()",
38                        substrs=['Hello world'])
39