Skip to content

Commit 155cbe1

Browse files
Merge pull request swiftlang#8093 from adrian-prantl/better-wording
Improve wording of progress update
2 parents b0bc446 + d912f94 commit 155cbe1

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

lldb/include/lldb/Utility/ConstString.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,14 @@ class ConstString {
183183

184184
// Implicitly convert \class ConstString instances to \class StringRef.
185185
operator llvm::StringRef() const { return GetStringRef(); }
186-
// Implicitly convert \class ConstString instances to \calss std::string_view.
187-
operator std::string_view() const { return std::string_view(m_string, GetLength()); }
186+
187+
// Implicitly convert \class ConstString instances to \class std::string_view.
188+
operator std::string_view() const {
189+
return std::string_view(m_string, GetLength());
190+
}
191+
192+
// Explicitly convert \class ConstString instances to \class std::string.
193+
explicit operator std::string() const { return GetString(); }
188194

189195
/// Get the string value as a C string.
190196
///
@@ -208,6 +214,9 @@ class ConstString {
208214
return llvm::StringRef(m_string, GetLength());
209215
}
210216

217+
/// Get the string value as a std::string
218+
std::string GetString() const { return std::string(m_string, GetLength()); }
219+
211220
/// Get the string value as a C string.
212221
///
213222
/// Get the value of the contained string as a NULL terminated C string

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8829,9 +8829,9 @@ bool SwiftASTContext::GetCompileUnitImportsImpl(
88298829
if (cu_imports.size() == 0)
88308830
return true;
88318831

8832-
Progress progress("Getting Swift compile unit imports",
8833-
compile_unit->GetPrimaryFile().GetFilename().GetCString(),
8834-
cu_imports.size());
8832+
std::string category = "Importing Swift module dependencies for ";
8833+
category += compile_unit->GetPrimaryFile().GetFilename();
8834+
Progress progress(category, "", cu_imports.size());
88358835
size_t completion = 0;
88368836
for (const SourceModule &module : cu_imports) {
88378837
progress.Increment(++completion, module.path.back().GetStringRef().str());

lldb/test/API/functionalities/progress_reporting/swift_progress_reporting/TestSwiftProgressReporting.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ def test_swift_progress_report(self):
3838
"Loading Swift module",
3939
"Importing modules used in expression",
4040
"Setting up Swift reflection",
41-
"Getting Swift compile unit imports",
41+
"Importing Swift module dependencies for main.swift",
4242
"Importing Swift modules",
4343
"Importing Swift standard library",
4444
]
4545

4646
while len(beacons):
4747
event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
4848
ret_args = lldb.SBDebugger.GetProgressFromEvent(event)
49+
if self.TraceOn():
50+
print(ret_args[0])
4951

5052
for beacon in beacons:
5153
if beacon in ret_args[0]:

lldb/unittests/Utility/ConstStringTest.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,17 @@ TEST(ConstStringTest, CompareStringRef) {
137137
EXPECT_TRUE(null == static_cast<const char *>(nullptr));
138138
EXPECT_TRUE(null != "bar");
139139
}
140+
141+
TEST(ConstStringTest, StringConversions) {
142+
ConstString foo("foo");
143+
144+
// Member functions.
145+
EXPECT_EQ(llvm::StringRef("foo"), foo.GetStringRef());
146+
EXPECT_EQ(std::string("foo"), foo.GetString());
147+
EXPECT_STREQ("foo", foo.AsCString());
148+
149+
// Conversion operators.
150+
EXPECT_EQ(llvm::StringRef("foo"), llvm::StringRef(foo));
151+
EXPECT_EQ(std::string("foo"), std::string_view(foo));
152+
EXPECT_EQ(std::string("foo"), std::string(foo));
153+
}

0 commit comments

Comments
 (0)