Skip to content

Sema: Fix a null dereference when diagnosing a call to a renamed function #69999

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
Nov 27, 2023
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
6 changes: 3 additions & 3 deletions lib/Sema/TypeCheckAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2420,12 +2420,12 @@ static void fixItAvailableAttrRename(InFlightDiagnostic &diag,
}
}
}
// Function names are the same(including context if applicable), so
// Function names are the same (including context if applicable), so
// renaming fix-it doesn't need do be produced.
auto calledValue = CE->getCalledValue(/*skipFunctionConversions=*/true);
if ((parsed.ContextName.empty() ||
parsed.ContextName == callContextName) &&
CE->getCalledValue(/*skipFunctionConversions=*/true)
->getBaseName() == parsed.BaseName) {
calledValue && calledValue->getBaseName() == parsed.BaseName) {
shouldEmitRenameFixit = false;
}
}
Expand Down
5 changes: 4 additions & 1 deletion test/attr/attr_availability.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift
// RUN: %target-typecheck-verify-swift -module-name Test

@available(*, unavailable)
func unavailable_func() {}
Expand Down Expand Up @@ -204,6 +204,9 @@ func use_deprecated_with_renamed() {
deprecated_func_with_renamed() // expected-warning{{'deprecated_func_with_renamed()' is deprecated: renamed to 'blarg'}}
// expected-note@-1{{use 'blarg'}}{{3-31=blarg}}

Test.deprecated_func_with_renamed() // expected-warning{{'deprecated_func_with_renamed()' is deprecated: renamed to 'blarg'}}
// expected-note@-1{{use 'blarg' instead}}

deprecated_func_with_message_renamed() //expected-warning{{'deprecated_func_with_message_renamed()' is deprecated: blarg is your friend}}
// expected-note@-1{{use 'blarg'}}{{3-39=blarg}}

Expand Down