[PATCH] D23003: [ObjC Availability] Warn upon unguarded use of partially available declaration

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 31 16:28:17 PDT 2016


erik.pilkington created this revision.
erik.pilkington added reviewers: manmanren, dexonsmith, dcoughlin.
erik.pilkington added a subscriber: cfe-commits.

This patch implements support for diagnostics for @available violations. This is done with a traversal of the AST after semantic analysis of a function where a partially available (based on availability attributes) use of a declaration is found. For example:

```
  if (@available(macos 10.12, *))
    fn_10_12();
  else
    fn_10_12(); // clang now emits a warning here
```

This patch also treats both branches of `if (@available(...))` checks as begin protected; being able to `goto` into them would break this feature. Also, `-Wpartial-availability` is now an alias of `-Wunguarded-availability`.

Up next is a patch to implement clang CodeGen support for `ObjCAvailabilityCheckExpr`, and another to provide fixits to suggest using @available.

This patch is part of a series that implements the feature I proposed here:
http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html


https://reviews.llvm.org/D23003

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/Stmt.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/ScopeInfo.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaStmt.cpp
  test/Sema/attr-availability.c
  test/SemaObjC/attr-availability.m
  test/SemaObjC/property-deprecated-warning.m
  test/SemaObjC/unguarded-availability.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23003.66256.patch
Type: text/x-patch
Size: 38173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160731/e9054463/attachment-0001.bin>


More information about the cfe-commits mailing list