Skip to content
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