Skip to content

[lldb] Fix an incorrect trigger of a per-module scratch context #9349

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 1 commit into from
Sep 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -1389,9 +1389,13 @@ SwiftExpressionParser::ParseAndImport(
// GetImplicitImports.
swift::performImportResolution(*source_file);

if (expr_diagnostics.HasErrors())
return make_error<ModuleImportError>(
llvm::toString(expr_diagnostics.GetAllErrors()));
if (expr_diagnostics.HasErrors()) {
// FIXME: This could be done more elegantly.
std::string msg = llvm::toString(expr_diagnostics.GetAllErrors());
if (StringRef(msg).contains(": could not build module "))
return make_error<ModuleImportError>(msg);
return llvm::createStringError(msg);

Choose a reason for hiding this comment

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

nit: let's std::move(msg) here and above, since those are likely big strings.

Copy link
Author

Choose a reason for hiding this comment

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

Is this not an optimization that Clang can do on its own?

Choose a reason for hiding this comment

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

Nope, not in the middle of an expression. Clang will move when you have a naked return. E.g. imagine you had an Error class (which cannot be copied) instead of a string, this compiles:

return error;

but this doesn't compile:

return foo(error);

}

std::unique_ptr<SwiftASTManipulator> code_manipulator;
if (repl || !playground) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil

@skipIf(bugnumber = "rdar://135575668")
class TestSwiftExprImport(TestBase):
# Don't run ClangImporter tests if Clangimporter is disabled.
@skipIf(setting=('symbols.use-swift-clangimporter', 'false'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class TestSwiftSimpleExpressions(TestBase):
@skipIf(bugnumber = "rdar://135575668")
@swiftTest
def test_simple_swift_expressions(self):
"""Tests that we can run simple Swift expressions correctly"""
Expand Down