[Lldb-commits] [lldb] 1438639 - [LLDB] Remove undefined behavior in TestConstStaticIntegralMember.py

Shafik Yaghmour via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 8 19:25:34 PDT 2022


Author: Shafik Yaghmour
Date: 2022-08-08T19:23:53-07:00
New Revision: 1438639a2f7eb9e9cba01454d3a9b1b16d179c9a

URL: https://github.com/llvm/llvm-project/commit/1438639a2f7eb9e9cba01454d3a9b1b16d179c9a
DIFF: https://github.com/llvm/llvm-project/commit/1438639a2f7eb9e9cba01454d3a9b1b16d179c9a.diff

LOG: [LLDB] Remove undefined behavior in TestConstStaticIntegralMember.py

Setting an enum without a fixed underlying type to a value which is outside the
value range is undefined behavior.

The initializer needs to be a constant expression and therefore this was always
ill-formed we just were not diagnosing it before.

See D130058 and D131307 for more details.

Differential Revision: https://reviews.llvm.org/D131460

Added: 
    

Modified: 
    lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
    lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
index 09345b98b16bc..794f382b8b68f 100644
--- a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -53,8 +53,6 @@ def test(self):
 
         # Test an unscoped enum.
         self.expect_expr("A::enum_val", result_value="enum_case2")
-        # Test an unscoped enum with an invalid enum case.
-        self.expect_expr("A::invalid_enum_val", result_value="enum_case1 | enum_case2 | 0x4")
 
         # Test a scoped enum.
         self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")

diff  --git a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
index b26251336371c..17b14da864a97 100644
--- a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -47,7 +47,6 @@ struct A {
       std::numeric_limits<unsigned long long>::min();
 
   const static Enum enum_val = enum_case2;
-  const static Enum invalid_enum_val = static_cast<Enum>(enum_case2 + 5);
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
   const static ScopedEnum invalid_scoped_enum_val = static_cast<ScopedEnum>(5);
   const static ScopedCharEnum scoped_char_enum_val = ScopedCharEnum::case2;
@@ -102,7 +101,6 @@ int main() {
   int member_copy = ClassWithOnlyConstStatic::member;
 
   Enum e = A::enum_val;
-  e = A::invalid_enum_val;
   ScopedEnum se = A::scoped_enum_val;
   se = A::invalid_scoped_enum_val;
   ScopedCharEnum sce = A::scoped_char_enum_val;


        


More information about the lldb-commits mailing list