diff --git a/lldb/test/API/commands/expression/formatters/TestFormatters.py b/lldb/test/API/commands/expression/formatters/TestFormatters.py index 98872dffca35f7..1fbc1ef829862b 100644 --- a/lldb/test/API/commands/expression/formatters/TestFormatters.py +++ b/lldb/test/API/commands/expression/formatters/TestFormatters.py @@ -57,7 +57,7 @@ def cleanup(): self.runCmd("frame variable foo1.b --show-types") self.runCmd("frame variable foo1.b.b_ref --show-types") - self.filecheck("expression --show-types -- *(new foo(47))", __file__, + self.filecheck("expression --show-types -- *(new_foo(47))", __file__, '-check-prefix=EXPR-TYPES-NEW-FOO') # EXPR-TYPES-NEW-FOO: (foo) ${{.*}} = { # EXPR-TYPES-NEW-FOO-NEXT: (int) a = 47 @@ -90,13 +90,13 @@ def cleanup(): self.runCmd("type summary add -F formatters.foo_SummaryProvider foo") - self.expect("expression new int(12)", + self.expect("expression new_int(12)", substrs=['(int *) $', ' = 0x']) self.runCmd( "type summary add -s \"${var%pointer} -> ${*var%decimal}\" \"int *\"") - self.expect("expression new int(12)", + self.expect("expression new_int(12)", substrs=['(int *) $', '= 0x', ' -> 12']) self.expect("expression foo1.a_ptr", @@ -112,7 +112,7 @@ def cleanup(): # EXPR-FOO1-SAME: h = 27 # EXPR-FOO1-SAME: k = 29 - self.filecheck("expression --ptr-depth=1 -- new foo(47)", __file__, + self.filecheck("expression --ptr-depth=1 -- new_foo(47)", __file__, '-check-prefix=EXPR-PTR-DEPTH1') # EXPR-PTR-DEPTH1: (foo *) $ # EXPR-PTR-DEPTH1-SAME: a = 47 diff --git a/lldb/test/API/commands/expression/formatters/main.cpp b/lldb/test/API/commands/expression/formatters/main.cpp index 4ca2504ff8cb53..7360c479f10a58 100644 --- a/lldb/test/API/commands/expression/formatters/main.cpp +++ b/lldb/test/API/commands/expression/formatters/main.cpp @@ -1,6 +1,10 @@ #include #include +int *new_int(int val) { + return new int(val); +} + struct baz { int h; @@ -24,16 +28,22 @@ struct foo bar b; foo(int x) : a(x), - a_ptr(new int(x+1)), + a_ptr(new_int(x+1)), b(2*x) {} }; + +foo *new_foo(int x) { + return new foo(x); +} + int main(int argc, char** argv) { foo foo1(12); foo foo2(121); - + foo * newd_foo = new_foo(1); + delete newd_foo; foo2.a = 7777; // Stop here *(foo2.b.i_ptr) = 8888; foo2.b.b.h = 9999; diff --git a/lldb/test/API/lang/cpp/constructors/TestCppConstructors.py b/lldb/test/API/lang/cpp/constructors/TestCppConstructors.py index 422854e38de1e8..75784f310ddef4 100644 --- a/lldb/test/API/lang/cpp/constructors/TestCppConstructors.py +++ b/lldb/test/API/lang/cpp/constructors/TestCppConstructors.py @@ -24,3 +24,9 @@ def test_constructors(self): self.expect("expr ClassWithDeletedCtor(1).value", error=True, substrs=["Couldn't lookup symbols:"]) self.expect("expr ClassWithDeletedDefaultCtor().value", error=True, substrs=["Couldn't lookup symbols:"]) + @skipIfLinux # Fails on some Linux systems with SIGABRT. + def test_constructors_new(self): + self.build() + lldbutil.run_to_source_breakpoint(self,"// break here", lldb.SBFileSpec("main.cpp")) + + self.expect_expr("(new ClassWithOneCtor(1)).value; 1", result_type="int", result_value="1")