clang 18.0.0git
ExprObjC.h
Go to the documentation of this file.
1//===- ExprObjC.h - Classes for representing ObjC expressions ---*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the ExprObjC interface and subclasses.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_EXPROBJC_H
14#define LLVM_CLANG_AST_EXPROBJC_H
15
17#include "clang/AST/Decl.h"
18#include "clang/AST/DeclObjC.h"
20#include "clang/AST/Expr.h"
23#include "clang/AST/Stmt.h"
24#include "clang/AST/Type.h"
26#include "clang/Basic/LLVM.h"
29#include "llvm/ADT/ArrayRef.h"
30#include "llvm/ADT/PointerIntPair.h"
31#include "llvm/ADT/PointerUnion.h"
32#include "llvm/ADT/StringRef.h"
33#include "llvm/ADT/iterator_range.h"
34#include "llvm/Support/Casting.h"
35#include "llvm/Support/Compiler.h"
36#include "llvm/Support/TrailingObjects.h"
37#include "llvm/Support/VersionTuple.h"
38#include "llvm/Support/type_traits.h"
39#include <cassert>
40#include <cstddef>
41#include <cstdint>
42#include <optional>
43
44namespace clang {
45
46class ASTContext;
47class CXXBaseSpecifier;
48
49/// ObjCStringLiteral, used for Objective-C string literals
50/// i.e. @"foo".
51class ObjCStringLiteral : public Expr {
52 Stmt *String;
53 SourceLocation AtLoc;
54
55public:
57 : Expr(ObjCStringLiteralClass, T, VK_PRValue, OK_Ordinary), String(SL),
58 AtLoc(L) {
59 setDependence(ExprDependence::None);
60 }
62 : Expr(ObjCStringLiteralClass, Empty) {}
63
64 StringLiteral *getString() { return cast<StringLiteral>(String); }
65 const StringLiteral *getString() const { return cast<StringLiteral>(String); }
66 void setString(StringLiteral *S) { String = S; }
67
68 SourceLocation getAtLoc() const { return AtLoc; }
69 void setAtLoc(SourceLocation L) { AtLoc = L; }
70
71 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
72 SourceLocation getEndLoc() const LLVM_READONLY { return String->getEndLoc(); }
73
74 // Iterators
75 child_range children() { return child_range(&String, &String+1); }
76
78 return const_child_range(&String, &String + 1);
79 }
80
81 static bool classof(const Stmt *T) {
82 return T->getStmtClass() == ObjCStringLiteralClass;
83 }
84};
85
86/// ObjCBoolLiteralExpr - Objective-C Boolean Literal.
87class ObjCBoolLiteralExpr : public Expr {
88 bool Value;
90
91public:
93 : Expr(ObjCBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary), Value(val),
94 Loc(l) {
95 setDependence(ExprDependence::None);
96 }
98 : Expr(ObjCBoolLiteralExprClass, Empty) {}
99
100 bool getValue() const { return Value; }
101 void setValue(bool V) { Value = V; }
102
103 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
104 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
105
106 SourceLocation getLocation() const { return Loc; }
107 void setLocation(SourceLocation L) { Loc = L; }
108
109 // Iterators
112 }
113
116 }
117
118 static bool classof(const Stmt *T) {
119 return T->getStmtClass() == ObjCBoolLiteralExprClass;
120 }
121};
122
123/// ObjCBoxedExpr - used for generalized expression boxing.
124/// as in: @(strdup("hello world")), @(random()) or @(view.frame)
125/// Also used for boxing non-parenthesized numeric literals;
126/// as in: @42 or \@true (c++/objc++) or \@__objc_yes (c/objc).
127class ObjCBoxedExpr : public Expr {
128 Stmt *SubExpr;
129 ObjCMethodDecl *BoxingMethod;
130 SourceRange Range;
131
132public:
133 friend class ASTStmtReader;
134
136 : Expr(ObjCBoxedExprClass, T, VK_PRValue, OK_Ordinary), SubExpr(E),
137 BoxingMethod(method), Range(R) {
139 }
140 explicit ObjCBoxedExpr(EmptyShell Empty)
141 : Expr(ObjCBoxedExprClass, Empty) {}
142
143 Expr *getSubExpr() { return cast<Expr>(SubExpr); }
144 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
145
147 return BoxingMethod;
148 }
149
150 // Indicates whether this boxed expression can be emitted as a compile-time
151 // constant.
153 return !BoxingMethod && SubExpr;
154 }
155
156 SourceLocation getAtLoc() const { return Range.getBegin(); }
157
158 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
159 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
160
161 SourceRange getSourceRange() const LLVM_READONLY {
162 return Range;
163 }
164
165 // Iterators
166 child_range children() { return child_range(&SubExpr, &SubExpr+1); }
167
169 return const_child_range(&SubExpr, &SubExpr + 1);
170 }
171
173
175 return reinterpret_cast<Stmt const * const*>(&SubExpr);
176 }
177
179 return reinterpret_cast<Stmt const * const*>(&SubExpr + 1);
180 }
181
182 static bool classof(const Stmt *T) {
183 return T->getStmtClass() == ObjCBoxedExprClass;
184 }
185};
186
187/// ObjCArrayLiteral - used for objective-c array containers; as in:
188/// @[@"Hello", NSApp, [NSNumber numberWithInt:42]];
190 : public Expr,
191 private llvm::TrailingObjects<ObjCArrayLiteral, Expr *> {
192 unsigned NumElements;
193 SourceRange Range;
194 ObjCMethodDecl *ArrayWithObjectsMethod;
195
197 QualType T, ObjCMethodDecl * Method,
198 SourceRange SR);
199
200 explicit ObjCArrayLiteral(EmptyShell Empty, unsigned NumElements)
201 : Expr(ObjCArrayLiteralClass, Empty), NumElements(NumElements) {}
202
203public:
204 friend class ASTStmtReader;
206
207 static ObjCArrayLiteral *Create(const ASTContext &C,
208 ArrayRef<Expr *> Elements,
209 QualType T, ObjCMethodDecl * Method,
210 SourceRange SR);
211
213 unsigned NumElements);
214
215 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
216 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
217 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
218
219 /// Retrieve elements of array of literals.
220 Expr **getElements() { return getTrailingObjects<Expr *>(); }
221
222 /// Retrieve elements of array of literals.
223 const Expr * const *getElements() const {
224 return getTrailingObjects<Expr *>();
225 }
226
227 /// getNumElements - Return number of elements of objective-c array literal.
228 unsigned getNumElements() const { return NumElements; }
229
230 /// getElement - Return the Element at the specified index.
231 Expr *getElement(unsigned Index) {
232 assert((Index < NumElements) && "Arg access out of range!");
233 return getElements()[Index];
234 }
235 const Expr *getElement(unsigned Index) const {
236 assert((Index < NumElements) && "Arg access out of range!");
237 return getElements()[Index];
238 }
239
241 return ArrayWithObjectsMethod;
242 }
243
244 // Iterators
246 return child_range(reinterpret_cast<Stmt **>(getElements()),
247 reinterpret_cast<Stmt **>(getElements()) + NumElements);
248 }
249
251 auto Children = const_cast<ObjCArrayLiteral *>(this)->children();
252 return const_child_range(Children.begin(), Children.end());
253 }
254
255 static bool classof(const Stmt *T) {
256 return T->getStmtClass() == ObjCArrayLiteralClass;
257 }
258};
259
260/// An element in an Objective-C dictionary literal.
261///
263 /// The key for the dictionary element.
265
266 /// The value of the dictionary element.
268
269 /// The location of the ellipsis, if this is a pack expansion.
271
272 /// The number of elements this pack expansion will expand to, if
273 /// this is a pack expansion and is known.
274 std::optional<unsigned> NumExpansions;
275
276 /// Determines whether this dictionary element is a pack expansion.
277 bool isPackExpansion() const { return EllipsisLoc.isValid(); }
278};
279
280} // namespace clang
281
282namespace clang {
283
284/// Internal struct for storing Key/value pair.
288};
289
290/// Internal struct to describes an element that is a pack
291/// expansion, used if any of the elements in the dictionary literal
292/// are pack expansions.
294 /// The location of the ellipsis, if this element is a pack
295 /// expansion.
297
298 /// If non-zero, the number of elements that this pack
299 /// expansion will expand to (+1).
301};
302
303/// ObjCDictionaryLiteral - AST node to represent objective-c dictionary
304/// literals; as in: @{@"name" : NSUserName(), @"date" : [NSDate date] };
306 : public Expr,
307 private llvm::TrailingObjects<ObjCDictionaryLiteral,
308 ObjCDictionaryLiteral_KeyValuePair,
309 ObjCDictionaryLiteral_ExpansionData> {
310 /// The number of elements in this dictionary literal.
311 unsigned NumElements : 31;
312
313 /// Determine whether this dictionary literal has any pack expansions.
314 ///
315 /// If the dictionary literal has pack expansions, then there will
316 /// be an array of pack expansion data following the array of
317 /// key/value pairs, which provide the locations of the ellipses (if
318 /// any) and number of elements in the expansion (if known). If
319 /// there are no pack expansions, we optimize away this storage.
320 unsigned HasPackExpansions : 1;
321
322 SourceRange Range;
323 ObjCMethodDecl *DictWithObjectsMethod;
324
327
329 bool HasPackExpansions,
330 QualType T, ObjCMethodDecl *method,
331 SourceRange SR);
332
333 explicit ObjCDictionaryLiteral(EmptyShell Empty, unsigned NumElements,
334 bool HasPackExpansions)
335 : Expr(ObjCDictionaryLiteralClass, Empty), NumElements(NumElements),
336 HasPackExpansions(HasPackExpansions) {}
337
338 size_t numTrailingObjects(OverloadToken<KeyValuePair>) const {
339 return NumElements;
340 }
341
342public:
343 friend class ASTStmtReader;
344 friend class ASTStmtWriter;
346
349 bool HasPackExpansions,
350 QualType T, ObjCMethodDecl *method,
351 SourceRange SR);
352
354 unsigned NumElements,
355 bool HasPackExpansions);
356
357 /// getNumElements - Return number of elements of objective-c dictionary
358 /// literal.
359 unsigned getNumElements() const { return NumElements; }
360
362 assert((Index < NumElements) && "Arg access out of range!");
363 const KeyValuePair &KV = getTrailingObjects<KeyValuePair>()[Index];
365 std::nullopt};
366 if (HasPackExpansions) {
367 const ExpansionData &Expansion =
368 getTrailingObjects<ExpansionData>()[Index];
369 Result.EllipsisLoc = Expansion.EllipsisLoc;
370 if (Expansion.NumExpansionsPlusOne > 0)
371 Result.NumExpansions = Expansion.NumExpansionsPlusOne - 1;
372 }
373 return Result;
374 }
375
377 return DictWithObjectsMethod;
378 }
379
380 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
381 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
382 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
383
384 // Iterators
386 // Note: we're taking advantage of the layout of the KeyValuePair struct
387 // here. If that struct changes, this code will need to change as well.
388 static_assert(sizeof(KeyValuePair) == sizeof(Stmt *) * 2,
389 "KeyValuePair is expected size");
390 return child_range(
391 reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()),
392 reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()) +
393 NumElements * 2);
394 }
395
397 auto Children = const_cast<ObjCDictionaryLiteral *>(this)->children();
398 return const_child_range(Children.begin(), Children.end());
399 }
400
401 static bool classof(const Stmt *T) {
402 return T->getStmtClass() == ObjCDictionaryLiteralClass;
403 }
404};
405
406/// ObjCEncodeExpr, used for \@encode in Objective-C. \@encode has the same
407/// type and behavior as StringLiteral except that the string initializer is
408/// obtained from ASTContext with the encoding type as an argument.
409class ObjCEncodeExpr : public Expr {
410 TypeSourceInfo *EncodedType;
411 SourceLocation AtLoc, RParenLoc;
412
413public:
416 : Expr(ObjCEncodeExprClass, T, VK_LValue, OK_Ordinary),
417 EncodedType(EncodedType), AtLoc(at), RParenLoc(rp) {
419 }
420
421 explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){}
422
423 SourceLocation getAtLoc() const { return AtLoc; }
424 void setAtLoc(SourceLocation L) { AtLoc = L; }
425 SourceLocation getRParenLoc() const { return RParenLoc; }
426 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
427
428 QualType getEncodedType() const { return EncodedType->getType(); }
429
430 TypeSourceInfo *getEncodedTypeSourceInfo() const { return EncodedType; }
431
433 EncodedType = EncType;
434 }
435
436 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
437 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
438
439 // Iterators
442 }
443
446 }
447
448 static bool classof(const Stmt *T) {
449 return T->getStmtClass() == ObjCEncodeExprClass;
450 }
451};
452
453/// ObjCSelectorExpr used for \@selector in Objective-C.
454class ObjCSelectorExpr : public Expr {
455 Selector SelName;
456 SourceLocation AtLoc, RParenLoc;
457
458public:
461 : Expr(ObjCSelectorExprClass, T, VK_PRValue, OK_Ordinary),
462 SelName(selInfo), AtLoc(at), RParenLoc(rp) {
463 setDependence(ExprDependence::None);
464 }
466 : Expr(ObjCSelectorExprClass, Empty) {}
467
468 Selector getSelector() const { return SelName; }
469 void setSelector(Selector S) { SelName = S; }
470
471 SourceLocation getAtLoc() const { return AtLoc; }
472 SourceLocation getRParenLoc() const { return RParenLoc; }
473 void setAtLoc(SourceLocation L) { AtLoc = L; }
474 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
475
476 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
477 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
478
479 /// getNumArgs - Return the number of actual arguments to this call.
480 unsigned getNumArgs() const { return SelName.getNumArgs(); }
481
482 // Iterators
485 }
486
489 }
490
491 static bool classof(const Stmt *T) {
492 return T->getStmtClass() == ObjCSelectorExprClass;
493 }
494};
495
496/// ObjCProtocolExpr used for protocol expression in Objective-C.
497///
498/// This is used as: \@protocol(foo), as in:
499/// \code
500/// [obj conformsToProtocol:@protocol(foo)]
501/// \endcode
502///
503/// The return type is "Protocol*".
504class ObjCProtocolExpr : public Expr {
505 ObjCProtocolDecl *TheProtocol;
506 SourceLocation AtLoc, ProtoLoc, RParenLoc;
507
508public:
509 friend class ASTStmtReader;
510 friend class ASTStmtWriter;
511
513 SourceLocation protoLoc, SourceLocation rp)
514 : Expr(ObjCProtocolExprClass, T, VK_PRValue, OK_Ordinary),
515 TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) {
516 setDependence(ExprDependence::None);
517 }
519 : Expr(ObjCProtocolExprClass, Empty) {}
520
521 ObjCProtocolDecl *getProtocol() const { return TheProtocol; }
522 void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; }
523
524 SourceLocation getProtocolIdLoc() const { return ProtoLoc; }
525 SourceLocation getAtLoc() const { return AtLoc; }
526 SourceLocation getRParenLoc() const { return RParenLoc; }
527 void setAtLoc(SourceLocation L) { AtLoc = L; }
528 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
529
530 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
531 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
532
533 // Iterators
536 }
537
540 }
541
542 static bool classof(const Stmt *T) {
543 return T->getStmtClass() == ObjCProtocolExprClass;
544 }
545};
546
547/// ObjCIvarRefExpr - A reference to an ObjC instance variable.
548class ObjCIvarRefExpr : public Expr {
549 ObjCIvarDecl *D;
550 Stmt *Base;
551 SourceLocation Loc;
552
553 /// OpLoc - This is the location of '.' or '->'
554 SourceLocation OpLoc;
555
556 // True if this is "X->F", false if this is "X.F".
557 bool IsArrow : 1;
558
559 // True if ivar reference has no base (self assumed).
560 bool IsFreeIvar : 1;
561
562public:
564 SourceLocation oploc, Expr *base, bool arrow = false,
565 bool freeIvar = false)
566 : Expr(ObjCIvarRefExprClass, t, VK_LValue,
567 d->isBitField() ? OK_BitField : OK_Ordinary),
568 D(d), Base(base), Loc(l), OpLoc(oploc), IsArrow(arrow),
569 IsFreeIvar(freeIvar) {
571 }
572
574 : Expr(ObjCIvarRefExprClass, Empty) {}
575
576 ObjCIvarDecl *getDecl() { return D; }
577 const ObjCIvarDecl *getDecl() const { return D; }
578 void setDecl(ObjCIvarDecl *d) { D = d; }
579
580 const Expr *getBase() const { return cast<Expr>(Base); }
581 Expr *getBase() { return cast<Expr>(Base); }
582 void setBase(Expr * base) { Base = base; }
583
584 bool isArrow() const { return IsArrow; }
585 bool isFreeIvar() const { return IsFreeIvar; }
586 void setIsArrow(bool A) { IsArrow = A; }
587 void setIsFreeIvar(bool A) { IsFreeIvar = A; }
588
589 SourceLocation getLocation() const { return Loc; }
590 void setLocation(SourceLocation L) { Loc = L; }
591
592 SourceLocation getBeginLoc() const LLVM_READONLY {
593 return isFreeIvar() ? Loc : getBase()->getBeginLoc();
594 }
595 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
596
597 SourceLocation getOpLoc() const { return OpLoc; }
598 void setOpLoc(SourceLocation L) { OpLoc = L; }
599
600 // Iterators
602
604 return const_child_range(&Base, &Base + 1);
605 }
606
607 static bool classof(const Stmt *T) {
608 return T->getStmtClass() == ObjCIvarRefExprClass;
609 }
610};
611
612/// ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC
613/// property.
614class ObjCPropertyRefExpr : public Expr {
615private:
616 /// If the bool is true, this is an implicit property reference; the
617 /// pointer is an (optional) ObjCMethodDecl and Setter may be set.
618 /// if the bool is false, this is an explicit property reference;
619 /// the pointer is an ObjCPropertyDecl and Setter is always null.
620 llvm::PointerIntPair<NamedDecl *, 1, bool> PropertyOrGetter;
621
622 /// Indicates whether the property reference will result in a message
623 /// to the getter, the setter, or both.
624 /// This applies to both implicit and explicit property references.
625 enum MethodRefFlags {
626 MethodRef_None = 0,
627 MethodRef_Getter = 0x1,
628 MethodRef_Setter = 0x2
629 };
630
631 /// Contains the Setter method pointer and MethodRefFlags bit flags.
632 llvm::PointerIntPair<ObjCMethodDecl *, 2, unsigned> SetterAndMethodRefFlags;
633
634 // FIXME: Maybe we should store the property identifier here,
635 // because it's not rederivable from the other data when there's an
636 // implicit property with no getter (because the 'foo' -> 'setFoo:'
637 // transformation is lossy on the first character).
638
639 SourceLocation IdLoc;
640
641 /// When the receiver in property access is 'super', this is
642 /// the location of the 'super' keyword. When it's an interface,
643 /// this is that interface.
644 SourceLocation ReceiverLoc;
645 llvm::PointerUnion<Stmt *, const Type *, ObjCInterfaceDecl *> Receiver;
646
647public:
650 : Expr(ObjCPropertyRefExprClass, t, VK, OK), PropertyOrGetter(PD, false),
651 IdLoc(l), Receiver(base) {
652 assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
654 }
655
658 QualType st)
659 : Expr(ObjCPropertyRefExprClass, t, VK, OK), PropertyOrGetter(PD, false),
660 IdLoc(l), ReceiverLoc(sl), Receiver(st.getTypePtr()) {
661 assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
663 }
664
667 SourceLocation IdLoc, Expr *Base)
668 : Expr(ObjCPropertyRefExprClass, T, VK, OK),
669 PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
670 IdLoc(IdLoc), Receiver(Base) {
671 assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
673 }
674
677 SourceLocation IdLoc, SourceLocation SuperLoc,
678 QualType SuperTy)
679 : Expr(ObjCPropertyRefExprClass, T, VK, OK),
680 PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
681 IdLoc(IdLoc), ReceiverLoc(SuperLoc), Receiver(SuperTy.getTypePtr()) {
682 assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
684 }
685
688 SourceLocation IdLoc, SourceLocation ReceiverLoc,
689 ObjCInterfaceDecl *Receiver)
690 : Expr(ObjCPropertyRefExprClass, T, VK, OK),
691 PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
692 IdLoc(IdLoc), ReceiverLoc(ReceiverLoc), Receiver(Receiver) {
693 assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
695 }
696
698 : Expr(ObjCPropertyRefExprClass, Empty) {}
699
700 bool isImplicitProperty() const { return PropertyOrGetter.getInt(); }
701 bool isExplicitProperty() const { return !PropertyOrGetter.getInt(); }
702
704 assert(!isImplicitProperty());
705 return cast<ObjCPropertyDecl>(PropertyOrGetter.getPointer());
706 }
707
709 assert(isImplicitProperty());
710 return cast_or_null<ObjCMethodDecl>(PropertyOrGetter.getPointer());
711 }
712
714 assert(isImplicitProperty());
715 return SetterAndMethodRefFlags.getPointer();
716 }
717
719 if (isImplicitProperty())
722 }
723
725 if (isImplicitProperty())
728 }
729
730 /// True if the property reference will result in a message to the
731 /// getter.
732 /// This applies to both implicit and explicit property references.
733 bool isMessagingGetter() const {
734 return SetterAndMethodRefFlags.getInt() & MethodRef_Getter;
735 }
736
737 /// True if the property reference will result in a message to the
738 /// setter.
739 /// This applies to both implicit and explicit property references.
740 bool isMessagingSetter() const {
741 return SetterAndMethodRefFlags.getInt() & MethodRef_Setter;
742 }
743
744 void setIsMessagingGetter(bool val = true) {
745 setMethodRefFlag(MethodRef_Getter, val);
746 }
747
748 void setIsMessagingSetter(bool val = true) {
749 setMethodRefFlag(MethodRef_Setter, val);
750 }
751
752 const Expr *getBase() const {
753 return cast<Expr>(Receiver.get<Stmt*>());
754 }
756 return cast<Expr>(Receiver.get<Stmt*>());
757 }
758
759 SourceLocation getLocation() const { return IdLoc; }
760
761 SourceLocation getReceiverLocation() const { return ReceiverLoc; }
762
764 return QualType(Receiver.get<const Type*>(), 0);
765 }
766
768 return Receiver.get<ObjCInterfaceDecl*>();
769 }
770
771 bool isObjectReceiver() const { return Receiver.is<Stmt*>(); }
772 bool isSuperReceiver() const { return Receiver.is<const Type*>(); }
773 bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
774
775 /// Determine the type of the base, regardless of the kind of receiver.
776 QualType getReceiverType(const ASTContext &ctx) const;
777
778 SourceLocation getBeginLoc() const LLVM_READONLY {
779 return isObjectReceiver() ? getBase()->getBeginLoc()
781 }
782
783 SourceLocation getEndLoc() const LLVM_READONLY { return IdLoc; }
784
785 // Iterators
787 if (Receiver.is<Stmt*>()) {
788 Stmt **begin = reinterpret_cast<Stmt**>(&Receiver); // hack!
789 return child_range(begin, begin+1);
790 }
792 }
793
795 auto Children = const_cast<ObjCPropertyRefExpr *>(this)->children();
796 return const_child_range(Children.begin(), Children.end());
797 }
798
799 static bool classof(const Stmt *T) {
800 return T->getStmtClass() == ObjCPropertyRefExprClass;
801 }
802
803private:
804 friend class ASTStmtReader;
805 friend class ASTStmtWriter;
806
807 void setExplicitProperty(ObjCPropertyDecl *D, unsigned methRefFlags) {
808 PropertyOrGetter.setPointer(D);
809 PropertyOrGetter.setInt(false);
810 SetterAndMethodRefFlags.setPointer(nullptr);
811 SetterAndMethodRefFlags.setInt(methRefFlags);
812 }
813
814 void setImplicitProperty(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
815 unsigned methRefFlags) {
816 PropertyOrGetter.setPointer(Getter);
817 PropertyOrGetter.setInt(true);
818 SetterAndMethodRefFlags.setPointer(Setter);
819 SetterAndMethodRefFlags.setInt(methRefFlags);
820 }
821
822 void setBase(Expr *Base) { Receiver = Base; }
823 void setSuperReceiver(QualType T) { Receiver = T.getTypePtr(); }
824 void setClassReceiver(ObjCInterfaceDecl *D) { Receiver = D; }
825
826 void setLocation(SourceLocation L) { IdLoc = L; }
827 void setReceiverLocation(SourceLocation Loc) { ReceiverLoc = Loc; }
828
829 void setMethodRefFlag(MethodRefFlags flag, bool val) {
830 unsigned f = SetterAndMethodRefFlags.getInt();
831 if (val)
832 f |= flag;
833 else
834 f &= ~flag;
835 SetterAndMethodRefFlags.setInt(f);
836 }
837};
838
839/// ObjCSubscriptRefExpr - used for array and dictionary subscripting.
840/// array[4] = array[3]; dictionary[key] = dictionary[alt_key];
842 // Location of ']' in an indexing expression.
843 SourceLocation RBracket;
844
845 // array/dictionary base expression.
846 // for arrays, this is a numeric expression. For dictionaries, this is
847 // an objective-c object pointer expression.
848 enum { BASE, KEY, END_EXPR };
849 Stmt* SubExprs[END_EXPR];
850
851 ObjCMethodDecl *GetAtIndexMethodDecl;
852
853 // For immutable objects this is null. When ObjCSubscriptRefExpr is to read
854 // an indexed object this is null too.
855 ObjCMethodDecl *SetAtIndexMethodDecl;
856
857public:
859 ExprObjectKind OK, ObjCMethodDecl *getMethod,
860 ObjCMethodDecl *setMethod, SourceLocation RB)
861 : Expr(ObjCSubscriptRefExprClass, T, VK, OK), RBracket(RB),
862 GetAtIndexMethodDecl(getMethod), SetAtIndexMethodDecl(setMethod) {
863 SubExprs[BASE] = base;
864 SubExprs[KEY] = key;
866 }
867
869 : Expr(ObjCSubscriptRefExprClass, Empty) {}
870
871 SourceLocation getRBracket() const { return RBracket; }
872 void setRBracket(SourceLocation RB) { RBracket = RB; }
873
874 SourceLocation getBeginLoc() const LLVM_READONLY {
875 return SubExprs[BASE]->getBeginLoc();
876 }
877
878 SourceLocation getEndLoc() const LLVM_READONLY { return RBracket; }
879
880 Expr *getBaseExpr() const { return cast<Expr>(SubExprs[BASE]); }
881 void setBaseExpr(Stmt *S) { SubExprs[BASE] = S; }
882
883 Expr *getKeyExpr() const { return cast<Expr>(SubExprs[KEY]); }
884 void setKeyExpr(Stmt *S) { SubExprs[KEY] = S; }
885
887 return GetAtIndexMethodDecl;
888 }
889
891 return SetAtIndexMethodDecl;
892 }
893
896 }
897
899 return child_range(SubExprs, SubExprs+END_EXPR);
900 }
901
903 return const_child_range(SubExprs, SubExprs + END_EXPR);
904 }
905
906 static bool classof(const Stmt *T) {
907 return T->getStmtClass() == ObjCSubscriptRefExprClass;
908 }
909
910private:
911 friend class ASTStmtReader;
912};
913
914/// An expression that sends a message to the given Objective-C
915/// object or class.
916///
917/// The following contains two message send expressions:
918///
919/// \code
920/// [[NSString alloc] initWithString:@"Hello"]
921/// \endcode
922///
923/// The innermost message send invokes the "alloc" class method on the
924/// NSString class, while the outermost message send invokes the
925/// "initWithString" instance method on the object returned from
926/// NSString's "alloc". In all, an Objective-C message send can take
927/// on four different (although related) forms:
928///
929/// 1. Send to an object instance.
930/// 2. Send to a class.
931/// 3. Send to the superclass instance of the current class.
932/// 4. Send to the superclass of the current class.
933///
934/// All four kinds of message sends are modeled by the ObjCMessageExpr
935/// class, and can be distinguished via \c getReceiverKind(). Example:
936///
937/// The "void *" trailing objects are actually ONE void * (the
938/// receiver pointer), and NumArgs Expr *. But due to the
939/// implementation of children(), these must be together contiguously.
941 : public Expr,
942 private llvm::TrailingObjects<ObjCMessageExpr, void *, SourceLocation> {
943 /// Stores either the selector that this message is sending
944 /// to (when \c HasMethod is zero) or an \c ObjCMethodDecl pointer
945 /// referring to the method that we type-checked against.
946 uintptr_t SelectorOrMethod = 0;
947
948 enum { NumArgsBitWidth = 16 };
949
950 /// The number of arguments in the message send, not
951 /// including the receiver.
952 unsigned NumArgs : NumArgsBitWidth;
953
954 /// The kind of message send this is, which is one of the
955 /// ReceiverKind values.
956 ///
957 /// We pad this out to a byte to avoid excessive masking and shifting.
958 unsigned Kind : 8;
959
960 /// Whether we have an actual method prototype in \c
961 /// SelectorOrMethod.
962 ///
963 /// When non-zero, we have a method declaration; otherwise, we just
964 /// have a selector.
965 unsigned HasMethod : 1;
966
967 /// Whether this message send is a "delegate init call",
968 /// i.e. a call of an init method on self from within an init method.
969 unsigned IsDelegateInitCall : 1;
970
971 /// Whether this message send was implicitly generated by
972 /// the implementation rather than explicitly written by the user.
973 unsigned IsImplicit : 1;
974
975 /// Whether the locations of the selector identifiers are in a
976 /// "standard" position, a enum SelectorLocationsKind.
977 unsigned SelLocsKind : 2;
978
979 /// When the message expression is a send to 'super', this is
980 /// the location of the 'super' keyword.
981 SourceLocation SuperLoc;
982
983 /// The source locations of the open and close square
984 /// brackets ('[' and ']', respectively).
985 SourceLocation LBracLoc, RBracLoc;
986
987 ObjCMessageExpr(EmptyShell Empty, unsigned NumArgs)
988 : Expr(ObjCMessageExprClass, Empty), Kind(0), HasMethod(false),
989 IsDelegateInitCall(false), IsImplicit(false), SelLocsKind(0) {
990 setNumArgs(NumArgs);
991 }
992
994 SourceLocation LBracLoc,
995 SourceLocation SuperLoc,
996 bool IsInstanceSuper,
997 QualType SuperType,
998 Selector Sel,
1000 SelectorLocationsKind SelLocsK,
1001 ObjCMethodDecl *Method,
1002 ArrayRef<Expr *> Args,
1003 SourceLocation RBracLoc,
1004 bool isImplicit);
1006 SourceLocation LBracLoc,
1007 TypeSourceInfo *Receiver,
1008 Selector Sel,
1010 SelectorLocationsKind SelLocsK,
1011 ObjCMethodDecl *Method,
1012 ArrayRef<Expr *> Args,
1013 SourceLocation RBracLoc,
1014 bool isImplicit);
1016 SourceLocation LBracLoc,
1017 Expr *Receiver,
1018 Selector Sel,
1020 SelectorLocationsKind SelLocsK,
1021 ObjCMethodDecl *Method,
1022 ArrayRef<Expr *> Args,
1023 SourceLocation RBracLoc,
1024 bool isImplicit);
1025
1026 size_t numTrailingObjects(OverloadToken<void *>) const { return NumArgs + 1; }
1027
1028 void setNumArgs(unsigned Num) {
1029 assert((Num >> NumArgsBitWidth) == 0 && "Num of args is out of range!");
1030 NumArgs = Num;
1031 }
1032
1033 void initArgsAndSelLocs(ArrayRef<Expr *> Args,
1035 SelectorLocationsKind SelLocsK);
1036
1037 /// Retrieve the pointer value of the message receiver.
1038 void *getReceiverPointer() const { return *getTrailingObjects<void *>(); }
1039
1040 /// Set the pointer value of the message receiver.
1041 void setReceiverPointer(void *Value) {
1042 *getTrailingObjects<void *>() = Value;
1043 }
1044
1045 SelectorLocationsKind getSelLocsKind() const {
1046 return (SelectorLocationsKind)SelLocsKind;
1047 }
1048
1049 bool hasStandardSelLocs() const {
1050 return getSelLocsKind() != SelLoc_NonStandard;
1051 }
1052
1053 /// Get a pointer to the stored selector identifiers locations array.
1054 /// No locations will be stored if HasStandardSelLocs is true.
1055 SourceLocation *getStoredSelLocs() {
1056 return getTrailingObjects<SourceLocation>();
1057 }
1058 const SourceLocation *getStoredSelLocs() const {
1059 return getTrailingObjects<SourceLocation>();
1060 }
1061
1062 /// Get the number of stored selector identifiers locations.
1063 /// No locations will be stored if HasStandardSelLocs is true.
1064 unsigned getNumStoredSelLocs() const {
1065 if (hasStandardSelLocs())
1066 return 0;
1067 return getNumSelectorLocs();
1068 }
1069
1070 static ObjCMessageExpr *alloc(const ASTContext &C,
1071 ArrayRef<Expr *> Args,
1072 SourceLocation RBraceLoc,
1074 Selector Sel,
1075 SelectorLocationsKind &SelLocsK);
1076 static ObjCMessageExpr *alloc(const ASTContext &C,
1077 unsigned NumArgs,
1078 unsigned NumStoredSelLocs);
1079
1080public:
1081 friend class ASTStmtReader;
1082 friend class ASTStmtWriter;
1084
1085 /// The kind of receiver this message is sending to.
1087 /// The receiver is a class.
1089
1090 /// The receiver is an object instance.
1092
1093 /// The receiver is a superclass.
1095
1096 /// The receiver is the instance of the superclass object.
1099
1100 /// Create a message send to super.
1101 ///
1102 /// \param Context The ASTContext in which this expression will be created.
1103 ///
1104 /// \param T The result type of this message.
1105 ///
1106 /// \param VK The value kind of this message. A message returning
1107 /// a l-value or r-value reference will be an l-value or x-value,
1108 /// respectively.
1109 ///
1110 /// \param LBracLoc The location of the open square bracket '['.
1111 ///
1112 /// \param SuperLoc The location of the "super" keyword.
1113 ///
1114 /// \param IsInstanceSuper Whether this is an instance "super"
1115 /// message (otherwise, it's a class "super" message).
1116 ///
1117 /// \param Sel The selector used to determine which method gets called.
1118 ///
1119 /// \param Method The Objective-C method against which this message
1120 /// send was type-checked. May be nullptr.
1121 ///
1122 /// \param Args The message send arguments.
1123 ///
1124 /// \param RBracLoc The location of the closing square bracket ']'.
1125 static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1126 ExprValueKind VK,
1127 SourceLocation LBracLoc,
1128 SourceLocation SuperLoc,
1129 bool IsInstanceSuper,
1130 QualType SuperType,
1131 Selector Sel,
1133 ObjCMethodDecl *Method,
1134 ArrayRef<Expr *> Args,
1135 SourceLocation RBracLoc,
1136 bool isImplicit);
1137
1138 /// Create a class message send.
1139 ///
1140 /// \param Context The ASTContext in which this expression will be created.
1141 ///
1142 /// \param T The result type of this message.
1143 ///
1144 /// \param VK The value kind of this message. A message returning
1145 /// a l-value or r-value reference will be an l-value or x-value,
1146 /// respectively.
1147 ///
1148 /// \param LBracLoc The location of the open square bracket '['.
1149 ///
1150 /// \param Receiver The type of the receiver, including
1151 /// source-location information.
1152 ///
1153 /// \param Sel The selector used to determine which method gets called.
1154 ///
1155 /// \param Method The Objective-C method against which this message
1156 /// send was type-checked. May be nullptr.
1157 ///
1158 /// \param Args The message send arguments.
1159 ///
1160 /// \param RBracLoc The location of the closing square bracket ']'.
1161 static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1162 ExprValueKind VK,
1163 SourceLocation LBracLoc,
1164 TypeSourceInfo *Receiver,
1165 Selector Sel,
1167 ObjCMethodDecl *Method,
1168 ArrayRef<Expr *> Args,
1169 SourceLocation RBracLoc,
1170 bool isImplicit);
1171
1172 /// Create an instance message send.
1173 ///
1174 /// \param Context The ASTContext in which this expression will be created.
1175 ///
1176 /// \param T The result type of this message.
1177 ///
1178 /// \param VK The value kind of this message. A message returning
1179 /// a l-value or r-value reference will be an l-value or x-value,
1180 /// respectively.
1181 ///
1182 /// \param LBracLoc The location of the open square bracket '['.
1183 ///
1184 /// \param Receiver The expression used to produce the object that
1185 /// will receive this message.
1186 ///
1187 /// \param Sel The selector used to determine which method gets called.
1188 ///
1189 /// \param Method The Objective-C method against which this message
1190 /// send was type-checked. May be nullptr.
1191 ///
1192 /// \param Args The message send arguments.
1193 ///
1194 /// \param RBracLoc The location of the closing square bracket ']'.
1195 static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1196 ExprValueKind VK,
1197 SourceLocation LBracLoc,
1198 Expr *Receiver,
1199 Selector Sel,
1201 ObjCMethodDecl *Method,
1202 ArrayRef<Expr *> Args,
1203 SourceLocation RBracLoc,
1204 bool isImplicit);
1205
1206 /// Create an empty Objective-C message expression, to be
1207 /// filled in by subsequent calls.
1208 ///
1209 /// \param Context The context in which the message send will be created.
1210 ///
1211 /// \param NumArgs The number of message arguments, not including
1212 /// the receiver.
1213 static ObjCMessageExpr *CreateEmpty(const ASTContext &Context,
1214 unsigned NumArgs,
1215 unsigned NumStoredSelLocs);
1216
1217 /// Indicates whether the message send was implicitly
1218 /// generated by the implementation. If false, it was written explicitly
1219 /// in the source code.
1220 bool isImplicit() const { return IsImplicit; }
1221
1222 /// Determine the kind of receiver that this message is being
1223 /// sent to.
1225
1226 /// \return the return type of the message being sent.
1227 /// This is not always the type of the message expression itself because
1228 /// of references (the expression would not have a reference type).
1229 /// It is also not always the declared return type of the method because
1230 /// of `instancetype` (in that case it's an expression type).
1232
1233 /// Source range of the receiver.
1235
1236 /// Determine whether this is an instance message to either a
1237 /// computed object or to super.
1238 bool isInstanceMessage() const {
1240 }
1241
1242 /// Determine whether this is an class message to either a
1243 /// specified class or to super.
1244 bool isClassMessage() const {
1245 return getReceiverKind() == Class || getReceiverKind() == SuperClass;
1246 }
1247
1248 /// Returns the object expression (receiver) for an instance message,
1249 /// or null for a message that is not an instance message.
1251 if (getReceiverKind() == Instance)
1252 return static_cast<Expr *>(getReceiverPointer());
1253
1254 return nullptr;
1255 }
1256 const Expr *getInstanceReceiver() const {
1257 return const_cast<ObjCMessageExpr*>(this)->getInstanceReceiver();
1258 }
1259
1260 /// Turn this message send into an instance message that
1261 /// computes the receiver object with the given expression.
1263 Kind = Instance;
1264 setReceiverPointer(rec);
1265 }
1266
1267 /// Returns the type of a class message send, or NULL if the
1268 /// message is not a class message.
1271 return TSInfo->getType();
1272
1273 return {};
1274 }
1275
1276 /// Returns a type-source information of a class message
1277 /// send, or nullptr if the message is not a class message.
1279 if (getReceiverKind() == Class)
1280 return reinterpret_cast<TypeSourceInfo *>(getReceiverPointer());
1281 return nullptr;
1282 }
1283
1285 Kind = Class;
1286 setReceiverPointer(TSInfo);
1287 }
1288
1289 /// Retrieve the location of the 'super' keyword for a class
1290 /// or instance message to 'super', otherwise an invalid source location.
1293 return SuperLoc;
1294
1295 return SourceLocation();
1296 }
1297
1298 /// Retrieve the receiver type to which this message is being directed.
1299 ///
1300 /// This routine cross-cuts all of the different kinds of message
1301 /// sends to determine what the underlying (statically known) type
1302 /// of the receiver will be; use \c getReceiverKind() to determine
1303 /// whether the message is a class or an instance method, whether it
1304 /// is a send to super or not, etc.
1305 ///
1306 /// \returns The type of the receiver.
1307 QualType getReceiverType() const;
1308
1309 /// Retrieve the Objective-C interface to which this message
1310 /// is being directed, if known.
1311 ///
1312 /// This routine cross-cuts all of the different kinds of message
1313 /// sends to determine what the underlying (statically known) type
1314 /// of the receiver will be; use \c getReceiverKind() to determine
1315 /// whether the message is a class or an instance method, whether it
1316 /// is a send to super or not, etc.
1317 ///
1318 /// \returns The Objective-C interface if known, otherwise nullptr.
1320
1321 /// Retrieve the type referred to by 'super'.
1322 ///
1323 /// The returned type will either be an ObjCInterfaceType (for an
1324 /// class message to super) or an ObjCObjectPointerType that refers
1325 /// to a class (for an instance message to super);
1328 return QualType::getFromOpaquePtr(getReceiverPointer());
1329
1330 return QualType();
1331 }
1332
1333 void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper) {
1334 Kind = IsInstanceSuper? SuperInstance : SuperClass;
1335 SuperLoc = Loc;
1336 setReceiverPointer(T.getAsOpaquePtr());
1337 }
1338
1339 Selector getSelector() const;
1340
1342 HasMethod = false;
1343 SelectorOrMethod = reinterpret_cast<uintptr_t>(S.getAsOpaquePtr());
1344 }
1345
1347 if (HasMethod)
1348 return reinterpret_cast<const ObjCMethodDecl *>(SelectorOrMethod);
1349
1350 return nullptr;
1351 }
1352
1354 if (HasMethod)
1355 return reinterpret_cast<ObjCMethodDecl *>(SelectorOrMethod);
1356
1357 return nullptr;
1358 }
1359
1361 HasMethod = true;
1362 SelectorOrMethod = reinterpret_cast<uintptr_t>(MD);
1363 }
1364
1366 if (HasMethod) return getMethodDecl()->getMethodFamily();
1367 return getSelector().getMethodFamily();
1368 }
1369
1370 /// Return the number of actual arguments in this message,
1371 /// not counting the receiver.
1372 unsigned getNumArgs() const { return NumArgs; }
1373
1374 /// Retrieve the arguments to this message, not including the
1375 /// receiver.
1377 return reinterpret_cast<Expr **>(getTrailingObjects<void *>() + 1);
1378 }
1379 const Expr * const *getArgs() const {
1380 return reinterpret_cast<const Expr *const *>(getTrailingObjects<void *>() +
1381 1);
1382 }
1383
1384 /// getArg - Return the specified argument.
1385 Expr *getArg(unsigned Arg) {
1386 assert(Arg < NumArgs && "Arg access out of range!");
1387 return getArgs()[Arg];
1388 }
1389 const Expr *getArg(unsigned Arg) const {
1390 assert(Arg < NumArgs && "Arg access out of range!");
1391 return getArgs()[Arg];
1392 }
1393
1394 /// setArg - Set the specified argument.
1395 void setArg(unsigned Arg, Expr *ArgExpr) {
1396 assert(Arg < NumArgs && "Arg access out of range!");
1397 getArgs()[Arg] = ArgExpr;
1398 }
1399
1400 /// isDelegateInitCall - Answers whether this message send has been
1401 /// tagged as a "delegate init call", i.e. a call to a method in the
1402 /// -init family on self from within an -init method implementation.
1403 bool isDelegateInitCall() const { return IsDelegateInitCall; }
1404 void setDelegateInitCall(bool isDelegate) { IsDelegateInitCall = isDelegate; }
1405
1406 SourceLocation getLeftLoc() const { return LBracLoc; }
1407 SourceLocation getRightLoc() const { return RBracLoc; }
1408
1410 if (isImplicit())
1411 return getBeginLoc();
1412 return getSelectorLoc(0);
1413 }
1414
1415 SourceLocation getSelectorLoc(unsigned Index) const {
1416 assert(Index < getNumSelectorLocs() && "Index out of range!");
1417 if (hasStandardSelLocs())
1419 Index, getSelector(), getSelLocsKind() == SelLoc_StandardWithSpace,
1420 llvm::ArrayRef(const_cast<Expr **>(getArgs()), getNumArgs()),
1421 RBracLoc);
1422 return getStoredSelLocs()[Index];
1423 }
1424
1426
1427 unsigned getNumSelectorLocs() const {
1428 if (isImplicit())
1429 return 0;
1430 Selector Sel = getSelector();
1431 if (Sel.isUnarySelector())
1432 return 1;
1433 return Sel.getNumArgs();
1434 }
1435
1437 LBracLoc = R.getBegin();
1438 RBracLoc = R.getEnd();
1439 }
1440
1441 SourceLocation getBeginLoc() const LLVM_READONLY { return LBracLoc; }
1442 SourceLocation getEndLoc() const LLVM_READONLY { return RBracLoc; }
1443
1444 // Iterators
1446
1448
1451
1452 llvm::iterator_range<arg_iterator> arguments() {
1453 return llvm::make_range(arg_begin(), arg_end());
1454 }
1455
1456 llvm::iterator_range<const_arg_iterator> arguments() const {
1457 return llvm::make_range(arg_begin(), arg_end());
1458 }
1459
1460 arg_iterator arg_begin() { return reinterpret_cast<Stmt **>(getArgs()); }
1461
1463 return reinterpret_cast<Stmt **>(getArgs() + NumArgs);
1464 }
1465
1467 return reinterpret_cast<Stmt const * const*>(getArgs());
1468 }
1469
1471 return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs);
1472 }
1473
1474 static bool classof(const Stmt *T) {
1475 return T->getStmtClass() == ObjCMessageExprClass;
1476 }
1477};
1478
1479/// ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
1480/// (similar in spirit to MemberExpr).
1481class ObjCIsaExpr : public Expr {
1482 /// Base - the expression for the base object pointer.
1483 Stmt *Base;
1484
1485 /// IsaMemberLoc - This is the location of the 'isa'.
1486 SourceLocation IsaMemberLoc;
1487
1488 /// OpLoc - This is the location of '.' or '->'
1489 SourceLocation OpLoc;
1490
1491 /// IsArrow - True if this is "X->F", false if this is "X.F".
1492 bool IsArrow;
1493
1494public:
1495 ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc,
1496 QualType ty)
1497 : Expr(ObjCIsaExprClass, ty, VK_LValue, OK_Ordinary), Base(base),
1498 IsaMemberLoc(l), OpLoc(oploc), IsArrow(isarrow) {
1500 }
1501
1502 /// Build an empty expression.
1503 explicit ObjCIsaExpr(EmptyShell Empty) : Expr(ObjCIsaExprClass, Empty) {}
1504
1505 void setBase(Expr *E) { Base = E; }
1506 Expr *getBase() const { return cast<Expr>(Base); }
1507
1508 bool isArrow() const { return IsArrow; }
1509 void setArrow(bool A) { IsArrow = A; }
1510
1511 /// getMemberLoc - Return the location of the "member", in X->F, it is the
1512 /// location of 'F'.
1513 SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; }
1514 void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; }
1515
1516 SourceLocation getOpLoc() const { return OpLoc; }
1517 void setOpLoc(SourceLocation L) { OpLoc = L; }
1518
1519 SourceLocation getBeginLoc() const LLVM_READONLY {
1520 return getBase()->getBeginLoc();
1521 }
1522
1523 SourceLocation getBaseLocEnd() const LLVM_READONLY {
1524 return getBase()->getEndLoc();
1525 }
1526
1527 SourceLocation getEndLoc() const LLVM_READONLY { return IsaMemberLoc; }
1528
1529 SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; }
1530
1531 // Iterators
1533
1535 return const_child_range(&Base, &Base + 1);
1536 }
1537
1538 static bool classof(const Stmt *T) {
1539 return T->getStmtClass() == ObjCIsaExprClass;
1540 }
1541};
1542
1543/// ObjCIndirectCopyRestoreExpr - Represents the passing of a function
1544/// argument by indirect copy-restore in ARC. This is used to support
1545/// passing indirect arguments with the wrong lifetime, e.g. when
1546/// passing the address of a __strong local variable to an 'out'
1547/// parameter. This expression kind is only valid in an "argument"
1548/// position to some sort of call expression.
1549///
1550/// The parameter must have type 'pointer to T', and the argument must
1551/// have type 'pointer to U', where T and U agree except possibly in
1552/// qualification. If the argument value is null, then a null pointer
1553/// is passed; otherwise it points to an object A, and:
1554/// 1. A temporary object B of type T is initialized, either by
1555/// zero-initialization (used when initializing an 'out' parameter)
1556/// or copy-initialization (used when initializing an 'inout'
1557/// parameter).
1558/// 2. The address of the temporary is passed to the function.
1559/// 3. If the call completes normally, A is move-assigned from B.
1560/// 4. Finally, A is destroyed immediately.
1561///
1562/// Currently 'T' must be a retainable object lifetime and must be
1563/// __autoreleasing; this qualifier is ignored when initializing
1564/// the value.
1566 friend class ASTReader;
1567 friend class ASTStmtReader;
1568
1569 Stmt *Operand;
1570
1571 // unsigned ObjCIndirectCopyRestoreBits.ShouldCopy : 1;
1572
1574 : Expr(ObjCIndirectCopyRestoreExprClass, Empty) {}
1575
1576 void setShouldCopy(bool shouldCopy) {
1578 }
1579
1580public:
1582 : Expr(ObjCIndirectCopyRestoreExprClass, type, VK_LValue, OK_Ordinary),
1583 Operand(operand) {
1584 setShouldCopy(shouldCopy);
1586 }
1587
1588 Expr *getSubExpr() { return cast<Expr>(Operand); }
1589 const Expr *getSubExpr() const { return cast<Expr>(Operand); }
1590
1591 /// shouldCopy - True if we should do the 'copy' part of the
1592 /// copy-restore. If false, the temporary will be zero-initialized.
1593 bool shouldCopy() const { return ObjCIndirectCopyRestoreExprBits.ShouldCopy; }
1594
1595 child_range children() { return child_range(&Operand, &Operand+1); }
1596
1598 return const_child_range(&Operand, &Operand + 1);
1599 }
1600
1601 // Source locations are determined by the subexpression.
1602 SourceLocation getBeginLoc() const LLVM_READONLY {
1603 return Operand->getBeginLoc();
1604 }
1605 SourceLocation getEndLoc() const LLVM_READONLY {
1606 return Operand->getEndLoc();
1607 }
1608
1609 SourceLocation getExprLoc() const LLVM_READONLY {
1610 return getSubExpr()->getExprLoc();
1611 }
1612
1613 static bool classof(const Stmt *s) {
1614 return s->getStmtClass() == ObjCIndirectCopyRestoreExprClass;
1615 }
1616};
1617
1618/// An Objective-C "bridged" cast expression, which casts between
1619/// Objective-C pointers and C pointers, transferring ownership in the process.
1620///
1621/// \code
1622/// NSString *str = (__bridge_transfer NSString *)CFCreateString();
1623/// \endcode
1625 : public ExplicitCastExpr,
1626 private llvm::TrailingObjects<ObjCBridgedCastExpr, CXXBaseSpecifier *> {
1627 friend class ASTStmtReader;
1628 friend class ASTStmtWriter;
1629 friend class CastExpr;
1630 friend TrailingObjects;
1631
1632 SourceLocation LParenLoc;
1633 SourceLocation BridgeKeywordLoc;
1634 unsigned Kind : 2;
1635
1636public:
1638 CastKind CK, SourceLocation BridgeKeywordLoc,
1639 TypeSourceInfo *TSInfo, Expr *Operand)
1640 : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(),
1641 VK_PRValue, CK, Operand, 0, false, TSInfo),
1642 LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {}
1643
1644 /// Construct an empty Objective-C bridged cast.
1646 : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0, false) {}
1647
1648 SourceLocation getLParenLoc() const { return LParenLoc; }
1649
1650 /// Determine which kind of bridge is being performed via this cast.
1652 return static_cast<ObjCBridgeCastKind>(Kind);
1653 }
1654
1655 /// Retrieve the kind of bridge being performed as a string.
1656 StringRef getBridgeKindName() const;
1657
1658 /// The location of the bridge keyword.
1659 SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; }
1660
1661 SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
1662
1663 SourceLocation getEndLoc() const LLVM_READONLY {
1664 return getSubExpr()->getEndLoc();
1665 }
1666
1667 static bool classof(const Stmt *T) {
1668 return T->getStmtClass() == ObjCBridgedCastExprClass;
1669 }
1670};
1671
1672/// A runtime availability query.
1673///
1674/// There are 2 ways to spell this node:
1675/// \code
1676/// @available(macos 10.10, ios 8, *); // Objective-C
1677/// __builtin_available(macos 10.10, ios 8, *); // C, C++, and Objective-C
1678/// \endcode
1679///
1680/// Note that we only need to keep track of one \c VersionTuple here, which is
1681/// the one that corresponds to the current deployment target. This is meant to
1682/// be used in the condition of an \c if, but it is also usable as top level
1683/// expressions.
1684///
1686 friend class ASTStmtReader;
1687
1688 VersionTuple VersionToCheck;
1689 SourceLocation AtLoc, RParen;
1690
1691public:
1692 ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc,
1693 SourceLocation RParen, QualType Ty)
1694 : Expr(ObjCAvailabilityCheckExprClass, Ty, VK_PRValue, OK_Ordinary),
1695 VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) {
1696 setDependence(ExprDependence::None);
1697 }
1698
1700 : Expr(ObjCAvailabilityCheckExprClass, Shell) {}
1701
1702 SourceLocation getBeginLoc() const { return AtLoc; }
1703 SourceLocation getEndLoc() const { return RParen; }
1704 SourceRange getSourceRange() const { return {AtLoc, RParen}; }
1705
1706 /// This may be '*', in which case this should fold to true.
1707 bool hasVersion() const { return !VersionToCheck.empty(); }
1708 VersionTuple getVersion() const { return VersionToCheck; }
1709
1712 }
1713
1716 }
1717
1718 static bool classof(const Stmt *T) {
1719 return T->getStmtClass() == ObjCAvailabilityCheckExprClass;
1720 }
1721};
1722
1723} // namespace clang
1724
1725#endif // LLVM_CLANG_AST_EXPROBJC_H
#define V(N, I)
Definition: ASTContext.h:3233
StringRef P
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
C Language Family Type Representation.
__device__ __2f16 float __ockl_bool s
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:368
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3502
Expr * getSubExpr()
Definition: Expr.h:3552
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3737
This represents one expression.
Definition: Expr.h:110
Expr()=delete
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:330
QualType getType() const
Definition: Expr.h:142
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
Definition: Expr.h:135
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition: ExprObjC.h:191
Expr * getElement(unsigned Index)
getElement - Return the Element at the specified index.
Definition: ExprObjC.h:231
const Expr *const * getElements() const
Retrieve elements of array of literals.
Definition: ExprObjC.h:223
child_range children()
Definition: ExprObjC.h:245
static ObjCArrayLiteral * CreateEmpty(const ASTContext &C, unsigned NumElements)
Definition: ExprObjC.cpp:47
const_child_range children() const
Definition: ExprObjC.h:250
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:215
Expr ** getElements()
Retrieve elements of array of literals.
Definition: ExprObjC.h:220
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
Definition: ExprObjC.h:228
const Expr * getElement(unsigned Index) const
Definition: ExprObjC.h:235
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:217
static ObjCArrayLiteral * Create(const ASTContext &C, ArrayRef< Expr * > Elements, QualType T, ObjCMethodDecl *Method, SourceRange SR)
Definition: ExprObjC.cpp:39
ObjCMethodDecl * getArrayWithObjectsMethod() const
Definition: ExprObjC.h:240
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:216
static bool classof(const Stmt *T)
Definition: ExprObjC.h:255
A runtime availability query.
Definition: ExprObjC.h:1685
bool hasVersion() const
This may be '*', in which case this should fold to true.
Definition: ExprObjC.h:1707
const_child_range children() const
Definition: ExprObjC.h:1714
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1718
ObjCAvailabilityCheckExpr(EmptyShell Shell)
Definition: ExprObjC.h:1699
SourceRange getSourceRange() const
Definition: ExprObjC.h:1704
SourceLocation getBeginLoc() const
Definition: ExprObjC.h:1702
SourceLocation getEndLoc() const
Definition: ExprObjC.h:1703
VersionTuple getVersion() const
Definition: ExprObjC.h:1708
ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc, SourceLocation RParen, QualType Ty)
Definition: ExprObjC.h:1692
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:87
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:104
void setLocation(SourceLocation L)
Definition: ExprObjC.h:107
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:103
SourceLocation getLocation() const
Definition: ExprObjC.h:106
const_child_range children() const
Definition: ExprObjC.h:114
ObjCBoolLiteralExpr(bool val, QualType Ty, SourceLocation l)
Definition: ExprObjC.h:92
static bool classof(const Stmt *T)
Definition: ExprObjC.h:118
child_range children()
Definition: ExprObjC.h:110
ObjCBoolLiteralExpr(EmptyShell Empty)
Definition: ExprObjC.h:97
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:127
const_arg_iterator arg_begin() const
Definition: ExprObjC.h:174
const Expr * getSubExpr() const
Definition: ExprObjC.h:144
Expr * getSubExpr()
Definition: ExprObjC.h:143
SourceLocation getAtLoc() const
Definition: ExprObjC.h:156
ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, SourceRange R)
Definition: ExprObjC.h:135
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:161
static bool classof(const Stmt *T)
Definition: ExprObjC.h:182
ObjCBoxedExpr(EmptyShell Empty)
Definition: ExprObjC.h:140
const_child_range children() const
Definition: ExprObjC.h:168
ObjCMethodDecl * getBoxingMethod() const
Definition: ExprObjC.h:146
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:158
const_arg_iterator arg_end() const
Definition: ExprObjC.h:178
bool isExpressibleAsConstantInitializer() const
Definition: ExprObjC.h:152
child_range children()
Definition: ExprObjC.h:166
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:159
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
Definition: ExprObjC.h:1626
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1663
ObjCBridgedCastExpr(EmptyShell Shell)
Construct an empty Objective-C bridged cast.
Definition: ExprObjC.h:1645
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
Definition: ExprObjC.cpp:341
SourceLocation getLParenLoc() const
Definition: ExprObjC.h:1648
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1667
SourceLocation getBridgeKeywordLoc() const
The location of the bridge keyword.
Definition: ExprObjC.h:1659
ObjCBridgeCastKind getBridgeKind() const
Determine which kind of bridge is being performed via this cast.
Definition: ExprObjC.h:1651
ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, CastKind CK, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *Operand)
Definition: ExprObjC.h:1637
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1661
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:309
static ObjCDictionaryLiteral * Create(const ASTContext &C, ArrayRef< ObjCDictionaryElement > VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR)
Definition: ExprObjC.cpp:78
static ObjCDictionaryLiteral * CreateEmpty(const ASTContext &C, unsigned NumElements, bool HasPackExpansions)
Definition: ExprObjC.cpp:88
const_child_range children() const
Definition: ExprObjC.h:396
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:359
ObjCMethodDecl * getDictWithObjectsMethod() const
Definition: ExprObjC.h:376
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:361
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:380
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:381
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:382
static bool classof(const Stmt *T)
Definition: ExprObjC.h:401
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:409
void setEncodedTypeSourceInfo(TypeSourceInfo *EncType)
Definition: ExprObjC.h:432
TypeSourceInfo * getEncodedTypeSourceInfo() const
Definition: ExprObjC.h:430
const_child_range children() const
Definition: ExprObjC.h:444
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:436
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:425
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:426
static bool classof(const Stmt *T)
Definition: ExprObjC.h:448
QualType getEncodedType() const
Definition: ExprObjC.h:428
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:437
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:424
ObjCEncodeExpr(QualType T, TypeSourceInfo *EncodedType, SourceLocation at, SourceLocation rp)
Definition: ExprObjC.h:414
SourceLocation getAtLoc() const
Definition: ExprObjC.h:423
child_range children()
Definition: ExprObjC.h:440
ObjCEncodeExpr(EmptyShell Empty)
Definition: ExprObjC.h:421
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1565
const Expr * getSubExpr() const
Definition: ExprObjC.h:1589
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1605
static bool classof(const Stmt *s)
Definition: ExprObjC.h:1613
bool shouldCopy() const
shouldCopy - True if we should do the 'copy' part of the copy-restore.
Definition: ExprObjC.h:1593
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprObjC.h:1609
ObjCIndirectCopyRestoreExpr(Expr *operand, QualType type, bool shouldCopy)
Definition: ExprObjC.h:1581
const_child_range children() const
Definition: ExprObjC.h:1597
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1602
Represents an ObjC class declaration.
Definition: DeclObjC.h:1147
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition: ExprObjC.h:1481
SourceLocation getIsaMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
Definition: ExprObjC.h:1513
ObjCIsaExpr(EmptyShell Empty)
Build an empty expression.
Definition: ExprObjC.h:1503
SourceLocation getOpLoc() const
Definition: ExprObjC.h:1516
void setIsaMemberLoc(SourceLocation L)
Definition: ExprObjC.h:1514
Expr * getBase() const
Definition: ExprObjC.h:1506
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1538
SourceLocation getBaseLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:1523
bool isArrow() const
Definition: ExprObjC.h:1508
child_range children()
Definition: ExprObjC.h:1532
void setBase(Expr *E)
Definition: ExprObjC.h:1505
void setArrow(bool A)
Definition: ExprObjC.h:1509
void setOpLoc(SourceLocation L)
Definition: ExprObjC.h:1517
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprObjC.h:1529
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1527
const_child_range children() const
Definition: ExprObjC.h:1534
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1519
ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc, QualType ty)
Definition: ExprObjC.h:1495
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1939
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:548
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:592
void setIsArrow(bool A)
Definition: ExprObjC.h:586
void setBase(Expr *base)
Definition: ExprObjC.h:582
SourceLocation getLocation() const
Definition: ExprObjC.h:589
SourceLocation getOpLoc() const
Definition: ExprObjC.h:597
void setDecl(ObjCIvarDecl *d)
Definition: ExprObjC.h:578
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:576
ObjCIvarRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:573
bool isArrow() const
Definition: ExprObjC.h:584
bool isFreeIvar() const
Definition: ExprObjC.h:585
void setIsFreeIvar(bool A)
Definition: ExprObjC.h:587
void setOpLoc(SourceLocation L)
Definition: ExprObjC.h:598
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:595
const_child_range children() const
Definition: ExprObjC.h:603
const ObjCIvarDecl * getDecl() const
Definition: ExprObjC.h:577
const Expr * getBase() const
Definition: ExprObjC.h:580
child_range children()
Definition: ExprObjC.h:601
void setLocation(SourceLocation L)
Definition: ExprObjC.h:590
static bool classof(const Stmt *T)
Definition: ExprObjC.h:607
ObjCIvarRefExpr(ObjCIvarDecl *d, QualType t, SourceLocation l, SourceLocation oploc, Expr *base, bool arrow=false, bool freeIvar=false)
Definition: ExprObjC.h:563
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:942
static ObjCMessageExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, Selector Sel, ArrayRef< SourceLocation > SelLocs, ObjCMethodDecl *Method, ArrayRef< Expr * > Args, SourceLocation RBracLoc, bool isImplicit)
Create a message send to super.
Definition: ExprObjC.cpp:175
const Expr * getArg(unsigned Arg) const
Definition: ExprObjC.h:1389
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: ExprObjC.h:1385
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Definition: ExprObjC.cpp:258
bool isImplicit() const
Indicates whether the message send was implicitly generated by the implementation.
Definition: ExprObjC.h:1220
llvm::iterator_range< const_arg_iterator > arguments() const
Definition: ExprObjC.h:1456
static ObjCMessageExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs, unsigned NumStoredSelLocs)
Create an empty Objective-C message expression, to be filled in by subsequent calls.
Definition: ExprObjC.cpp:232
void setMethodDecl(ObjCMethodDecl *MD)
Definition: ExprObjC.h:1360
Expr ** getArgs()
Retrieve the arguments to this message, not including the receiver.
Definition: ExprObjC.h:1376
bool isDelegateInitCall() const
isDelegateInitCall - Answers whether this message send has been tagged as a "delegate init call",...
Definition: ExprObjC.h:1403
ObjCMethodDecl * getMethodDecl()
Definition: ExprObjC.h:1353
void setClassReceiver(TypeSourceInfo *TSInfo)
Definition: ExprObjC.h:1284
void setInstanceReceiver(Expr *rec)
Turn this message send into an instance message that computes the receiver object with the given expr...
Definition: ExprObjC.h:1262
const_arg_iterator arg_end() const
Definition: ExprObjC.h:1470
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1441
void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper)
Definition: ExprObjC.h:1333
SourceLocation getLeftLoc() const
Definition: ExprObjC.h:1406
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1250
QualType getCallReturnType(ASTContext &Ctx) const
Definition: ExprObjC.cpp:265
SourceLocation getSuperLoc() const
Retrieve the location of the 'super' keyword for a class or instance message to 'super',...
Definition: ExprObjC.h:1291
ObjCMethodFamily getMethodFamily() const
Definition: ExprObjC.h:1365
Selector getSelector() const
Definition: ExprObjC.cpp:293
ReceiverKind
The kind of receiver this message is sending to.
Definition: ExprObjC.h:1086
@ SuperInstance
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:1097
@ Instance
The receiver is an object instance.
Definition: ExprObjC.h:1091
@ SuperClass
The receiver is a superclass.
Definition: ExprObjC.h:1094
@ Class
The receiver is a class.
Definition: ExprObjC.h:1088
TypeSourceInfo * getClassReceiverTypeInfo() const
Returns a type-source information of a class message send, or nullptr if the message is not a class m...
Definition: ExprObjC.h:1278
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1269
void setDelegateInitCall(bool isDelegate)
Definition: ExprObjC.h:1404
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
Definition: ExprObjC.h:1238
llvm::iterator_range< arg_iterator > arguments()
Definition: ExprObjC.h:1452
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
Definition: ExprObjC.cpp:314
QualType getSuperType() const
Retrieve the type referred to by 'super'.
Definition: ExprObjC.h:1326
const ObjCMethodDecl * getMethodDecl() const
Definition: ExprObjC.h:1346
SourceRange getReceiverRange() const
Source range of the receiver.
Definition: ExprObjC.cpp:277
bool isClassMessage() const
Determine whether this is an class message to either a specified class or to super.
Definition: ExprObjC.h:1244
const Expr * getInstanceReceiver() const
Definition: ExprObjC.h:1256
unsigned getNumSelectorLocs() const
Definition: ExprObjC.h:1427
const Expr *const * getArgs() const
Definition: ExprObjC.h:1379
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1224
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1442
child_range children()
Definition: ExprObjC.cpp:326
QualType getReceiverType() const
Retrieve the receiver type to which this message is being directed.
Definition: ExprObjC.cpp:300
SourceLocation getSelectorLoc(unsigned Index) const
Definition: ExprObjC.h:1415
SourceLocation getSelectorStartLoc() const
Definition: ExprObjC.h:1409
arg_iterator arg_begin()
Definition: ExprObjC.h:1460
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1474
void setSourceRange(SourceRange R)
Definition: ExprObjC.h:1436
SourceLocation getRightLoc() const
Definition: ExprObjC.h:1407
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver.
Definition: ExprObjC.h:1372
void setSelector(Selector S)
Definition: ExprObjC.h:1341
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
Definition: ExprObjC.h:1395
arg_iterator arg_end()
Definition: ExprObjC.h:1462
const_arg_iterator arg_begin() const
Definition: ExprObjC.h:1466
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
Selector getSelector() const
Definition: DeclObjC.h:329
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
Definition: DeclObjC.cpp:1053
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:729
Selector getSetterName() const
Definition: DeclObjC.h:886
Selector getGetterName() const
Definition: DeclObjC.h:878
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:614
bool isMessagingGetter() const
True if the property reference will result in a message to the getter.
Definition: ExprObjC.h:733
child_range children()
Definition: ExprObjC.h:786
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:703
Selector getSetterSelector() const
Definition: ExprObjC.h:724
bool isMessagingSetter() const
True if the property reference will result in a message to the setter.
Definition: ExprObjC.h:740
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:708
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, SourceLocation ReceiverLoc, ObjCInterfaceDecl *Receiver)
Definition: ExprObjC.h:686
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, Expr *Base)
Definition: ExprObjC.h:665
void setIsMessagingSetter(bool val=true)
Definition: ExprObjC.h:748
SourceLocation getReceiverLocation() const
Definition: ExprObjC.h:761
const Expr * getBase() const
Definition: ExprObjC.h:752
const_child_range children() const
Definition: ExprObjC.h:794
static bool classof(const Stmt *T)
Definition: ExprObjC.h:799
bool isObjectReceiver() const
Definition: ExprObjC.h:771
bool isExplicitProperty() const
Definition: ExprObjC.h:701
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:778
void setIsMessagingGetter(bool val=true)
Definition: ExprObjC.h:744
QualType getSuperReceiverType() const
Definition: ExprObjC.h:763
bool isImplicitProperty() const
Definition: ExprObjC.h:700
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:783
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:713
ObjCInterfaceDecl * getClassReceiver() const
Definition: ExprObjC.h:767
SourceLocation getLocation() const
Definition: ExprObjC.h:759
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, Expr *base)
Definition: ExprObjC.h:648
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, SourceLocation SuperLoc, QualType SuperTy)
Definition: ExprObjC.h:675
Selector getGetterSelector() const
Definition: ExprObjC.h:718
ObjCPropertyRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:697
QualType getReceiverType(const ASTContext &ctx) const
Determine the type of the base, regardless of the kind of receiver.
Definition: ExprObjC.cpp:96
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, SourceLocation sl, QualType st)
Definition: ExprObjC.h:656
bool isClassReceiver() const
Definition: ExprObjC.h:773
bool isSuperReceiver() const
Definition: ExprObjC.h:772
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2069
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:504
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:530
ObjCProtocolDecl * getProtocol() const
Definition: ExprObjC.h:521
ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, SourceLocation at, SourceLocation protoLoc, SourceLocation rp)
Definition: ExprObjC.h:512
SourceLocation getProtocolIdLoc() const
Definition: ExprObjC.h:524
const_child_range children() const
Definition: ExprObjC.h:538
void setProtocol(ObjCProtocolDecl *P)
Definition: ExprObjC.h:522
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:528
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:527
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:526
static bool classof(const Stmt *T)
Definition: ExprObjC.h:542
SourceLocation getAtLoc() const
Definition: ExprObjC.h:525
child_range children()
Definition: ExprObjC.h:534
ObjCProtocolExpr(EmptyShell Empty)
Definition: ExprObjC.h:518
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:531
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:454
static bool classof(const Stmt *T)
Definition: ExprObjC.h:491
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:476
void setSelector(Selector S)
Definition: ExprObjC.h:469
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: ExprObjC.h:480
ObjCSelectorExpr(EmptyShell Empty)
Definition: ExprObjC.h:465
ObjCSelectorExpr(QualType T, Selector selInfo, SourceLocation at, SourceLocation rp)
Definition: ExprObjC.h:459
child_range children()
Definition: ExprObjC.h:483
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:473
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:472
const_child_range children() const
Definition: ExprObjC.h:487
Selector getSelector() const
Definition: ExprObjC.h:468
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:477
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:474
SourceLocation getAtLoc() const
Definition: ExprObjC.h:471
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:51
child_range children()
Definition: ExprObjC.h:75
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:72
const StringLiteral * getString() const
Definition: ExprObjC.h:65
SourceLocation getAtLoc() const
Definition: ExprObjC.h:68
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:69
void setString(StringLiteral *S)
Definition: ExprObjC.h:66
const_child_range children() const
Definition: ExprObjC.h:77
ObjCStringLiteral(EmptyShell Empty)
Definition: ExprObjC.h:61
static bool classof(const Stmt *T)
Definition: ExprObjC.h:81
StringLiteral * getString()
Definition: ExprObjC.h:64
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:71
ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
Definition: ExprObjC.h:56
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:841
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:874
Expr * getKeyExpr() const
Definition: ExprObjC.h:883
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:878
void setRBracket(SourceLocation RB)
Definition: ExprObjC.h:872
bool isArraySubscriptRefExpr() const
Definition: ExprObjC.h:894
ObjCSubscriptRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:868
child_range children()
Definition: ExprObjC.h:898
ObjCSubscriptRefExpr(Expr *base, Expr *key, QualType T, ExprValueKind VK, ExprObjectKind OK, ObjCMethodDecl *getMethod, ObjCMethodDecl *setMethod, SourceLocation RB)
Definition: ExprObjC.h:858
void setKeyExpr(Stmt *S)
Definition: ExprObjC.h:884
static bool classof(const Stmt *T)
Definition: ExprObjC.h:906
void setBaseExpr(Stmt *S)
Definition: ExprObjC.h:881
Expr * getBaseExpr() const
Definition: ExprObjC.h:880
const_child_range children() const
Definition: ExprObjC.h:902
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:886
SourceLocation getRBracket() const
Definition: ExprObjC.h:871
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:890
A (possibly-)qualified type.
Definition: Type.h:736
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:785
void * getAsOpaquePtr() const
Definition: Type.h:783
Smart pointer class that efficiently represents Objective-C method names.
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
bool isUnarySelector() const
unsigned getNumArgs() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
Definition: Stmt.h:72
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:349
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
Definition: Stmt.h:1267
StmtClass getStmtClass() const
Definition: Stmt.h:1181
ConstCastIterator< Expr > ConstExprIterator
Definition: Stmt.h:1155
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1270
ConstStmtIterator const_child_iterator
Definition: Stmt.h:1268
ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits
Definition: Stmt.h:1093
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:337
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1271
CastIterator< Expr > ExprIterator
Definition: Stmt.h:1154
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1793
A container of type source information.
Definition: Type.h:6718
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6729
The base class of the type hierarchy.
Definition: Type.h:1597
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
Definition: Type.h:7306
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Definition: Type.h:7420
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
@ SelLoc_StandardWithSpace
For nullary selectors, immediately before the end: "[foo release]" / "-(void)release;" Or with a spac...
@ SelLoc_NonStandard
Non-standard.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:140
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition: Specifiers.h:142
@ OK_BitField
A bitfield object is a bitfield on a C or C++ record.
Definition: Specifiers.h:145
ExprDependence computeDependence(FullExpr *E)
ObjCMethodFamily
A family of Objective-C methods.
@ C
Languages that the frontend can parse and compile.
@ Result
The result type of a method or function.
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
CastKind
CastKind - The kind of operation required for a conversion.
SourceLocation getStandardSelectorLoc(unsigned Index, Selector Sel, bool WithArgSpace, ArrayRef< Expr * > Args, SourceLocation EndLoc)
Get the "standard" location of a selector identifier, e.g: For nullary selectors, immediately before ...
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:123
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:126
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:130
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
#define true
Definition: stdbool.h:21
#define false
Definition: stdbool.h:22
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:262
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:267
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:277
SourceLocation EllipsisLoc
The location of the ellipsis, if this is a pack expansion.
Definition: ExprObjC.h:270
std::optional< unsigned > NumExpansions
The number of elements this pack expansion will expand to, if this is a pack expansion and is known.
Definition: ExprObjC.h:274
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:264
Internal struct to describes an element that is a pack expansion, used if any of the elements in the ...
Definition: ExprObjC.h:293
SourceLocation EllipsisLoc
The location of the ellipsis, if this element is a pack expansion.
Definition: ExprObjC.h:296
unsigned NumExpansionsPlusOne
If non-zero, the number of elements that this pack expansion will expand to (+1).
Definition: ExprObjC.h:300
Internal struct for storing Key/value pair.
Definition: ExprObjC.h:285
Iterator for iterating over Stmt * arrays that contain only T *.
Definition: Stmt.h:1139
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition: Stmt.h:1121