diff options
Diffstat (limited to 'include/clang/AST/ExprObjC.h')
-rw-r--r-- | include/clang/AST/ExprObjC.h | 87 |
1 files changed, 77 insertions, 10 deletions
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index c7b305f3304e..dbb2b2ff7099 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -1,9 +1,8 @@ //===- ExprObjC.h - Classes for representing ObjC expressions ---*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -73,6 +72,10 @@ public: // Iterators child_range children() { return child_range(&String, &String+1); } + const_child_range children() const { + return const_child_range(&String, &String + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCStringLiteralClass; } @@ -105,6 +108,10 @@ public: return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCBoolLiteralExprClass; } @@ -139,6 +146,12 @@ public: return BoxingMethod; } + // Indicates whether this boxed expression can be emitted as a compile-time + // constant. + bool isExpressibleAsConstantInitializer() const { + return !BoxingMethod && SubExpr; + } + SourceLocation getAtLoc() const { return Range.getBegin(); } SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); } @@ -151,6 +164,10 @@ public: // Iterators child_range children() { return child_range(&SubExpr, &SubExpr+1); } + const_child_range children() const { + return const_child_range(&SubExpr, &SubExpr + 1); + } + using const_arg_iterator = ConstExprIterator; const_arg_iterator arg_begin() const { @@ -229,6 +246,11 @@ public: reinterpret_cast<Stmt **>(getElements()) + NumElements); } + const_child_range children() const { + auto Children = const_cast<ObjCArrayLiteral *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCArrayLiteralClass; } @@ -256,12 +278,6 @@ struct ObjCDictionaryElement { } // namespace clang -namespace llvm { - -template <> struct isPodLike<clang::ObjCDictionaryElement> : std::true_type {}; - -} // namespace llvm - namespace clang { /// Internal struct for storing Key/value pair. @@ -375,6 +391,11 @@ public: NumElements * 2); } + const_child_range children() const { + auto Children = const_cast<ObjCDictionaryLiteral *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCDictionaryLiteralClass; } @@ -420,6 +441,10 @@ public: return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCEncodeExprClass; } @@ -458,6 +483,10 @@ public: return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCSelectorExprClass; } @@ -504,6 +533,10 @@ public: return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCProtocolExprClass; } @@ -567,6 +600,10 @@ public: // Iterators child_range children() { return child_range(&Base, &Base+1); } + const_child_range children() const { + return const_child_range(&Base, &Base + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCIvarRefExprClass; } @@ -758,6 +795,11 @@ public: return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + auto Children = const_cast<ObjCPropertyRefExpr *>(this)->children(); + return const_child_range(Children.begin(), Children.end()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCPropertyRefExprClass; } @@ -867,6 +909,10 @@ public: return child_range(SubExprs, SubExprs+END_EXPR); } + const_child_range children() const { + return const_child_range(SubExprs, SubExprs + END_EXPR); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCSubscriptRefExprClass; } @@ -1187,6 +1233,13 @@ public: /// sent to. ReceiverKind getReceiverKind() const { return (ReceiverKind)Kind; } + /// \return the return type of the message being sent. + /// This is not always the type of the message expression itself because + /// of references (the expression would not have a reference type). + /// It is also not always the declared return type of the method because + /// of `instancetype` (in that case it's an expression type). + QualType getCallReturnType(ASTContext &Ctx) const; + /// Source range of the receiver. SourceRange getReceiverRange() const; @@ -1402,6 +1455,8 @@ public: // Iterators child_range children(); + const_child_range children() const; + using arg_iterator = ExprIterator; using const_arg_iterator = ConstExprIterator; @@ -1488,6 +1543,10 @@ public: // Iterators child_range children() { return child_range(&Base, &Base+1); } + const_child_range children() const { + return const_child_range(&Base, &Base + 1); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCIsaExprClass; } @@ -1549,6 +1608,10 @@ public: child_range children() { return child_range(&Operand, &Operand+1); } + const_child_range children() const { + return const_child_range(&Operand, &Operand + 1); + } + // Source locations are determined by the subexpression. SourceLocation getBeginLoc() const LLVM_READONLY { return Operand->getBeginLoc(); @@ -1661,6 +1724,10 @@ public: return child_range(child_iterator(), child_iterator()); } + const_child_range children() const { + return const_child_range(const_child_iterator(), const_child_iterator()); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAvailabilityCheckExprClass; } |