Skip to content

Commit

Permalink
Merge pull request #3241 from adrian-prantl/82537719
Browse files Browse the repository at this point in the history
Remove unnecessary assertion and add a testcase.
  • Loading branch information
adrian-prantl committed Sep 9, 2021
2 parents d758d3c + 237059d commit 4927057
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2317,9 +2317,8 @@ lldb::Encoding TypeSystemSwiftTypeRef::GetEncoding(opaque_compiler_type_t type,
return referent_type.GetEncoding(count);
}
default:
assert(false && "Unhandled node kind");
LLDB_LOGF(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES),
"GetEncoding: Unhandled node kind for type %s",
"No encoding for type %s",
AsMangledName(type));
break;
}
Expand Down
3 changes: 3 additions & 0 deletions lldb/test/API/lang/swift/enum_as_value/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SWIFT_SOURCES := main.swift

include Makefile.rules
22 changes: 22 additions & 0 deletions lldb/test/API/lang/swift/enum_as_value/TestSwiftEnumAsValue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import lldb
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbtest as lldbtest
import lldbsuite.test.lldbutil as lldbutil
import unittest2


class TestSwiftAnyType(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@swiftTest
def test_any_type(self):
self.build()
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
self, 'Set breakpoint here', lldb.SBFileSpec('main.swift'))

frame = thread.frames[0]
var_e = frame.FindVariable("e")
# We don't have an encoding for enums.
self.assertEqual(var_e.GetValueAsSigned(0xdead), 0xdead)
self.assertEqual(var_e.GetValue(), 'B')
10 changes: 10 additions & 0 deletions lldb/test/API/lang/swift/enum_as_value/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
enum E {
case A
case B
}
func main(_ e: E) {
print(e) // Set breakpoint here
}

main(.B)

0 comments on commit 4927057

Please sign in to comment.