Skip to content

Commit d48df29

Browse files
author
git apple-llvm automerger
committed
Merge commit '659e139d89ff' from swift/release/5.4 into swift/main
2 parents 7d805d0 + 659e139 commit d48df29

File tree

4 files changed

+47
-46
lines changed

4 files changed

+47
-46
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4180,7 +4180,7 @@ void SwiftASTContext::CacheDemangledTypeFailure(ConstString name) {
41804180
/// What we should really do is only mangle AST types in DebugInfo, but that
41814181
/// requires some more plumbing on the Swift side to properly handle generic
41824182
/// specializations.
4183-
swift::Type convertSILFunctionTypesToASTFunctionTypes(swift::Type t) {
4183+
static swift::Type ConvertSILFunctionTypesToASTFunctionTypes(swift::Type t) {
41844184
return t.transform([](swift::Type t) -> swift::Type {
41854185
if (auto *silFn = t->getAs<swift::SILFunctionType>())
41864186
return swift::FunctionType::get({}, t->getASTContext().TheEmptyTupleType);
@@ -4300,14 +4300,18 @@ swift::TypeBase *SwiftASTContext::ReconstructType(ConstString mangled_typename,
43004300
.getPointer();
43014301

43024302
if (found_type) {
4303-
found_type =
4304-
convertSILFunctionTypesToASTFunctionTypes(found_type).getPointer();
4305-
CacheDemangledType(mangled_typename, found_type);
4306-
CompilerType result_type = ToCompilerType(found_type);
4307-
assert(&found_type->getASTContext() == ast_ctx);
4303+
swift::TypeBase *ast_type =
4304+
ConvertSILFunctionTypesToASTFunctionTypes(found_type).getPointer();
4305+
// This transformation is lossy: all SILFunction types are mapped
4306+
// to the same AST type. We thus cannot cache the result, since
4307+
// the mapping isn't bijective.
4308+
if (ast_type == found_type)
4309+
CacheDemangledType(mangled_typename, ast_type);
4310+
CompilerType result_type = ToCompilerType(ast_type);
4311+
assert(&ast_type->getASTContext() == ast_ctx);
43084312
LOG_PRINTF(LIBLLDB_LOG_TYPES, "(\"%s\") -- found %s", mangled_cstr,
43094313
result_type.GetTypeName().GetCString());
4310-
return found_type;
4314+
return ast_type;
43114315
}
43124316

43134317
LOG_PRINTF(LIBLLDB_LOG_TYPES, "(\"%s\") -- not found", mangled_cstr);

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,12 @@ static bool ContainsSugaredParen(swift::Demangle::NodePointer node) {
14201420
/// Compare two swift types from different type systems by comparing their
14211421
/// (canonicalized) mangled name.
14221422
template <> bool Equivalent<CompilerType>(CompilerType l, CompilerType r) {
1423+
// See comments in SwiftASTContext::ReconstructType(). For
1424+
// SILFunctionTypes the mapping isn't bijective.
1425+
auto *ast_ctx = llvm::cast<SwiftASTContext>(r.GetTypeSystem());
1426+
if (((void *)ast_ctx->ReconstructType(l.GetMangledTypeName())) ==
1427+
r.GetOpaqueQualType())
1428+
return true;
14231429
ConstString lhs = l.GetMangledTypeName();
14241430
ConstString rhs = r.GetMangledTypeName();
14251431
if (lhs == ConstString("$sSiD") && rhs == ConstString("$sSuD"))
Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
1-
# TestSwiftTaggedPointer.py
2-
#
3-
# This source file is part of the Swift.org open source project
4-
#
5-
# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
6-
# Licensed under Apache License v2.0 with Runtime Library Exception
7-
#
8-
# See https://swift.org/LICENSE.txt for license information
9-
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10-
#
11-
# ------------------------------------------------------------------------------
12-
import lldbsuite.test.lldbinline as lldbinline
1+
import lldb
132
from lldbsuite.test.decorators import *
3+
import lldbsuite.test.lldbtest as lldbtest
4+
import lldbsuite.test.lldbutil as lldbutil
5+
import unittest2
146

15-
# This test depends on NSObject, so it is not available on non-Darwin
16-
# platforms.
17-
lldbinline.MakeInlineTest(__file__, globals(),
18-
decorators=[swiftTest,skipUnlessDarwin,
19-
skipIf(bugnumber="rdar://problem/66842937")])
7+
8+
class TestSwiftAnyType(lldbtest.TestBase):
9+
10+
mydir = lldbtest.TestBase.compute_mydir(__file__)
11+
12+
@swiftTest
13+
# This test depends on NSObject, so it is not available on non-Darwin
14+
# platforms.
15+
@skipUnlessDarwin
16+
def test(self):
17+
self.build()
18+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
19+
self, 'break here', lldb.SBFileSpec('main.swift'))
20+
21+
self.expect('frame variable -d run -- a', substrs=['Int64(3)'])
22+
self.expect('frame variable -d run -- b', substrs=['Int64(3)'])
23+
24+
self.expect('frame variable -d run -- c', substrs=['"hi"'])
25+
self.expect('frame variable -d run -- d', substrs=['"hi"'])
26+
27+
self.expect('expr -d run -- a', substrs=['Int64(3)'])
28+
self.expect('expr -d run -- b', substrs=['Int64(3)'])
29+
30+
self.expect('expr -d run -- c', substrs=['"hi"'])
31+
self.expect('expr -d run -- d', substrs=['"hi"'])

lldb/test/API/lang/swift/tagged_pointer/main.swift

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
// main.swift
2-
//
3-
// This source file is part of the Swift.org open source project
4-
//
5-
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
6-
// Licensed under Apache License v2.0 with Runtime Library Exception
7-
//
8-
// See https://swift.org/LICENSE.txt for license information
9-
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10-
//
11-
// -----------------------------------------------------------------------------
121
import Foundation
132

143
func main() {
@@ -18,17 +7,7 @@ func main() {
187
var c: NSObject = "hi" as NSString
198
var d: AnyObject = "hi" as NSString
209

21-
//% self.expect('frame variable -d run -- a', substrs=['Int64(3)'])
22-
//% self.expect('frame variable -d run -- b', substrs=['Int64(3)'])
23-
24-
//% self.expect('frame variable -d run -- c', substrs=['"hi"'])
25-
//% self.expect('frame variable -d run -- d', substrs=['"hi"'])
26-
27-
//% self.expect('expr -d run -- a', substrs=['Int64(3)'])
28-
//% self.expect('expr -d run -- b', substrs=['Int64(3)'])
29-
30-
//% self.expect('expr -d run -- c', substrs=['"hi"'])
31-
//% self.expect('expr -d run -- d', substrs=['"hi"'])
10+
print("break here")
3211
}
3312

3413
main()

0 commit comments

Comments
 (0)