Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lang / c / vla / TestVLA.py
blobff4da0ee75740317a035f4d5795095c9fdc57722
1 import lldb
2 from lldbsuite.test.lldbtest import *
3 from lldbsuite.test.decorators import *
4 import lldbsuite.test.lldbutil as lldbutil
7 class TestVLA(TestBase):
8 @skipIf(compiler="clang", compiler_version=["<", "8.0"])
9 def test_variable_list(self):
10 self.build()
11 _, process, _, _ = lldbutil.run_to_source_breakpoint(
12 self, "break here", lldb.SBFileSpec("main.c")
15 # Make sure no helper expressions show up in frame variable.
16 var_opts = lldb.SBVariablesOptions()
17 var_opts.SetIncludeArguments(False)
18 var_opts.SetIncludeLocals(True)
19 var_opts.SetInScopeOnly(True)
20 var_opts.SetIncludeStatics(False)
21 var_opts.SetIncludeRuntimeSupportValues(False)
22 var_opts.SetUseDynamic(lldb.eDynamicCanRunTarget)
23 all_locals = self.frame().GetVariables(var_opts)
24 for value in all_locals:
25 self.assertNotIn("vla_expr", value.name)
27 @decorators.skipIf(compiler="clang", compiler_version=["<", "8.0"])
28 def test_vla(self):
29 self.build()
30 _, process, _, _ = lldbutil.run_to_source_breakpoint(
31 self, "break here", lldb.SBFileSpec("main.c")
34 def test(a):
35 children = []
36 for i in range(a):
37 name = "[%d]" % i
38 value = str(a - i)
39 self.expect_var_path("vla" + name, type="int", value=value)
40 self.expect_expr("vla" + name, result_type="int", result_value=value)
41 children.append(ValueCheck(name=name, value=value))
42 self.expect_var_path("vla", type="int[]", children=children)
43 self.expect("expr vla", error=True, substrs=["incomplete"])
45 test(2)
46 process.Continue()
47 test(4)