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

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 11 11:51:45 PDT 2016


erik.pilkington updated this revision to Diff 67713.
erik.pilkington added a comment.

This new patch adds some testcases for templates, and simplifies some control flow in `TraverseIfStmt`. This patch also removes diagnostics for instantiated templates, instead just using the pattern. This means that a dependent type that was resolved during instantiation can refer to an unavailable declaration. For example, the following now compiles cleanly (when we want a diagnostic):

  void f(int);
  void f(char) __attribute__((availability(macos, introduced=10.12)));
  
  template <class T> void use_f(T p) { f(p); }
  
  template void use_f<char>();

This is done so containers, such as `vector<partially_available>` can be used safely provided `partially_available` is safe at the point of instantiation. I think the way to improve this is in `Sema::getVersionForDecl()`. There we could look at function and template parameters to determine the best base version, then diagnose against it.


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/Parser/objc-available.m
  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.67713.patch
Type: text/x-patch
Size: 34826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160811/b0dedf3f/attachment-0001.bin>


More information about the cfe-commits mailing list