[PATCH] D22171: [ObjC Availability] Implement parser support for Objective-C's @available

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 8 14:12:50 PDT 2016


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

This patch is the first of the feature I proposed on Monday here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html

This patch adds a new AST node, `ObjCAvailabilityCheckExpr`, and teaches the parser and Sema to build it. Currently, if compiled without `-fsyntax-only`, Clang errors out in CodeGen. Up next is a patch that implements the availability violation warning itself, then CodeGen support.

`ObjCAvailabilityCheckExpr` is an predicate expression that will end up compiling into a runtime check of the host's OS version. It can be spelled in two ways:
```
  @available(macos 10.10, *); // Objective-C only
  __builtin_available(macos 10.10, *); // C, C++, and Objective-C
```

It's main purpose in life is to guard calls to API calls that are marked with an `__attribute__((availability()))` greater than the current deployment target, so users can safely use new APIs while still supporting old OS versions.

Thanks!

http://reviews.llvm.org/D22171

Files:
  include/clang-c/Index.h
  include/clang/AST/Availability.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/StmtNodes.td
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/VersionTuple.h
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseObjc.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Parser/objc-available.m
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22171.63310.patch
Type: text/x-patch
Size: 29874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160708/02f6131c/attachment-0001.bin>


More information about the cfe-commits mailing list