Skip to content

[ClangImporter] Defend against ObjC properties without getters #17429

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 22, 2018
Merged
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
17 changes: 11 additions & 6 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4891,13 +4891,18 @@ namespace {
Impl.recordImplicitUnwrapForDecl(result,
importedType.isImplicitlyUnwrapped());

// Recover from a missing getter in no-asserts builds. We're still not
// sure under what circumstances this occurs, but we shouldn't crash.
auto clangGetter = decl->getGetterMethodDecl();
assert(clangGetter && "ObjC property without getter");
if (!clangGetter)
return nullptr;

// Import the getter.
AccessorDecl *getter = nullptr;
if (auto clangGetter = decl->getGetterMethodDecl()) {
getter = importAccessor(clangGetter, result, AccessorKind::Get, dc);
if (!getter)
return nullptr;
}
AccessorDecl *getter = importAccessor(clangGetter, result,
AccessorKind::Get, dc);
if (!getter)
return nullptr;

// Import the setter, if there is one.
AccessorDecl *setter = nullptr;
Expand Down