Skip to content

Commit 9631b3c

Browse files
authored
Merge pull request #1881 from apple/dl/lldb-Stop-unconditionally-emitting-could-not-resolve-type
[lldb] Stop unconditionally emitting "could not resolve type"
2 parents 761636a + 8863d99 commit 9631b3c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7923,8 +7923,7 @@ void SwiftASTContext::DumpTypeDescription(opaque_compiler_type_t type,
79237923
bool print_help_if_available,
79247924
bool print_extensions_if_available,
79257925
lldb::DescriptionLevel level) {
7926-
llvm::SmallVector<char, 1024> buf;
7927-
llvm::raw_svector_ostream llvm_ostrm(buf);
7926+
const auto initial_written_bytes = s->GetWrittenBytes();
79287927

79297928
if (type) {
79307929
swift::CanType swift_can_type(GetCanonicalSwiftType(type));
@@ -8088,12 +8087,10 @@ void SwiftASTContext::DumpTypeDescription(opaque_compiler_type_t type,
80888087
}
80898088
} break;
80908089
}
8091-
8092-
if (buf.size() > 0) {
8093-
s->Write(buf.data(), buf.size());
8094-
}
80958090
}
8096-
s->Printf("<could not resolve type>");
8091+
8092+
if (s->GetWrittenBytes() == initial_written_bytes)
8093+
s->Printf("<could not resolve type>");
80978094
}
80988095

80998096
TypeSP SwiftASTContext::GetCachedType(ConstString mangled) {

lldb/test/API/lang/swift/printdecl/TestSwiftTypeLookup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def test_swift_type_lookup(self):
5656
'func bar()',
5757
'var b'])
5858

59+
# Regression test. Ensure "<could not resolve type>" is not output.
60+
self.expect(
61+
"type lookup String",
62+
matching=False,
63+
substrs=["<could not resolve type>"])
64+
5965
# check that specifiers are honored
6066
# self.expect('type lookup class Cla1', substrs=['class Cla1 {'])
6167
# self.expect('type lookup struct Cla1', substrs=['class Cla1 {'], matching=False, error=True)

0 commit comments

Comments
 (0)