Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / c / calling-conventions / TestCCallingConventions.py
blob9483dfcd0401864ca77621a11ef14db3d837e8a2
1 import lldb
2 from lldbsuite.test.decorators import *
3 from lldbsuite.test.lldbtest import *
4 from lldbsuite.test import lldbutil
5 from lldbsuite.test_event.build_exception import BuildError
8 class TestCase(TestBase):
9 NO_DEBUG_INFO_TESTCASE = True
11 def build_and_run(self, test_file):
12 """
13 Tries building the given test source and runs to the first breakpoint.
14 Returns false if the file fails to build due to an unsupported calling
15 convention on the current test target. Returns true if building and
16 running to the breakpoint succeeded.
17 """
18 try:
19 self.build(
20 dictionary={
21 "C_SOURCES": test_file,
22 "CFLAGS_EXTRAS": "-Werror=ignored-attributes",
25 except BuildError as e:
26 # Test source failed to build. Check if it failed because the
27 # calling convention argument is unsupported/unknown in which case
28 # the test should be skipped.
29 error_msg = str(e)
30 # Clang gives an explicit error when a calling convention is
31 # not supported.
32 if "calling convention is not supported for this target" in error_msg:
33 return False
34 # GCC's has two different generic warnings it can emit.
35 if "attribute ignored" in error_msg:
36 return False
37 if "attribute directive ignored " in error_msg:
38 return False
39 # We got a different build error, so raise it again to fail the
40 # test.
41 raise
42 lldbutil.run_to_source_breakpoint(
43 self, "// break here", lldb.SBFileSpec(test_file)
45 return True
47 @skipIf(compiler="clang", compiler_version=["<", "9.0"])
48 def test_regcall(self):
49 if not self.build_and_run("regcall.c"):
50 return
51 self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")
53 @skipIf(compiler="clang", compiler_version=["<", "9.0"])
54 def test_ms_abi(self):
55 if not self.build_and_run("ms_abi.c"):
56 return
57 self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")
59 @skipIf(compiler="clang", compiler_version=["<", "9.0"])
60 def test_stdcall(self):
61 if not self.build_and_run("stdcall.c"):
62 return
63 self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")
65 @expectedFailureAll(
66 oslist=["freebsd"], bugnumber="github.com/llvm/llvm-project/issues/56084"
68 def test_vectorcall(self):
69 if not self.build_and_run("vectorcall.c"):
70 return
71 self.expect_expr("func(1.0)", result_type="int", result_value="1")
73 @skipIf(compiler="clang", compiler_version=["<", "9.0"])
74 def test_fastcall(self):
75 if not self.build_and_run("fastcall.c"):
76 return
77 self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")
79 @skipIf(compiler="clang", compiler_version=["<", "9.0"])
80 def test_pascal(self):
81 if not self.build_and_run("pascal.c"):
82 return
83 self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")
85 def test_sysv_abi(self):
86 if not self.build_and_run("sysv_abi.c"):
87 return
88 self.expect_expr("func(1, 2, 3, 4)", result_type="int", result_value="10")