Author: ewancrawford Date: Tue Mar 15 08:02:11 2016 New Revision: 263547 URL: http://llvm.org/viewvc/llvm-project?rev=263547&view=rev Log: Add regression test for expressions calling functions taking anonymous struct typedef arguments
This CL adds a regression test for the bug listed at https://llvm.org/bugs/show_bug.cgi?id=26790 Functionality was implemented in commit r263544 Author: Luke Drummond <luke.drumm...@codeplay.com> Differential Revision: http://reviews.llvm.org/D17777 Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/ lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile?rev=263547&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile (added) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/Makefile Tue Mar 15 08:02:11 2016 @@ -0,0 +1,12 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD +# targets. Other targets do not, which causes this test to fail. +# This flag enables FullDebugInfo for all targets. +ifneq (,$(findstring clang,$(CC))) + CFLAGS_EXTRAS += -fno-limit-debug-info +endif + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py?rev=263547&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py (added) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/TestCallUserAnonTypedef.py Tue Mar 15 08:02:11 2016 @@ -0,0 +1,40 @@ +""" +Test calling user defined functions using expression evaluation. +This test checks that typesystem lookup works correctly for typedefs of +untagged structures. + +Ticket: https://llvm.org/bugs/show_bug.cgi?id=26790 +""" + +from __future__ import print_function + +import lldb + +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestExprLookupAnonStructTypedef(TestBase): + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + TestBase.setUp(self) + # Find the breakpoint + self.line = line_number('main.cpp', '// lldb testsuite break') + + def test(self): + """Test typedeffed untagged struct arguments for function call expressions""" + self.build() + + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + lldbutil.run_break_set_by_file_and_line( + self, + "main.cpp", + self.line, + num_expected_locations=-1, + loc_exact=True + ) + + self.runCmd("run", RUN_SUCCEEDED) + self.expect("expr multiply(&s)", substrs=['$0 = 1']) Added: lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp?rev=263547&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp (added) +++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/anonymous-struct/main.cpp Tue Mar 15 08:02:11 2016 @@ -0,0 +1,26 @@ +#include <tgmath.h> + +typedef struct { + float f; + int i; +} my_untagged_struct; + +double multiply(my_untagged_struct *s) +{ + return s->f * s->i; +} + +double multiply(my_untagged_struct *s, int x) +{ + return multiply(s) * x; +} + +int main(int argc, char **argv) +{ + my_untagged_struct s = { + .f = (float)argc, + .i = argc, + }; + // lldb testsuite break + return !(multiply(&s, argc) == pow(argc, 3)); +} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits