This is an archive of the discontinued LLVM Phabricator instance.

[ObjC Availability] Consider lexical context of use of declaration when emitting availability diagnostics
ClosedPublic

Authored by erik.pilkington on Jul 22 2016, 1:55 PM.

Details

Summary

-Wpartial-availability currently fires on the following:

void f1() __attribute__((availability(macos, introduced=10.10)));

void f2() __attribute__((availability(macos, introduced=10.10))) {
  f1(); // warning: f1 is partially available: introduced in 10.10.
}

This is bad: f2 is also only available on macOS 10.10, so we know that the call to f1 is safe. This patch fixes this by considering the availability attributes of the lexical context of a use of a declaration when checking it for availability violations.

Thanks!

Diff Detail

Repository
rL LLVM

Event Timeline

erik.pilkington retitled this revision from to [ObjC Availability] Consider lexical context of use of declaration when emitting availability diagnostics.
erik.pilkington updated this object.
erik.pilkington added a reviewer: manmanren.
erik.pilkington added a subscriber: cfe-commits.
manmanren accepted this revision.Jul 25 2016, 2:45 PM
manmanren edited edge metadata.

LGTM except one nit.

Manman

include/clang/Sema/Sema.h
9595 ↗(On Diff #65139)

Can you add comments here?

This revision is now accepted and ready to land.Jul 25 2016, 2:45 PM
erik.pilkington edited edge metadata.

Thanks for taking a look!

This new patch makes a getCurContextVersion (now getVersionForDecl) take a parameter, which is the declaration that needs to be considered. This is so that we can later reuse it to check for @available(...) violations, which will be diagnosed after Sema leaves the context of the declaration we are checking. Does this still LG?

Yes, this still looks good to me. Please commit.

Manman

This revision was automatically updated to reflect the committed changes.