clang 20.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; }
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 }
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 LLVM_PREFERRED_TYPE(bool)
321 unsigned HasPackExpansions : 1;
322
323 SourceRange Range;
324 ObjCMethodDecl *DictWithObjectsMethod;
325
328
330 bool HasPackExpansions,
331 QualType T, ObjCMethodDecl *method,
332 SourceRange SR);
333
334 explicit ObjCDictionaryLiteral(EmptyShell Empty, unsigned NumElements,
335 bool HasPackExpansions)
336 : Expr(ObjCDictionaryLiteralClass, Empty), NumElements(NumElements),
337 HasPackExpansions(HasPackExpansions) {}
338
339 size_t numTrailingObjects(OverloadToken<KeyValuePair>) const {
340 return NumElements;
341 }
342
343public:
344 friend class ASTStmtReader;
345 friend class ASTStmtWriter;
347
350 bool HasPackExpansions,
351 QualType T, ObjCMethodDecl *method,
352 SourceRange SR);
353
355 unsigned NumElements,
356 bool HasPackExpansions);
357
358 /// getNumElements - Return number of elements of objective-c dictionary
359 /// literal.
360 unsigned getNumElements() const { return NumElements; }
361
363 assert((Index < NumElements) && "Arg access out of range!");
364 const KeyValuePair &KV = getTrailingObjects<KeyValuePair>()[Index];
366 std::nullopt};
367 if (HasPackExpansions) {
368 const ExpansionData &Expansion =
369 getTrailingObjects<ExpansionData>()[Index];
370 Result.EllipsisLoc = Expansion.EllipsisLoc;
371 if (Expansion.NumExpansionsPlusOne > 0)
372 Result.NumExpansions = Expansion.NumExpansionsPlusOne - 1;
373 }
374 return Result;
375 }
376
378 return DictWithObjectsMethod;
379 }
380
381 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
382 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
383 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
384
385 // Iterators
387 // Note: we're taking advantage of the layout of the KeyValuePair struct
388 // here. If that struct changes, this code will need to change as well.
389 static_assert(sizeof(KeyValuePair) == sizeof(Stmt *) * 2,
390 "KeyValuePair is expected size");
391 return child_range(
392 reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()),
393 reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()) +
394 NumElements * 2);
395 }
396
398 auto Children = const_cast<ObjCDictionaryLiteral *>(this)->children();
399 return const_child_range(Children.begin(), Children.end());
400 }
401
402 static bool classof(const Stmt *T) {
403 return T->getStmtClass() == ObjCDictionaryLiteralClass;
404 }
405};
406
407/// ObjCEncodeExpr, used for \@encode in Objective-C. \@encode has the same
408/// type and behavior as StringLiteral except that the string initializer is
409/// obtained from ASTContext with the encoding type as an argument.
410class ObjCEncodeExpr : public Expr {
411 TypeSourceInfo *EncodedType;
412 SourceLocation AtLoc, RParenLoc;
413
414public:
417 : Expr(ObjCEncodeExprClass, T, VK_LValue, OK_Ordinary),
418 EncodedType(EncodedType), AtLoc(at), RParenLoc(rp) {
420 }
421
422 explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){}
423
424 SourceLocation getAtLoc() const { return AtLoc; }
425 void setAtLoc(SourceLocation L) { AtLoc = L; }
426 SourceLocation getRParenLoc() const { return RParenLoc; }
427 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
428
429 QualType getEncodedType() const { return EncodedType->getType(); }
430
431 TypeSourceInfo *getEncodedTypeSourceInfo() const { return EncodedType; }
432
434 EncodedType = EncType;
435 }
436
437 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
438 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
439
440 // Iterators
443 }
444
447 }
448
449 static bool classof(const Stmt *T) {
450 return T->getStmtClass() == ObjCEncodeExprClass;
451 }
452};
453
454/// ObjCSelectorExpr used for \@selector in Objective-C.
455class ObjCSelectorExpr : public Expr {
456 Selector SelName;
457 SourceLocation AtLoc, RParenLoc;
458
459public:
462 : Expr(ObjCSelectorExprClass, T, VK_PRValue, OK_Ordinary),
463 SelName(selInfo), AtLoc(at), RParenLoc(rp) {
464 setDependence(ExprDependence::None);
465 }
467 : Expr(ObjCSelectorExprClass, Empty) {}
468
469 Selector getSelector() const { return SelName; }
470 void setSelector(Selector S) { SelName = S; }
471
472 SourceLocation getAtLoc() const { return AtLoc; }
473 SourceLocation getRParenLoc() const { return RParenLoc; }
474 void setAtLoc(SourceLocation L) { AtLoc = L; }
475 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
476
477 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
478 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
479
480 /// getNumArgs - Return the number of actual arguments to this call.
481 unsigned getNumArgs() const { return SelName.getNumArgs(); }
482
483 // Iterators
486 }
487
490 }
491
492 static bool classof(const Stmt *T) {
493 return T->getStmtClass() == ObjCSelectorExprClass;
494 }
495};
496
497/// ObjCProtocolExpr used for protocol expression in Objective-C.
498///
499/// This is used as: \@protocol(foo), as in:
500/// \code
501/// [obj conformsToProtocol:@protocol(foo)]
502/// \endcode
503///
504/// The return type is "Protocol*".
505class ObjCProtocolExpr : public Expr {
506 ObjCProtocolDecl *TheProtocol;
507 SourceLocation AtLoc, ProtoLoc, RParenLoc;
508
509public:
510 friend class ASTStmtReader;
511 friend class ASTStmtWriter;
512
514 SourceLocation protoLoc, SourceLocation rp)
515 : Expr(ObjCProtocolExprClass, T, VK_PRValue, OK_Ordinary),
516 TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) {
517 setDependence(ExprDependence::None);
518 }
520 : Expr(ObjCProtocolExprClass, Empty) {}
521
522 ObjCProtocolDecl *getProtocol() const { return TheProtocol; }
523 void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; }
524
525 SourceLocation getProtocolIdLoc() const { return ProtoLoc; }
526 SourceLocation getAtLoc() const { return AtLoc; }
527 SourceLocation getRParenLoc() const { return RParenLoc; }
528 void setAtLoc(SourceLocation L) { AtLoc = L; }
529 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
530
531 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
532 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
533
534 // Iterators
537 }
538
541 }
542
543 static bool classof(const Stmt *T) {
544 return T->getStmtClass() == ObjCProtocolExprClass;
545 }
546};
547
548/// ObjCIvarRefExpr - A reference to an ObjC instance variable.
549class ObjCIvarRefExpr : public Expr {
550 ObjCIvarDecl *D;
551 Stmt *Base;
552 SourceLocation Loc;
553
554 /// OpLoc - This is the location of '.' or '->'
555 SourceLocation OpLoc;
556
557 // True if this is "X->F", false if this is "X.F".
558 LLVM_PREFERRED_TYPE(bool)
559 bool IsArrow : 1;
560
561 // True if ivar reference has no base (self assumed).
562 LLVM_PREFERRED_TYPE(bool)
563 bool IsFreeIvar : 1;
564
565public:
567 SourceLocation oploc, Expr *base, bool arrow = false,
568 bool freeIvar = false)
569 : Expr(ObjCIvarRefExprClass, t, VK_LValue,
570 d->isBitField() ? OK_BitField : OK_Ordinary),
571 D(d), Base(base), Loc(l), OpLoc(oploc), IsArrow(arrow),
572 IsFreeIvar(freeIvar) {
574 }
575
577 : Expr(ObjCIvarRefExprClass, Empty) {}
578
579 ObjCIvarDecl *getDecl() { return D; }
580 const ObjCIvarDecl *getDecl() const { return D; }
581 void setDecl(ObjCIvarDecl *d) { D = d; }
582
583 const Expr *getBase() const { return cast<Expr>(Base); }
584 Expr *getBase() { return cast<Expr>(Base); }
585 void setBase(Expr * base) { Base = base; }
586
587 bool isArrow() const { return IsArrow; }
588 bool isFreeIvar() const { return IsFreeIvar; }
589 void setIsArrow(bool A) { IsArrow = A; }
590 void setIsFreeIvar(bool A) { IsFreeIvar = A; }
591
592 SourceLocation getLocation() const { return Loc; }
594
595 SourceLocation getBeginLoc() const LLVM_READONLY {
596 return isFreeIvar() ? Loc : getBase()->getBeginLoc();
597 }
598 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
599
600 SourceLocation getOpLoc() const { return OpLoc; }
601 void setOpLoc(SourceLocation L) { OpLoc = L; }
602
603 // Iterators
605
607 return const_child_range(&Base, &Base + 1);
608 }
609
610 static bool classof(const Stmt *T) {
611 return T->getStmtClass() == ObjCIvarRefExprClass;
612 }
613};
614
615/// ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC
616/// property.
617class ObjCPropertyRefExpr : public Expr {
618private:
619 /// If the bool is true, this is an implicit property reference; the
620 /// pointer is an (optional) ObjCMethodDecl and Setter may be set.
621 /// if the bool is false, this is an explicit property reference;
622 /// the pointer is an ObjCPropertyDecl and Setter is always null.
623 llvm::PointerIntPair<NamedDecl *, 1, bool> PropertyOrGetter;
624
625 /// Indicates whether the property reference will result in a message
626 /// to the getter, the setter, or both.
627 /// This applies to both implicit and explicit property references.
628 enum MethodRefFlags {
629 MethodRef_None = 0,
630 MethodRef_Getter = 0x1,
631 MethodRef_Setter = 0x2
632 };
633
634 /// Contains the Setter method pointer and MethodRefFlags bit flags.
635 llvm::PointerIntPair<ObjCMethodDecl *, 2, unsigned> SetterAndMethodRefFlags;
636
637 // FIXME: Maybe we should store the property identifier here,
638 // because it's not rederivable from the other data when there's an
639 // implicit property with no getter (because the 'foo' -> 'setFoo:'
640 // transformation is lossy on the first character).
641
642 SourceLocation IdLoc;
643
644 /// When the receiver in property access is 'super', this is
645 /// the location of the 'super' keyword. When it's an interface,
646 /// this is that interface.
647 SourceLocation ReceiverLoc;
648 llvm::PointerUnion<Stmt *, const Type *, ObjCInterfaceDecl *> Receiver;
649
650public:
653 : Expr(ObjCPropertyRefExprClass, t, VK, OK), PropertyOrGetter(PD, false),
654 IdLoc(l), Receiver(base) {
655 assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
657 }
658
661 QualType st)
662 : Expr(ObjCPropertyRefExprClass, t, VK, OK), PropertyOrGetter(PD, false),
663 IdLoc(l), ReceiverLoc(sl), Receiver(st.getTypePtr()) {
664 assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
666 }
667
670 SourceLocation IdLoc, Expr *Base)
671 : Expr(ObjCPropertyRefExprClass, T, VK, OK),
672 PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
673 IdLoc(IdLoc), Receiver(Base) {
674 assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
676 }
677
680 SourceLocation IdLoc, SourceLocation SuperLoc,
681 QualType SuperTy)
682 : Expr(ObjCPropertyRefExprClass, T, VK, OK),
683 PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
684 IdLoc(IdLoc), ReceiverLoc(SuperLoc), Receiver(SuperTy.getTypePtr()) {
685 assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
687 }
688
691 SourceLocation IdLoc, SourceLocation ReceiverLoc,
692 ObjCInterfaceDecl *Receiver)
693 : Expr(ObjCPropertyRefExprClass, T, VK, OK),
694 PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
695 IdLoc(IdLoc), ReceiverLoc(ReceiverLoc), Receiver(Receiver) {
696 assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
698 }
699
701 : Expr(ObjCPropertyRefExprClass, Empty) {}
702
703 bool isImplicitProperty() const { return PropertyOrGetter.getInt(); }
704 bool isExplicitProperty() const { return !PropertyOrGetter.getInt(); }
705
707 assert(!isImplicitProperty());
708 return cast<ObjCPropertyDecl>(PropertyOrGetter.getPointer());
709 }
710
712 assert(isImplicitProperty());
713 return cast_or_null<ObjCMethodDecl>(PropertyOrGetter.getPointer());
714 }
715
717 assert(isImplicitProperty());
718 return SetterAndMethodRefFlags.getPointer();
719 }
720
722 if (isImplicitProperty())
725 }
726
728 if (isImplicitProperty())
731 }
732
733 /// True if the property reference will result in a message to the
734 /// getter.
735 /// This applies to both implicit and explicit property references.
736 bool isMessagingGetter() const {
737 return SetterAndMethodRefFlags.getInt() & MethodRef_Getter;
738 }
739
740 /// True if the property reference will result in a message to the
741 /// setter.
742 /// This applies to both implicit and explicit property references.
743 bool isMessagingSetter() const {
744 return SetterAndMethodRefFlags.getInt() & MethodRef_Setter;
745 }
746
747 void setIsMessagingGetter(bool val = true) {
748 setMethodRefFlag(MethodRef_Getter, val);
749 }
750
751 void setIsMessagingSetter(bool val = true) {
752 setMethodRefFlag(MethodRef_Setter, val);
753 }
754
755 const Expr *getBase() const {
756 return cast<Expr>(Receiver.get<Stmt*>());
757 }
759 return cast<Expr>(Receiver.get<Stmt*>());
760 }
761
762 SourceLocation getLocation() const { return IdLoc; }
763
764 SourceLocation getReceiverLocation() const { return ReceiverLoc; }
765
767 return QualType(Receiver.get<const Type*>(), 0);
768 }
769
771 return Receiver.get<ObjCInterfaceDecl*>();
772 }
773
774 bool isObjectReceiver() const { return Receiver.is<Stmt*>(); }
775 bool isSuperReceiver() const { return Receiver.is<const Type*>(); }
776 bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
777
778 /// Determine the type of the base, regardless of the kind of receiver.
779 QualType getReceiverType(const ASTContext &ctx) const;
780
781 SourceLocation getBeginLoc() const LLVM_READONLY {
782 return isObjectReceiver() ? getBase()->getBeginLoc()
784 }
785
786 SourceLocation getEndLoc() const LLVM_READONLY { return IdLoc; }
787
788 // Iterators
790 if (Receiver.is<Stmt*>()) {
791 Stmt **begin = reinterpret_cast<Stmt**>(&Receiver); // hack!
792 return child_range(begin, begin+1);
793 }
795 }
796
798 auto Children = const_cast<ObjCPropertyRefExpr *>(this)->children();
799 return const_child_range(Children.begin(), Children.end());
800 }
801
802 static bool classof(const Stmt *T) {
803 return T->getStmtClass() == ObjCPropertyRefExprClass;
804 }
805
806private:
807 friend class ASTStmtReader;
808 friend class ASTStmtWriter;
809
810 void setExplicitProperty(ObjCPropertyDecl *D, unsigned methRefFlags) {
811 PropertyOrGetter.setPointer(D);
812 PropertyOrGetter.setInt(false);
813 SetterAndMethodRefFlags.setPointer(nullptr);
814 SetterAndMethodRefFlags.setInt(methRefFlags);
815 }
816
817 void setImplicitProperty(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
818 unsigned methRefFlags) {
819 PropertyOrGetter.setPointer(Getter);
820 PropertyOrGetter.setInt(true);
821 SetterAndMethodRefFlags.setPointer(Setter);
822 SetterAndMethodRefFlags.setInt(methRefFlags);
823 }
824
825 void setBase(Expr *Base) { Receiver = Base; }
826 void setSuperReceiver(QualType T) { Receiver = T.getTypePtr(); }
827 void setClassReceiver(ObjCInterfaceDecl *D) { Receiver = D; }
828
829 void setLocation(SourceLocation L) { IdLoc = L; }
830 void setReceiverLocation(SourceLocation Loc) { ReceiverLoc = Loc; }
831
832 void setMethodRefFlag(MethodRefFlags flag, bool val) {
833 unsigned f = SetterAndMethodRefFlags.getInt();
834 if (val)
835 f |= flag;
836 else
837 f &= ~flag;
838 SetterAndMethodRefFlags.setInt(f);
839 }
840};
841
842/// ObjCSubscriptRefExpr - used for array and dictionary subscripting.
843/// array[4] = array[3]; dictionary[key] = dictionary[alt_key];
845 // Location of ']' in an indexing expression.
846 SourceLocation RBracket;
847
848 // array/dictionary base expression.
849 // for arrays, this is a numeric expression. For dictionaries, this is
850 // an objective-c object pointer expression.
851 enum { BASE, KEY, END_EXPR };
852 Stmt* SubExprs[END_EXPR];
853
854 ObjCMethodDecl *GetAtIndexMethodDecl;
855
856 // For immutable objects this is null. When ObjCSubscriptRefExpr is to read
857 // an indexed object this is null too.
858 ObjCMethodDecl *SetAtIndexMethodDecl;
859
860public:
862 ExprObjectKind OK, ObjCMethodDecl *getMethod,
863 ObjCMethodDecl *setMethod, SourceLocation RB)
864 : Expr(ObjCSubscriptRefExprClass, T, VK, OK), RBracket(RB),
865 GetAtIndexMethodDecl(getMethod), SetAtIndexMethodDecl(setMethod) {
866 SubExprs[BASE] = base;
867 SubExprs[KEY] = key;
869 }
870
872 : Expr(ObjCSubscriptRefExprClass, Empty) {}
873
874 SourceLocation getRBracket() const { return RBracket; }
875 void setRBracket(SourceLocation RB) { RBracket = RB; }
876
877 SourceLocation getBeginLoc() const LLVM_READONLY {
878 return SubExprs[BASE]->getBeginLoc();
879 }
880
881 SourceLocation getEndLoc() const LLVM_READONLY { return RBracket; }
882
883 Expr *getBaseExpr() const { return cast<Expr>(SubExprs[BASE]); }
884 void setBaseExpr(Stmt *S) { SubExprs[BASE] = S; }
885
886 Expr *getKeyExpr() const { return cast<Expr>(SubExprs[KEY]); }
887 void setKeyExpr(Stmt *S) { SubExprs[KEY] = S; }
888
890 return GetAtIndexMethodDecl;
891 }
892
894 return SetAtIndexMethodDecl;
895 }
896
899 }
900
902 return child_range(SubExprs, SubExprs+END_EXPR);
903 }
904
906 return const_child_range(SubExprs, SubExprs + END_EXPR);
907 }
908
909 static bool classof(const Stmt *T) {
910 return T->getStmtClass() == ObjCSubscriptRefExprClass;
911 }
912
913private:
914 friend class ASTStmtReader;
915};
916
917/// An expression that sends a message to the given Objective-C
918/// object or class.
919///
920/// The following contains two message send expressions:
921///
922/// \code
923/// [[NSString alloc] initWithString:@"Hello"]
924/// \endcode
925///
926/// The innermost message send invokes the "alloc" class method on the
927/// NSString class, while the outermost message send invokes the
928/// "initWithString" instance method on the object returned from
929/// NSString's "alloc". In all, an Objective-C message send can take
930/// on four different (although related) forms:
931///
932/// 1. Send to an object instance.
933/// 2. Send to a class.
934/// 3. Send to the superclass instance of the current class.
935/// 4. Send to the superclass of the current class.
936///
937/// All four kinds of message sends are modeled by the ObjCMessageExpr
938/// class, and can be distinguished via \c getReceiverKind(). Example:
939///
940/// The "void *" trailing objects are actually ONE void * (the
941/// receiver pointer), and NumArgs Expr *. But due to the
942/// implementation of children(), these must be together contiguously.
944 : public Expr,
945 private llvm::TrailingObjects<ObjCMessageExpr, void *, SourceLocation> {
946public:
947 /// The kind of receiver this message is sending to.
949 /// The receiver is a class.
950 Class = 0,
951
952 /// The receiver is an object instance.
954
955 /// The receiver is a superclass.
957
958 /// The receiver is the instance of the superclass object.
960 };
961
962private:
963 /// Stores either the selector that this message is sending
964 /// to (when \c HasMethod is zero) or an \c ObjCMethodDecl pointer
965 /// referring to the method that we type-checked against.
966 uintptr_t SelectorOrMethod = 0;
967
968 enum { NumArgsBitWidth = 16 };
969
970 /// The number of arguments in the message send, not
971 /// including the receiver.
972 unsigned NumArgs : NumArgsBitWidth;
973
974 /// The kind of message send this is, which is one of the
975 /// ReceiverKind values.
976 ///
977 /// We pad this out to a byte to avoid excessive masking and shifting.
978 LLVM_PREFERRED_TYPE(ReceiverKind)
979 unsigned Kind : 8;
980
981 /// Whether we have an actual method prototype in \c
982 /// SelectorOrMethod.
983 ///
984 /// When non-zero, we have a method declaration; otherwise, we just
985 /// have a selector.
986 LLVM_PREFERRED_TYPE(bool)
987 unsigned HasMethod : 1;
988
989 /// Whether this message send is a "delegate init call",
990 /// i.e. a call of an init method on self from within an init method.
991 LLVM_PREFERRED_TYPE(bool)
992 unsigned IsDelegateInitCall : 1;
993
994 /// Whether this message send was implicitly generated by
995 /// the implementation rather than explicitly written by the user.
996 LLVM_PREFERRED_TYPE(bool)
997 unsigned IsImplicit : 1;
998
999 /// Whether the locations of the selector identifiers are in a
1000 /// "standard" position, a enum SelectorLocationsKind.
1001 LLVM_PREFERRED_TYPE(SelectorLocationsKind)
1002 unsigned SelLocsKind : 2;
1003
1004 /// When the message expression is a send to 'super', this is
1005 /// the location of the 'super' keyword.
1006 SourceLocation SuperLoc;
1007
1008 /// The source locations of the open and close square
1009 /// brackets ('[' and ']', respectively).
1010 SourceLocation LBracLoc, RBracLoc;
1011
1012 ObjCMessageExpr(EmptyShell Empty, unsigned NumArgs)
1013 : Expr(ObjCMessageExprClass, Empty), Kind(0), HasMethod(false),
1014 IsDelegateInitCall(false), IsImplicit(false), SelLocsKind(0) {
1015 setNumArgs(NumArgs);
1016 }
1017
1018 ObjCMessageExpr(QualType T, ExprValueKind VK,
1019 SourceLocation LBracLoc,
1020 SourceLocation SuperLoc,
1021 bool IsInstanceSuper,
1022 QualType SuperType,
1023 Selector Sel,
1024 ArrayRef<SourceLocation> SelLocs,
1025 SelectorLocationsKind SelLocsK,
1026 ObjCMethodDecl *Method,
1027 ArrayRef<Expr *> Args,
1028 SourceLocation RBracLoc,
1029 bool isImplicit);
1030 ObjCMessageExpr(QualType T, ExprValueKind VK,
1031 SourceLocation LBracLoc,
1032 TypeSourceInfo *Receiver,
1033 Selector Sel,
1034 ArrayRef<SourceLocation> SelLocs,
1035 SelectorLocationsKind SelLocsK,
1036 ObjCMethodDecl *Method,
1037 ArrayRef<Expr *> Args,
1038 SourceLocation RBracLoc,
1039 bool isImplicit);
1040 ObjCMessageExpr(QualType T, ExprValueKind VK,
1041 SourceLocation LBracLoc,
1042 Expr *Receiver,
1043 Selector Sel,
1044 ArrayRef<SourceLocation> SelLocs,
1045 SelectorLocationsKind SelLocsK,
1046 ObjCMethodDecl *Method,
1047 ArrayRef<Expr *> Args,
1048 SourceLocation RBracLoc,
1049 bool isImplicit);
1050
1051 size_t numTrailingObjects(OverloadToken<void *>) const { return NumArgs + 1; }
1052
1053 void setNumArgs(unsigned Num) {
1054 assert((Num >> NumArgsBitWidth) == 0 && "Num of args is out of range!");
1055 NumArgs = Num;
1056 }
1057
1058 void initArgsAndSelLocs(ArrayRef<Expr *> Args,
1059 ArrayRef<SourceLocation> SelLocs,
1060 SelectorLocationsKind SelLocsK);
1061
1062 /// Retrieve the pointer value of the message receiver.
1063 void *getReceiverPointer() const { return *getTrailingObjects<void *>(); }
1064
1065 /// Set the pointer value of the message receiver.
1066 void setReceiverPointer(void *Value) {
1067 *getTrailingObjects<void *>() = Value;
1068 }
1069
1070 SelectorLocationsKind getSelLocsKind() const {
1071 return (SelectorLocationsKind)SelLocsKind;
1072 }
1073
1074 bool hasStandardSelLocs() const {
1075 return getSelLocsKind() != SelLoc_NonStandard;
1076 }
1077
1078 /// Get a pointer to the stored selector identifiers locations array.
1079 /// No locations will be stored if HasStandardSelLocs is true.
1080 SourceLocation *getStoredSelLocs() {
1081 return getTrailingObjects<SourceLocation>();
1082 }
1083 const SourceLocation *getStoredSelLocs() const {
1084 return getTrailingObjects<SourceLocation>();
1085 }
1086
1087 /// Get the number of stored selector identifiers locations.
1088 /// No locations will be stored if HasStandardSelLocs is true.
1089 unsigned getNumStoredSelLocs() const {
1090 if (hasStandardSelLocs())
1091 return 0;
1092 return getNumSelectorLocs();
1093 }
1094
1095 static ObjCMessageExpr *alloc(const ASTContext &C,
1096 ArrayRef<Expr *> Args,
1097 SourceLocation RBraceLoc,
1098 ArrayRef<SourceLocation> SelLocs,
1099 Selector Sel,
1100 SelectorLocationsKind &SelLocsK);
1101 static ObjCMessageExpr *alloc(const ASTContext &C,
1102 unsigned NumArgs,
1103 unsigned NumStoredSelLocs);
1104
1105public:
1106 friend class ASTStmtReader;
1107 friend class ASTStmtWriter;
1109
1110 /// Create a message send to super.
1111 ///
1112 /// \param Context The ASTContext in which this expression will be created.
1113 ///
1114 /// \param T The result type of this message.
1115 ///
1116 /// \param VK The value kind of this message. A message returning
1117 /// a l-value or r-value reference will be an l-value or x-value,
1118 /// respectively.
1119 ///
1120 /// \param LBracLoc The location of the open square bracket '['.
1121 ///
1122 /// \param SuperLoc The location of the "super" keyword.
1123 ///
1124 /// \param IsInstanceSuper Whether this is an instance "super"
1125 /// message (otherwise, it's a class "super" message).
1126 ///
1127 /// \param Sel The selector used to determine which method gets called.
1128 ///
1129 /// \param Method The Objective-C method against which this message
1130 /// send was type-checked. May be nullptr.
1131 ///
1132 /// \param Args The message send arguments.
1133 ///
1134 /// \param RBracLoc The location of the closing square bracket ']'.
1135 static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1136 ExprValueKind VK,
1137 SourceLocation LBracLoc,
1138 SourceLocation SuperLoc,
1139 bool IsInstanceSuper,
1140 QualType SuperType,
1141 Selector Sel,
1143 ObjCMethodDecl *Method,
1144 ArrayRef<Expr *> Args,
1145 SourceLocation RBracLoc,
1146 bool isImplicit);
1147
1148 /// Create a class message send.
1149 ///
1150 /// \param Context The ASTContext in which this expression will be created.
1151 ///
1152 /// \param T The result type of this message.
1153 ///
1154 /// \param VK The value kind of this message. A message returning
1155 /// a l-value or r-value reference will be an l-value or x-value,
1156 /// respectively.
1157 ///
1158 /// \param LBracLoc The location of the open square bracket '['.
1159 ///
1160 /// \param Receiver The type of the receiver, including
1161 /// source-location information.
1162 ///
1163 /// \param Sel The selector used to determine which method gets called.
1164 ///
1165 /// \param Method The Objective-C method against which this message
1166 /// send was type-checked. May be nullptr.
1167 ///
1168 /// \param Args The message send arguments.
1169 ///
1170 /// \param RBracLoc The location of the closing square bracket ']'.
1171 static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1172 ExprValueKind VK,
1173 SourceLocation LBracLoc,
1174 TypeSourceInfo *Receiver,
1175 Selector Sel,
1177 ObjCMethodDecl *Method,
1178 ArrayRef<Expr *> Args,
1179 SourceLocation RBracLoc,
1180 bool isImplicit);
1181
1182 /// Create an instance message send.
1183 ///
1184 /// \param Context The ASTContext in which this expression will be created.
1185 ///
1186 /// \param T The result type of this message.
1187 ///
1188 /// \param VK The value kind of this message. A message returning
1189 /// a l-value or r-value reference will be an l-value or x-value,
1190 /// respectively.
1191 ///
1192 /// \param LBracLoc The location of the open square bracket '['.
1193 ///
1194 /// \param Receiver The expression used to produce the object that
1195 /// will receive this message.
1196 ///
1197 /// \param Sel The selector used to determine which method gets called.
1198 ///
1199 /// \param Method The Objective-C method against which this message
1200 /// send was type-checked. May be nullptr.
1201 ///
1202 /// \param Args The message send arguments.
1203 ///
1204 /// \param RBracLoc The location of the closing square bracket ']'.
1205 static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1206 ExprValueKind VK,
1207 SourceLocation LBracLoc,
1208 Expr *Receiver,
1209 Selector Sel,
1211 ObjCMethodDecl *Method,
1212 ArrayRef<Expr *> Args,
1213 SourceLocation RBracLoc,
1214 bool isImplicit);
1215
1216 /// Create an empty Objective-C message expression, to be
1217 /// filled in by subsequent calls.
1218 ///
1219 /// \param Context The context in which the message send will be created.
1220 ///
1221 /// \param NumArgs The number of message arguments, not including
1222 /// the receiver.
1223 static ObjCMessageExpr *CreateEmpty(const ASTContext &Context,
1224 unsigned NumArgs,
1225 unsigned NumStoredSelLocs);
1226
1227 /// Indicates whether the message send was implicitly
1228 /// generated by the implementation. If false, it was written explicitly
1229 /// in the source code.
1230 bool isImplicit() const { return IsImplicit; }
1231
1232 /// Determine the kind of receiver that this message is being
1233 /// sent to.
1235
1236 /// \return the return type of the message being sent.
1237 /// This is not always the type of the message expression itself because
1238 /// of references (the expression would not have a reference type).
1239 /// It is also not always the declared return type of the method because
1240 /// of `instancetype` (in that case it's an expression type).
1242
1243 /// Source range of the receiver.
1245
1246 /// Determine whether this is an instance message to either a
1247 /// computed object or to super.
1248 bool isInstanceMessage() const {
1250 }
1251
1252 /// Determine whether this is an class message to either a
1253 /// specified class or to super.
1254 bool isClassMessage() const {
1255 return getReceiverKind() == Class || getReceiverKind() == SuperClass;
1256 }
1257
1258 /// Returns the object expression (receiver) for an instance message,
1259 /// or null for a message that is not an instance message.
1261 if (getReceiverKind() == Instance)
1262 return static_cast<Expr *>(getReceiverPointer());
1263
1264 return nullptr;
1265 }
1266 const Expr *getInstanceReceiver() const {
1267 return const_cast<ObjCMessageExpr*>(this)->getInstanceReceiver();
1268 }
1269
1270 /// Turn this message send into an instance message that
1271 /// computes the receiver object with the given expression.
1273 Kind = Instance;
1274 setReceiverPointer(rec);
1275 }
1276
1277 /// Returns the type of a class message send, or NULL if the
1278 /// message is not a class message.
1281 return TSInfo->getType();
1282
1283 return {};
1284 }
1285
1286 /// Returns a type-source information of a class message
1287 /// send, or nullptr if the message is not a class message.
1289 if (getReceiverKind() == Class)
1290 return reinterpret_cast<TypeSourceInfo *>(getReceiverPointer());
1291 return nullptr;
1292 }
1293
1295 Kind = Class;
1296 setReceiverPointer(TSInfo);
1297 }
1298
1299 /// Retrieve the location of the 'super' keyword for a class
1300 /// or instance message to 'super', otherwise an invalid source location.
1303 return SuperLoc;
1304
1305 return SourceLocation();
1306 }
1307
1308 /// Retrieve the receiver type to which this message is being directed.
1309 ///
1310 /// This routine cross-cuts all of the different kinds of message
1311 /// sends to determine what the underlying (statically known) type
1312 /// of the receiver will be; use \c getReceiverKind() to determine
1313 /// whether the message is a class or an instance method, whether it
1314 /// is a send to super or not, etc.
1315 ///
1316 /// \returns The type of the receiver.
1317 QualType getReceiverType() const;
1318
1319 /// Retrieve the Objective-C interface to which this message
1320 /// is being directed, if known.
1321 ///
1322 /// This routine cross-cuts all of the different kinds of message
1323 /// sends to determine what the underlying (statically known) type
1324 /// of the receiver will be; use \c getReceiverKind() to determine
1325 /// whether the message is a class or an instance method, whether it
1326 /// is a send to super or not, etc.
1327 ///
1328 /// \returns The Objective-C interface if known, otherwise nullptr.
1330
1331 /// Retrieve the type referred to by 'super'.
1332 ///
1333 /// The returned type will either be an ObjCInterfaceType (for an
1334 /// class message to super) or an ObjCObjectPointerType that refers
1335 /// to a class (for an instance message to super);
1338 return QualType::getFromOpaquePtr(getReceiverPointer());
1339
1340 return QualType();
1341 }
1342
1343 void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper) {
1344 Kind = IsInstanceSuper? SuperInstance : SuperClass;
1345 SuperLoc = Loc;
1346 setReceiverPointer(T.getAsOpaquePtr());
1347 }
1348
1349 Selector getSelector() const;
1350
1352 HasMethod = false;
1353 SelectorOrMethod = reinterpret_cast<uintptr_t>(S.getAsOpaquePtr());
1354 }
1355
1357 if (HasMethod)
1358 return reinterpret_cast<const ObjCMethodDecl *>(SelectorOrMethod);
1359
1360 return nullptr;
1361 }
1362
1364 if (HasMethod)
1365 return reinterpret_cast<ObjCMethodDecl *>(SelectorOrMethod);
1366
1367 return nullptr;
1368 }
1369
1371 HasMethod = true;
1372 SelectorOrMethod = reinterpret_cast<uintptr_t>(MD);
1373 }
1374
1376 if (HasMethod) return getMethodDecl()->getMethodFamily();
1377 return getSelector().getMethodFamily();
1378 }
1379
1380 /// Return the number of actual arguments in this message,
1381 /// not counting the receiver.
1382 unsigned getNumArgs() const { return NumArgs; }
1383
1384 /// Retrieve the arguments to this message, not including the
1385 /// receiver.
1387 return reinterpret_cast<Expr **>(getTrailingObjects<void *>() + 1);
1388 }
1389 const Expr * const *getArgs() const {
1390 return reinterpret_cast<const Expr *const *>(getTrailingObjects<void *>() +
1391 1);
1392 }
1393
1394 /// getArg - Return the specified argument.
1395 Expr *getArg(unsigned Arg) {
1396 assert(Arg < NumArgs && "Arg access out of range!");
1397 return getArgs()[Arg];
1398 }
1399 const Expr *getArg(unsigned Arg) const {
1400 assert(Arg < NumArgs && "Arg access out of range!");
1401 return getArgs()[Arg];
1402 }
1403
1404 /// setArg - Set the specified argument.
1405 void setArg(unsigned Arg, Expr *ArgExpr) {
1406 assert(Arg < NumArgs && "Arg access out of range!");
1407 getArgs()[Arg] = ArgExpr;
1408 }
1409
1410 /// isDelegateInitCall - Answers whether this message send has been
1411 /// tagged as a "delegate init call", i.e. a call to a method in the
1412 /// -init family on self from within an -init method implementation.
1413 bool isDelegateInitCall() const { return IsDelegateInitCall; }
1414 void setDelegateInitCall(bool isDelegate) { IsDelegateInitCall = isDelegate; }
1415
1416 SourceLocation getLeftLoc() const { return LBracLoc; }
1417 SourceLocation getRightLoc() const { return RBracLoc; }
1418
1420 if (isImplicit())
1421 return getBeginLoc();
1422 return getSelectorLoc(0);
1423 }
1424
1425 SourceLocation getSelectorLoc(unsigned Index) const {
1426 assert(Index < getNumSelectorLocs() && "Index out of range!");
1427 if (hasStandardSelLocs())
1429 Index, getSelector(), getSelLocsKind() == SelLoc_StandardWithSpace,
1430 llvm::ArrayRef(const_cast<Expr **>(getArgs()), getNumArgs()),
1431 RBracLoc);
1432 return getStoredSelLocs()[Index];
1433 }
1434
1436
1437 unsigned getNumSelectorLocs() const {
1438 if (isImplicit())
1439 return 0;
1440 Selector Sel = getSelector();
1441 if (Sel.isUnarySelector())
1442 return 1;
1443 return Sel.getNumArgs();
1444 }
1445
1447 LBracLoc = R.getBegin();
1448 RBracLoc = R.getEnd();
1449 }
1450
1451 SourceLocation getBeginLoc() const LLVM_READONLY { return LBracLoc; }
1452 SourceLocation getEndLoc() const LLVM_READONLY { return RBracLoc; }
1453
1454 // Iterators
1456
1458
1461
1462 llvm::iterator_range<arg_iterator> arguments() {
1463 return llvm::make_range(arg_begin(), arg_end());
1464 }
1465
1466 llvm::iterator_range<const_arg_iterator> arguments() const {
1467 return llvm::make_range(arg_begin(), arg_end());
1468 }
1469
1470 arg_iterator arg_begin() { return reinterpret_cast<Stmt **>(getArgs()); }
1471
1473 return reinterpret_cast<Stmt **>(getArgs() + NumArgs);
1474 }
1475
1477 return reinterpret_cast<Stmt const * const*>(getArgs());
1478 }
1479
1481 return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs);
1482 }
1483
1484 static bool classof(const Stmt *T) {
1485 return T->getStmtClass() == ObjCMessageExprClass;
1486 }
1487};
1488
1489/// ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
1490/// (similar in spirit to MemberExpr).
1491class ObjCIsaExpr : public Expr {
1492 /// Base - the expression for the base object pointer.
1493 Stmt *Base;
1494
1495 /// IsaMemberLoc - This is the location of the 'isa'.
1496 SourceLocation IsaMemberLoc;
1497
1498 /// OpLoc - This is the location of '.' or '->'
1499 SourceLocation OpLoc;
1500
1501 /// IsArrow - True if this is "X->F", false if this is "X.F".
1502 bool IsArrow;
1503
1504public:
1505 ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc,
1506 QualType ty)
1507 : Expr(ObjCIsaExprClass, ty, VK_LValue, OK_Ordinary), Base(base),
1508 IsaMemberLoc(l), OpLoc(oploc), IsArrow(isarrow) {
1510 }
1511
1512 /// Build an empty expression.
1513 explicit ObjCIsaExpr(EmptyShell Empty) : Expr(ObjCIsaExprClass, Empty) {}
1514
1515 void setBase(Expr *E) { Base = E; }
1516 Expr *getBase() const { return cast<Expr>(Base); }
1517
1518 bool isArrow() const { return IsArrow; }
1519 void setArrow(bool A) { IsArrow = A; }
1520
1521 /// getMemberLoc - Return the location of the "member", in X->F, it is the
1522 /// location of 'F'.
1523 SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; }
1524 void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; }
1525
1526 SourceLocation getOpLoc() const { return OpLoc; }
1527 void setOpLoc(SourceLocation L) { OpLoc = L; }
1528
1529 SourceLocation getBeginLoc() const LLVM_READONLY {
1530 return getBase()->getBeginLoc();
1531 }
1532
1533 SourceLocation getBaseLocEnd() const LLVM_READONLY {
1534 return getBase()->getEndLoc();
1535 }
1536
1537 SourceLocation getEndLoc() const LLVM_READONLY { return IsaMemberLoc; }
1538
1539 SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; }
1540
1541 // Iterators
1543
1545 return const_child_range(&Base, &Base + 1);
1546 }
1547
1548 static bool classof(const Stmt *T) {
1549 return T->getStmtClass() == ObjCIsaExprClass;
1550 }
1551};
1552
1553/// ObjCIndirectCopyRestoreExpr - Represents the passing of a function
1554/// argument by indirect copy-restore in ARC. This is used to support
1555/// passing indirect arguments with the wrong lifetime, e.g. when
1556/// passing the address of a __strong local variable to an 'out'
1557/// parameter. This expression kind is only valid in an "argument"
1558/// position to some sort of call expression.
1559///
1560/// The parameter must have type 'pointer to T', and the argument must
1561/// have type 'pointer to U', where T and U agree except possibly in
1562/// qualification. If the argument value is null, then a null pointer
1563/// is passed; otherwise it points to an object A, and:
1564/// 1. A temporary object B of type T is initialized, either by
1565/// zero-initialization (used when initializing an 'out' parameter)
1566/// or copy-initialization (used when initializing an 'inout'
1567/// parameter).
1568/// 2. The address of the temporary is passed to the function.
1569/// 3. If the call completes normally, A is move-assigned from B.
1570/// 4. Finally, A is destroyed immediately.
1571///
1572/// Currently 'T' must be a retainable object lifetime and must be
1573/// __autoreleasing; this qualifier is ignored when initializing
1574/// the value.
1576 friend class ASTReader;
1577 friend class ASTStmtReader;
1578
1579 Stmt *Operand;
1580
1581 // unsigned ObjCIndirectCopyRestoreBits.ShouldCopy : 1;
1582
1584 : Expr(ObjCIndirectCopyRestoreExprClass, Empty) {}
1585
1586 void setShouldCopy(bool shouldCopy) {
1588 }
1589
1590public:
1592 : Expr(ObjCIndirectCopyRestoreExprClass, type, VK_LValue, OK_Ordinary),
1593 Operand(operand) {
1594 setShouldCopy(shouldCopy);
1596 }
1597
1598 Expr *getSubExpr() { return cast<Expr>(Operand); }
1599 const Expr *getSubExpr() const { return cast<Expr>(Operand); }
1600
1601 /// shouldCopy - True if we should do the 'copy' part of the
1602 /// copy-restore. If false, the temporary will be zero-initialized.
1603 bool shouldCopy() const { return ObjCIndirectCopyRestoreExprBits.ShouldCopy; }
1604
1605 child_range children() { return child_range(&Operand, &Operand+1); }
1606
1608 return const_child_range(&Operand, &Operand + 1);
1609 }
1610
1611 // Source locations are determined by the subexpression.
1612 SourceLocation getBeginLoc() const LLVM_READONLY {
1613 return Operand->getBeginLoc();
1614 }
1615 SourceLocation getEndLoc() const LLVM_READONLY {
1616 return Operand->getEndLoc();
1617 }
1618
1619 SourceLocation getExprLoc() const LLVM_READONLY {
1620 return getSubExpr()->getExprLoc();
1621 }
1622
1623 static bool classof(const Stmt *s) {
1624 return s->getStmtClass() == ObjCIndirectCopyRestoreExprClass;
1625 }
1626};
1627
1628/// An Objective-C "bridged" cast expression, which casts between
1629/// Objective-C pointers and C pointers, transferring ownership in the process.
1630///
1631/// \code
1632/// NSString *str = (__bridge_transfer NSString *)CFCreateString();
1633/// \endcode
1635 : public ExplicitCastExpr,
1636 private llvm::TrailingObjects<ObjCBridgedCastExpr, CXXBaseSpecifier *> {
1637 friend class ASTStmtReader;
1638 friend class ASTStmtWriter;
1639 friend class CastExpr;
1640 friend TrailingObjects;
1641
1642 SourceLocation LParenLoc;
1643 SourceLocation BridgeKeywordLoc;
1644 LLVM_PREFERRED_TYPE(ObjCBridgeCastKind)
1645 unsigned Kind : 2;
1646
1647public:
1649 CastKind CK, SourceLocation BridgeKeywordLoc,
1650 TypeSourceInfo *TSInfo, Expr *Operand)
1651 : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(),
1652 VK_PRValue, CK, Operand, 0, false, TSInfo),
1653 LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {}
1654
1655 /// Construct an empty Objective-C bridged cast.
1657 : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0, false) {}
1658
1659 SourceLocation getLParenLoc() const { return LParenLoc; }
1660
1661 /// Determine which kind of bridge is being performed via this cast.
1663 return static_cast<ObjCBridgeCastKind>(Kind);
1664 }
1665
1666 /// Retrieve the kind of bridge being performed as a string.
1667 StringRef getBridgeKindName() const;
1668
1669 /// The location of the bridge keyword.
1670 SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; }
1671
1672 SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
1673
1674 SourceLocation getEndLoc() const LLVM_READONLY {
1675 return getSubExpr()->getEndLoc();
1676 }
1677
1678 static bool classof(const Stmt *T) {
1679 return T->getStmtClass() == ObjCBridgedCastExprClass;
1680 }
1681};
1682
1683/// A runtime availability query.
1684///
1685/// There are 2 ways to spell this node:
1686/// \code
1687/// @available(macos 10.10, ios 8, *); // Objective-C
1688/// __builtin_available(macos 10.10, ios 8, *); // C, C++, and Objective-C
1689/// \endcode
1690///
1691/// Note that we only need to keep track of one \c VersionTuple here, which is
1692/// the one that corresponds to the current deployment target. This is meant to
1693/// be used in the condition of an \c if, but it is also usable as top level
1694/// expressions.
1695///
1697 friend class ASTStmtReader;
1698
1699 VersionTuple VersionToCheck;
1700 SourceLocation AtLoc, RParen;
1701
1702public:
1703 ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc,
1704 SourceLocation RParen, QualType Ty)
1705 : Expr(ObjCAvailabilityCheckExprClass, Ty, VK_PRValue, OK_Ordinary),
1706 VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) {
1707 setDependence(ExprDependence::None);
1708 }
1709
1711 : Expr(ObjCAvailabilityCheckExprClass, Shell) {}
1712
1713 SourceLocation getBeginLoc() const { return AtLoc; }
1714 SourceLocation getEndLoc() const { return RParen; }
1715 SourceRange getSourceRange() const { return {AtLoc, RParen}; }
1716
1717 /// This may be '*', in which case this should fold to true.
1718 bool hasVersion() const { return !VersionToCheck.empty(); }
1719 VersionTuple getVersion() const { return VersionToCheck; }
1720
1723 }
1724
1727 }
1728
1729 static bool classof(const Stmt *T) {
1730 return T->getStmtClass() == ObjCAvailabilityCheckExprClass;
1731 }
1732};
1733
1734} // namespace clang
1735
1736#endif // LLVM_CLANG_AST_EXPROBJC_H
#define V(N, I)
Definition: ASTContext.h:3341
StringRef P
const Decl * D
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
Expr * E
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
SourceRange Range
Definition: SemaObjC.cpp:758
SourceLocation Loc
Definition: SemaObjC.cpp:759
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:187
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:378
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3498
Expr * getSubExpr()
Definition: Expr.h:3548
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:3750
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:277
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
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:1696
bool hasVersion() const
This may be '*', in which case this should fold to true.
Definition: ExprObjC.h:1718
const_child_range children() const
Definition: ExprObjC.h:1725
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1729
ObjCAvailabilityCheckExpr(EmptyShell Shell)
Definition: ExprObjC.h:1710
SourceRange getSourceRange() const
Definition: ExprObjC.h:1715
SourceLocation getBeginLoc() const
Definition: ExprObjC.h:1713
SourceLocation getEndLoc() const
Definition: ExprObjC.h:1714
VersionTuple getVersion() const
Definition: ExprObjC.h:1719
ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc, SourceLocation RParen, QualType Ty)
Definition: ExprObjC.h:1703
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:1636
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1674
ObjCBridgedCastExpr(EmptyShell Shell)
Construct an empty Objective-C bridged cast.
Definition: ExprObjC.h:1656
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
Definition: ExprObjC.cpp:341
SourceLocation getLParenLoc() const
Definition: ExprObjC.h:1659
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1678
SourceLocation getBridgeKeywordLoc() const
The location of the bridge keyword.
Definition: ExprObjC.h:1670
ObjCBridgeCastKind getBridgeKind() const
Determine which kind of bridge is being performed via this cast.
Definition: ExprObjC.h:1662
ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, CastKind CK, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *Operand)
Definition: ExprObjC.h:1648
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1672
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:309
static ObjCDictionaryLiteral * CreateEmpty(const ASTContext &C, unsigned NumElements, bool HasPackExpansions)
Definition: ExprObjC.cpp:88
const_child_range children() const
Definition: ExprObjC.h:397
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:360
ObjCMethodDecl * getDictWithObjectsMethod() const
Definition: ExprObjC.h:377
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:362
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:381
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:382
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:383
static bool classof(const Stmt *T)
Definition: ExprObjC.h:402
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:410
void setEncodedTypeSourceInfo(TypeSourceInfo *EncType)
Definition: ExprObjC.h:433
TypeSourceInfo * getEncodedTypeSourceInfo() const
Definition: ExprObjC.h:431
const_child_range children() const
Definition: ExprObjC.h:445
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:437
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:426
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:427
static bool classof(const Stmt *T)
Definition: ExprObjC.h:449
QualType getEncodedType() const
Definition: ExprObjC.h:429
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:438
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:425
ObjCEncodeExpr(QualType T, TypeSourceInfo *EncodedType, SourceLocation at, SourceLocation rp)
Definition: ExprObjC.h:415
SourceLocation getAtLoc() const
Definition: ExprObjC.h:424
child_range children()
Definition: ExprObjC.h:441
ObjCEncodeExpr(EmptyShell Empty)
Definition: ExprObjC.h:422
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1575
const Expr * getSubExpr() const
Definition: ExprObjC.h:1599
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1615
static bool classof(const Stmt *s)
Definition: ExprObjC.h:1623
bool shouldCopy() const
shouldCopy - True if we should do the 'copy' part of the copy-restore.
Definition: ExprObjC.h:1603
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprObjC.h:1619
ObjCIndirectCopyRestoreExpr(Expr *operand, QualType type, bool shouldCopy)
Definition: ExprObjC.h:1591
const_child_range children() const
Definition: ExprObjC.h:1607
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1612
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
Definition: ExprObjC.h:1491
SourceLocation getIsaMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
Definition: ExprObjC.h:1523
ObjCIsaExpr(EmptyShell Empty)
Build an empty expression.
Definition: ExprObjC.h:1513
SourceLocation getOpLoc() const
Definition: ExprObjC.h:1526
void setIsaMemberLoc(SourceLocation L)
Definition: ExprObjC.h:1524
Expr * getBase() const
Definition: ExprObjC.h:1516
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1548
SourceLocation getBaseLocEnd() const LLVM_READONLY
Definition: ExprObjC.h:1533
bool isArrow() const
Definition: ExprObjC.h:1518
child_range children()
Definition: ExprObjC.h:1542
void setBase(Expr *E)
Definition: ExprObjC.h:1515
void setArrow(bool A)
Definition: ExprObjC.h:1519
void setOpLoc(SourceLocation L)
Definition: ExprObjC.h:1527
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprObjC.h:1539
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1537
const_child_range children() const
Definition: ExprObjC.h:1544
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1529
ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc, QualType ty)
Definition: ExprObjC.h:1505
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1951
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:549
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:595
void setIsArrow(bool A)
Definition: ExprObjC.h:589
void setBase(Expr *base)
Definition: ExprObjC.h:585
SourceLocation getLocation() const
Definition: ExprObjC.h:592
SourceLocation getOpLoc() const
Definition: ExprObjC.h:600
void setDecl(ObjCIvarDecl *d)
Definition: ExprObjC.h:581
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:579
ObjCIvarRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:576
bool isArrow() const
Definition: ExprObjC.h:587
bool isFreeIvar() const
Definition: ExprObjC.h:588
void setIsFreeIvar(bool A)
Definition: ExprObjC.h:590
void setOpLoc(SourceLocation L)
Definition: ExprObjC.h:601
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:598
const_child_range children() const
Definition: ExprObjC.h:606
const ObjCIvarDecl * getDecl() const
Definition: ExprObjC.h:580
const Expr * getBase() const
Definition: ExprObjC.h:583
child_range children()
Definition: ExprObjC.h:604
void setLocation(SourceLocation L)
Definition: ExprObjC.h:593
static bool classof(const Stmt *T)
Definition: ExprObjC.h:610
ObjCIvarRefExpr(ObjCIvarDecl *d, QualType t, SourceLocation l, SourceLocation oploc, Expr *base, bool arrow=false, bool freeIvar=false)
Definition: ExprObjC.h:566
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:945
const Expr * getArg(unsigned Arg) const
Definition: ExprObjC.h:1399
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: ExprObjC.h:1395
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:1230
llvm::iterator_range< const_arg_iterator > arguments() const
Definition: ExprObjC.h:1466
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:1370
Expr ** getArgs()
Retrieve the arguments to this message, not including the receiver.
Definition: ExprObjC.h:1386
bool isDelegateInitCall() const
isDelegateInitCall - Answers whether this message send has been tagged as a "delegate init call",...
Definition: ExprObjC.h:1413
ObjCMethodDecl * getMethodDecl()
Definition: ExprObjC.h:1363
void setClassReceiver(TypeSourceInfo *TSInfo)
Definition: ExprObjC.h:1294
void setInstanceReceiver(Expr *rec)
Turn this message send into an instance message that computes the receiver object with the given expr...
Definition: ExprObjC.h:1272
const_arg_iterator arg_end() const
Definition: ExprObjC.h:1480
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:1451
void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper)
Definition: ExprObjC.h:1343
SourceLocation getLeftLoc() const
Definition: ExprObjC.h:1416
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1260
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:1301
ObjCMethodFamily getMethodFamily() const
Definition: ExprObjC.h:1375
Selector getSelector() const
Definition: ExprObjC.cpp:293
ReceiverKind
The kind of receiver this message is sending to.
Definition: ExprObjC.h:948
@ SuperInstance
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:959
@ Instance
The receiver is an object instance.
Definition: ExprObjC.h:953
@ SuperClass
The receiver is a superclass.
Definition: ExprObjC.h:956
@ Class
The receiver is a class.
Definition: ExprObjC.h:950
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:1288
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1279
void setDelegateInitCall(bool isDelegate)
Definition: ExprObjC.h:1414
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
Definition: ExprObjC.h:1248
llvm::iterator_range< arg_iterator > arguments()
Definition: ExprObjC.h:1462
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:1336
const ObjCMethodDecl * getMethodDecl() const
Definition: ExprObjC.h:1356
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:1254
const Expr * getInstanceReceiver() const
Definition: ExprObjC.h:1266
unsigned getNumSelectorLocs() const
Definition: ExprObjC.h:1437
const Expr *const * getArgs() const
Definition: ExprObjC.h:1389
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1234
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:1452
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:1425
SourceLocation getSelectorStartLoc() const
Definition: ExprObjC.h:1419
arg_iterator arg_begin()
Definition: ExprObjC.h:1470
static bool classof(const Stmt *T)
Definition: ExprObjC.h:1484
void setSourceRange(SourceRange R)
Definition: ExprObjC.h:1446
SourceLocation getRightLoc() const
Definition: ExprObjC.h:1417
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver.
Definition: ExprObjC.h:1382
void setSelector(Selector S)
Definition: ExprObjC.h:1351
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
Definition: ExprObjC.h:1405
arg_iterator arg_end()
Definition: ExprObjC.h:1472
const_arg_iterator arg_begin() const
Definition: ExprObjC.h:1476
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
Selector getSelector() const
Definition: DeclObjC.h:327
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:730
Selector getSetterName() const
Definition: DeclObjC.h:892
Selector getGetterName() const
Definition: DeclObjC.h:884
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:617
bool isMessagingGetter() const
True if the property reference will result in a message to the getter.
Definition: ExprObjC.h:736
child_range children()
Definition: ExprObjC.h:789
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:706
Selector getSetterSelector() const
Definition: ExprObjC.h:727
bool isMessagingSetter() const
True if the property reference will result in a message to the setter.
Definition: ExprObjC.h:743
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:711
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, SourceLocation ReceiverLoc, ObjCInterfaceDecl *Receiver)
Definition: ExprObjC.h:689
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, Expr *Base)
Definition: ExprObjC.h:668
void setIsMessagingSetter(bool val=true)
Definition: ExprObjC.h:751
SourceLocation getReceiverLocation() const
Definition: ExprObjC.h:764
const Expr * getBase() const
Definition: ExprObjC.h:755
const_child_range children() const
Definition: ExprObjC.h:797
static bool classof(const Stmt *T)
Definition: ExprObjC.h:802
bool isObjectReceiver() const
Definition: ExprObjC.h:774
bool isExplicitProperty() const
Definition: ExprObjC.h:704
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:781
void setIsMessagingGetter(bool val=true)
Definition: ExprObjC.h:747
QualType getSuperReceiverType() const
Definition: ExprObjC.h:766
bool isImplicitProperty() const
Definition: ExprObjC.h:703
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:786
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:716
ObjCInterfaceDecl * getClassReceiver() const
Definition: ExprObjC.h:770
SourceLocation getLocation() const
Definition: ExprObjC.h:762
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, Expr *base)
Definition: ExprObjC.h:651
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, QualType T, ExprValueKind VK, ExprObjectKind OK, SourceLocation IdLoc, SourceLocation SuperLoc, QualType SuperTy)
Definition: ExprObjC.h:678
Selector getGetterSelector() const
Definition: ExprObjC.h:721
ObjCPropertyRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:700
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:659
bool isClassReceiver() const
Definition: ExprObjC.h:776
bool isSuperReceiver() const
Definition: ExprObjC.h:775
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:505
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:531
ObjCProtocolDecl * getProtocol() const
Definition: ExprObjC.h:522
ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, SourceLocation at, SourceLocation protoLoc, SourceLocation rp)
Definition: ExprObjC.h:513
SourceLocation getProtocolIdLoc() const
Definition: ExprObjC.h:525
const_child_range children() const
Definition: ExprObjC.h:539
void setProtocol(ObjCProtocolDecl *P)
Definition: ExprObjC.h:523
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:529
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:528
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:527
static bool classof(const Stmt *T)
Definition: ExprObjC.h:543
SourceLocation getAtLoc() const
Definition: ExprObjC.h:526
child_range children()
Definition: ExprObjC.h:535
ObjCProtocolExpr(EmptyShell Empty)
Definition: ExprObjC.h:519
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:532
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:455
static bool classof(const Stmt *T)
Definition: ExprObjC.h:492
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:477
void setSelector(Selector S)
Definition: ExprObjC.h:470
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: ExprObjC.h:481
ObjCSelectorExpr(EmptyShell Empty)
Definition: ExprObjC.h:466
ObjCSelectorExpr(QualType T, Selector selInfo, SourceLocation at, SourceLocation rp)
Definition: ExprObjC.h:460
child_range children()
Definition: ExprObjC.h:484
void setAtLoc(SourceLocation L)
Definition: ExprObjC.h:474
SourceLocation getRParenLoc() const
Definition: ExprObjC.h:473
const_child_range children() const
Definition: ExprObjC.h:488
Selector getSelector() const
Definition: ExprObjC.h:469
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:478
void setRParenLoc(SourceLocation L)
Definition: ExprObjC.h:475
SourceLocation getAtLoc() const
Definition: ExprObjC.h:472
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:844
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprObjC.h:877
Expr * getKeyExpr() const
Definition: ExprObjC.h:886
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprObjC.h:881
void setRBracket(SourceLocation RB)
Definition: ExprObjC.h:875
bool isArraySubscriptRefExpr() const
Definition: ExprObjC.h:897
ObjCSubscriptRefExpr(EmptyShell Empty)
Definition: ExprObjC.h:871
child_range children()
Definition: ExprObjC.h:901
ObjCSubscriptRefExpr(Expr *base, Expr *key, QualType T, ExprValueKind VK, ExprObjectKind OK, ObjCMethodDecl *getMethod, ObjCMethodDecl *setMethod, SourceLocation RB)
Definition: ExprObjC.h:861
void setKeyExpr(Stmt *S)
Definition: ExprObjC.h:887
static bool classof(const Stmt *T)
Definition: ExprObjC.h:909
void setBaseExpr(Stmt *S)
Definition: ExprObjC.h:884
Expr * getBaseExpr() const
Definition: ExprObjC.h:883
const_child_range children() const
Definition: ExprObjC.h:905
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:889
SourceLocation getRBracket() const
Definition: ExprObjC.h:874
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:893
A (possibly-)qualified type.
Definition: Type.h:941
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:990
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:84
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:350
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
Definition: Stmt.h:1449
ConstCastIterator< Expr > ConstExprIterator
Definition: Stmt.h:1337
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:1452
ConstStmtIterator const_child_iterator
Definition: Stmt.h:1450
ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits
Definition: Stmt.h:1275
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:338
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1453
CastIterator< Expr > ExprIterator
Definition: Stmt.h:1336
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1778
A container of type source information.
Definition: Type.h:7726
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:7737
The base class of the type hierarchy.
Definition: Type.h:1829
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
Definition: Type.h:8313
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Definition: Type.h:8439
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
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:149
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition: Specifiers.h:151
@ OK_BitField
A bitfield object is a bitfield on a C or C++ record.
Definition: Specifiers.h:154
ExprDependence computeDependence(FullExpr *E)
ObjCMethodFamily
A family of Objective-C methods.
@ 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:132
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:135
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:139
const FunctionProtoType * T
__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:25
#define false
Definition: stdbool.h:26
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:1321
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition: Stmt.h:1303