From 29099ded0c1546dac891cf5510fd611a1d1992a5 Mon Sep 17 00:00:00 2001 From: Erik Pilkington Date: Sat, 16 Jul 2016 00:35:23 +0000 Subject: [ObjC] Implement @available in the Parser and AST This patch adds a new AST node: ObjCAvailabilityCheckExpr, and teaches the Parser and Sema to generate it. This node represents an availability check of the form: @available(macos 10.10, *); Which will eventually compile to a runtime check of the host's OS version. This is the first patch of the feature I proposed here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html Differential Revision: https://reviews.llvm.org/D22171 llvm-svn: 275654 --- clang/lib/Serialization/ASTReaderStmt.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'clang/lib/Serialization/ASTReaderStmt.cpp') diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index 2fa3a4400bc..395da42d4f2 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -1182,6 +1182,14 @@ void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) { E->setLocation(ReadSourceLocation(Record, Idx)); } +void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) { + VisitExpr(E); + SourceRange R = Reader.ReadSourceRange(F, Record, Idx); + E->AtLoc = R.getBegin(); + E->RParen = R.getEnd(); + E->VersionToCheck = Reader.ReadVersionTuple(Record, Idx); +} + //===----------------------------------------------------------------------===// // C++ Expressions and Statements //===----------------------------------------------------------------------===// @@ -3221,6 +3229,9 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { case EXPR_OBJC_BOOL_LITERAL: S = new (Context) ObjCBoolLiteralExpr(Empty); break; + case EXPR_OBJC_AVAILABILITY_CHECK: + S = new (Context) ObjCAvailabilityCheckExpr(Empty); + break; case STMT_SEH_LEAVE: S = new (Context) SEHLeaveStmt(Empty); break; -- cgit v1.2.3