Skip to content

Commit 9012800

Browse files
committed
Revert "[lldb] Initialize a shared, blank SwiftASTContext in Objective-C frames" (#10942)
The new behavior break Playgrounds. This reverts commit b5a1d34. (cherry picked from commit 771130a)
1 parent fb07c2c commit 9012800

File tree

14 files changed

+129
-83
lines changed

14 files changed

+129
-83
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,18 +2703,17 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
27032703

27042704
CompileUnit *cu = sc.comp_unit;
27052705
const char *key = TypeSystemSwiftTypeRef::DeriveKeyFor(sc);
2706-
bool swift_context = cu && cu->GetLanguage() == eLanguageTypeSwift;
27072706
std::string m_description;
27082707
{
27092708
StreamString ss;
27102709
ss << "SwiftASTContext";
27112710
if (for_expressions)
27122711
ss << "ForExpressions";
27132712
ss << "(module: " << '"' << key << "\", " << "cu: " << '"';
2714-
if (cu && swift_context)
2713+
if (cu)
27152714
ss << cu->GetPrimaryFile().GetFilename();
27162715
else
2717-
ss << "*";
2716+
ss << "null";
27182717
ss << '"' << ')';
27192718
m_description = ss.GetString();
27202719
}
@@ -2794,8 +2793,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
27942793
ModuleList module_module;
27952794
if (!target_sp)
27962795
module_module.Append(module_sp);
2797-
ModuleList &modules =
2798-
(target_sp && swift_context) ? target_sp->GetImages() : module_module;
2796+
ModuleList &modules = target_sp ? target_sp->GetImages() : module_module;
27992797
const size_t num_images = modules.GetSize();
28002798

28012799
// Set the SDK path prior to doing search paths. Otherwise when we
@@ -3131,8 +3129,7 @@ SwiftASTContext::CreateInstance(const SymbolContext &sc,
31313129
}
31323130
}
31333131
};
3134-
if (swift_context)
3135-
scan_module(module_sp, 0);
3132+
scan_module(module_sp, 0);
31363133
for (size_t mi = 0; mi != num_images; ++mi) {
31373134
auto image_sp = modules.GetModuleAtIndex(mi);
31383135
if (!visited_modules.count(image_sp.get()))

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,14 +2103,15 @@ ConstString TypeSystemSwiftTypeRef::GetSwiftModuleFor(const SymbolContext &sc) {
21032103
}
21042104

21052105
const char *TypeSystemSwiftTypeRef::DeriveKeyFor(const SymbolContext &sc) {
2106-
if (sc.comp_unit && sc.comp_unit->GetLanguage() == eLanguageTypeSwift)
2106+
if (sc.function)
21072107
if (ConstString name = GetSwiftModuleFor(sc))
21082108
return name.GetCString();
21092109

2110-
// Otherwise create a catch-all context per unique triple.
2111-
if (sc.module_sp)
2112-
return ConstString(sc.module_sp->GetArchitecture().GetTriple().str()).AsCString();
2113-
2110+
if (sc.module_sp) {
2111+
if (sc.module_sp->GetFileSpec())
2112+
return sc.module_sp->GetFileSpec().GetFilename().GetCString();
2113+
return sc.module_sp->GetObjectName().GetCString();
2114+
}
21142115
return nullptr;
21152116
}
21162117

@@ -2593,9 +2594,6 @@ template <> bool Equivalent<CompilerType>(CompilerType l, CompilerType r) {
25932594
ConstString rhs = r.GetMangledTypeName();
25942595
if (lhs == ConstString("$sSiD") && rhs == ConstString("$sSuD"))
25952596
return true;
2596-
if (lhs.GetStringRef() == "$sSPySo0023unnamedstruct_hEEEdhdEaVGSgD" &&
2597-
rhs.GetStringRef() == "$ss13OpaquePointerVSgD")
2598-
return true;
25992597
// Ignore missing sugar.
26002598
swift::Demangle::Demangler dem;
26012599
auto l_node = GetDemangledType(dem, lhs.GetStringRef());

lldb/test/API/lang/swift/po/objc/Base.h

Lines changed: 0 additions & 3 deletions
This file was deleted.

lldb/test/API/lang/swift/po/objc/Foo.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

lldb/test/API/lang/swift/po/objc/Makefile

Lines changed: 0 additions & 9 deletions
This file was deleted.

lldb/test/API/lang/swift/po/objc/TestSwiftPOObjC.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

lldb/test/API/lang/swift/po/objc/main.m

Lines changed: 0 additions & 13 deletions
This file was deleted.

lldb/test/API/lang/swift/po/objc/module.modulemap

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFExecutableName</key>
6+
<string>test</string>
7+
</dict>
8+
</plist>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
all: dylib xctest
2+
C_SOURCES=xctest.c
3+
EXE=xctest
4+
5+
include Makefile.rules
6+
7+
.PHONY: dylib
8+
dylib:
9+
"$(MAKE)" MAKE_DSYM=$(MAKE_DSYM) CC=$(CC) SWIFTC=$(SWIFTC) \
10+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
11+
VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dylib.mk all
12+
13+
clean::
14+
rm -rf *.o *.dSYM *.dylib *.swiftdoc *.swiftmodule *.xctest xctest
15+
"$(MAKE)" VPATH=$(SRCDIR) -f $(SRCDIR)/dylib.mk clean
16+

0 commit comments

Comments
 (0)