Skip to content

Don't create a Module SwiftASTContext when the stdlib is missing #1391

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
Jun 30, 2020

Conversation

vedantk
Copy link

@vedantk vedantk commented Jun 29, 2020

A Module SwiftASTContext that cannot access the stdlib module will crash
when performing simple actions, like looking up a type.

This patch tries to make the Target/Module overrides of CreateInstance
look more like each other, w.r.t error handling in particular.

rdar://57695158, rdar://64828733

A Module SwiftASTContext that cannot access the stdlib module will crash
when performing simple actions, like looking up a type.

This patch tries to make the Target/Module overrides of CreateInstance
look more like each other, w.r.t error handling in particular.

rdar://57695158, rdar://64828733
@vedantk vedantk requested review from adrian-prantl and dcci June 29, 2020 21:21
@vedantk
Copy link
Author

vedantk commented Jun 29, 2020

@swift-ci test


ArchSpec arch = module.GetArchitecture();
if (!arch.IsValid()) {
logError("invalid module architecture");
return TypeSystemSP();

Choose a reason for hiding this comment

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

I usually write the default return value as return {}, since the concrete type doesn't matter that much to the reader.

Copy link
Author

Choose a reason for hiding this comment

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

Will fix.

Choose a reason for hiding this comment

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

Really just stylistic preference :-)

if (!objfile) {
logError("no object file for module");
return TypeSystemSP();
}

Choose a reason for hiding this comment

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

do we want similar changes in CreateInstance(..., Target &) (the one that creates the expression context)?

Copy link
Author

Choose a reason for hiding this comment

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

I looked through the other override and started re-arranging it, but decided to leave those changes out of this patch as they're entirely cosmetic. (I didn't find any missing checks.)

@@ -1654,7 +1676,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
std::string target_triple;

if (sym_file) {
bool got_serialized_options;
bool got_serialized_options = false;

Choose a reason for hiding this comment

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

ouch!

Copy link
Author

Choose a reason for hiding this comment

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

This one is not so bad, I don't believe got_serialized_options is actually used, this is just some future-proofing. I can leave it out if you prefer.

Copy link

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

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

Good catch! This is a regression compared with the pre-DWARFImporter days.
I would be in favor of also landing this on 5.3
It will make diagnosing errors much easier.

@vedantk vedantk merged commit a1bb7ac into swiftlang:swift/master Jun 30, 2020
@vedantk vedantk deleted the check-for-stdlib branch June 30, 2020 00:25
vedantk added a commit that referenced this pull request Jun 30, 2020
Copy link
Member

@dcci dcci left a comment

Choose a reason for hiding this comment

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

As discussed in private, this is good. Thanks for taking care of this Vedant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants