From a9d84cb9d8fbe357c9365421e07895a9be1e44fa Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Thu, 12 Jul 2018 00:31:04 +0000 Subject: [IRInterpreter] Fix misevaluation of interpretation expressions with `urem`. Scalar::MakeUnsigned was implemented incorrectly so it didn't really change the sign of the type (leaving signed types signed). This showed up as a misevaluation when IR-interpreting urem but it's likely to arise in other contexts. This commit fixes the definition, and adds a test to make sure this won't regress in future (hopefully). Fixes rdar://problem/42038760 and LLVM PR38076 Differential Revision: https://reviews.llvm.org/D49155 llvm-svn: 336872 --- .../test/expression_command/rdar42038760/Makefile | 3 +++ .../expression_command/rdar42038760/TestScalarURem.py | 4 ++++ .../test/expression_command/rdar42038760/main.c | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/Makefile create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py create mode 100644 lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c (limited to 'lldb/packages/Python/lldbsuite/test/expression_command') diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/Makefile b/lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/Makefile new file mode 100644 index 00000000000..f5a47fcc46c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/Makefile @@ -0,0 +1,3 @@ +LEVEL = ../../make +C_SOURCES := main.c +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py b/lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py new file mode 100644 index 00000000000..03424658f3e --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/TestScalarURem.py @@ -0,0 +1,4 @@ +from lldbsuite.test import lldbinline +from lldbsuite.test import decorators + +lldbinline.MakeInlineTest(__file__, globals(), None) diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c b/lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c new file mode 100644 index 00000000000..98a957faf8b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/expression_command/rdar42038760/main.c @@ -0,0 +1,19 @@ +// Make sure we IR-interpret the expression correctly. + +typedef unsigned int uint32_t; +struct S0 { + signed f2; +}; +static g_463 = 0x1561983AL; +void func_1(void) +{ + struct S0 l_19; + l_19.f2 = 419; + uint32_t l_4037 = 4294967295UL; + l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883']) +} +int main() +{ + func_1(); + return 0; +} -- cgit v1.2.3