Skip to content

Improve wording of progress update #8093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lldb/include/lldb/Utility/ConstString.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,14 @@ class ConstString {

// Implicitly convert \class ConstString instances to \class StringRef.
operator llvm::StringRef() const { return GetStringRef(); }
// Implicitly convert \class ConstString instances to \calss std::string_view.
operator std::string_view() const { return std::string_view(m_string, GetLength()); }

// Implicitly convert \class ConstString instances to \class std::string_view.
operator std::string_view() const {
return std::string_view(m_string, GetLength());
}

// Explicitly convert \class ConstString instances to \class std::string.
explicit operator std::string() const { return GetString(); }

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

/// Get the string value as a std::string
std::string GetString() const { return std::string(m_string, GetLength()); }

/// Get the string value as a C string.
///
/// Get the value of the contained string as a NULL terminated C string
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8829,9 +8829,9 @@ bool SwiftASTContext::GetCompileUnitImportsImpl(
if (cu_imports.size() == 0)
return true;

Progress progress("Getting Swift compile unit imports",
compile_unit->GetPrimaryFile().GetFilename().GetCString(),
cu_imports.size());
std::string category = "Importing Swift module dependencies for ";
category += compile_unit->GetPrimaryFile().GetFilename();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would main.swift always be the primary filename here? The category would be "Importing Swift module dependencies for main.swift" which I think works as a category name (as opposed to "Importing Swift module dependencies for"), I just wanna make sure that the filename here wouldn't change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is we're debugging main.swift, which contains

import Foundation
import Cocoa

and then we should get:

Importing Swift module dependencies for main.swift: Foundation
Importing Swift module dependencies for main.swift: Cocoa

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in short: yes!

Progress progress(category, "", cu_imports.size());
size_t completion = 0;
for (const SourceModule &module : cu_imports) {
progress.Increment(++completion, module.path.back().GetStringRef().str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ def test_swift_progress_report(self):
"Loading Swift module",
"Importing modules used in expression",
"Setting up Swift reflection",
"Getting Swift compile unit imports",
"Importing Swift module dependencies for main.swift",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We're only doing partial string matching on the test so we could have drop the file name at the end.

"Importing Swift modules",
"Importing Swift standard library",
]

while len(beacons):
event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
ret_args = lldb.SBDebugger.GetProgressFromEvent(event)
if self.TraceOn():
print(ret_args[0])

for beacon in beacons:
if beacon in ret_args[0]:
Expand Down
14 changes: 14 additions & 0 deletions lldb/unittests/Utility/ConstStringTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,17 @@ TEST(ConstStringTest, CompareStringRef) {
EXPECT_TRUE(null == static_cast<const char *>(nullptr));
EXPECT_TRUE(null != "bar");
}

TEST(ConstStringTest, StringConversions) {
ConstString foo("foo");

// Member functions.
EXPECT_EQ(llvm::StringRef("foo"), foo.GetStringRef());
EXPECT_EQ(std::string("foo"), foo.GetString());
EXPECT_STREQ("foo", foo.AsCString());

// Conversion operators.
EXPECT_EQ(llvm::StringRef("foo"), llvm::StringRef(foo));
EXPECT_EQ(std::string("foo"), std::string_view(foo));
EXPECT_EQ(std::string("foo"), std::string(foo));
}