File indexing completed on 2026-05-10 08:36:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CLANG_AST_EXPROBJC_H
0014 #define LLVM_CLANG_AST_EXPROBJC_H
0015
0016 #include "clang/AST/ComputeDependence.h"
0017 #include "clang/AST/Decl.h"
0018 #include "clang/AST/DeclObjC.h"
0019 #include "clang/AST/DependenceFlags.h"
0020 #include "clang/AST/Expr.h"
0021 #include "clang/AST/OperationKinds.h"
0022 #include "clang/AST/SelectorLocationsKind.h"
0023 #include "clang/AST/Stmt.h"
0024 #include "clang/AST/Type.h"
0025 #include "clang/Basic/IdentifierTable.h"
0026 #include "clang/Basic/LLVM.h"
0027 #include "clang/Basic/SourceLocation.h"
0028 #include "clang/Basic/Specifiers.h"
0029 #include "llvm/ADT/ArrayRef.h"
0030 #include "llvm/ADT/PointerIntPair.h"
0031 #include "llvm/ADT/PointerUnion.h"
0032 #include "llvm/ADT/StringRef.h"
0033 #include "llvm/ADT/iterator_range.h"
0034 #include "llvm/Support/Casting.h"
0035 #include "llvm/Support/Compiler.h"
0036 #include "llvm/Support/TrailingObjects.h"
0037 #include "llvm/Support/VersionTuple.h"
0038 #include "llvm/Support/type_traits.h"
0039 #include <cassert>
0040 #include <cstddef>
0041 #include <cstdint>
0042 #include <optional>
0043
0044 namespace clang {
0045
0046 class ASTContext;
0047 class CXXBaseSpecifier;
0048
0049
0050
0051 class ObjCStringLiteral : public Expr {
0052 Stmt *String;
0053 SourceLocation AtLoc;
0054
0055 public:
0056 ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
0057 : Expr(ObjCStringLiteralClass, T, VK_PRValue, OK_Ordinary), String(SL),
0058 AtLoc(L) {
0059 setDependence(ExprDependence::None);
0060 }
0061 explicit ObjCStringLiteral(EmptyShell Empty)
0062 : Expr(ObjCStringLiteralClass, Empty) {}
0063
0064 StringLiteral *getString() { return cast<StringLiteral>(String); }
0065 const StringLiteral *getString() const { return cast<StringLiteral>(String); }
0066 void setString(StringLiteral *S) { String = S; }
0067
0068 SourceLocation getAtLoc() const { return AtLoc; }
0069 void setAtLoc(SourceLocation L) { AtLoc = L; }
0070
0071 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
0072 SourceLocation getEndLoc() const LLVM_READONLY { return String->getEndLoc(); }
0073
0074
0075 child_range children() { return child_range(&String, &String+1); }
0076
0077 const_child_range children() const {
0078 return const_child_range(&String, &String + 1);
0079 }
0080
0081 static bool classof(const Stmt *T) {
0082 return T->getStmtClass() == ObjCStringLiteralClass;
0083 }
0084 };
0085
0086
0087 class ObjCBoolLiteralExpr : public Expr {
0088 bool Value;
0089 SourceLocation Loc;
0090
0091 public:
0092 ObjCBoolLiteralExpr(bool val, QualType Ty, SourceLocation l)
0093 : Expr(ObjCBoolLiteralExprClass, Ty, VK_PRValue, OK_Ordinary), Value(val),
0094 Loc(l) {
0095 setDependence(ExprDependence::None);
0096 }
0097 explicit ObjCBoolLiteralExpr(EmptyShell Empty)
0098 : Expr(ObjCBoolLiteralExprClass, Empty) {}
0099
0100 bool getValue() const { return Value; }
0101 void setValue(bool V) { Value = V; }
0102
0103 SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
0104 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
0105
0106 SourceLocation getLocation() const { return Loc; }
0107 void setLocation(SourceLocation L) { Loc = L; }
0108
0109
0110 child_range children() {
0111 return child_range(child_iterator(), child_iterator());
0112 }
0113
0114 const_child_range children() const {
0115 return const_child_range(const_child_iterator(), const_child_iterator());
0116 }
0117
0118 static bool classof(const Stmt *T) {
0119 return T->getStmtClass() == ObjCBoolLiteralExprClass;
0120 }
0121 };
0122
0123
0124
0125
0126
0127 class ObjCBoxedExpr : public Expr {
0128 Stmt *SubExpr;
0129 ObjCMethodDecl *BoxingMethod;
0130 SourceRange Range;
0131
0132 public:
0133 friend class ASTStmtReader;
0134
0135 ObjCBoxedExpr(Expr *E, QualType T, ObjCMethodDecl *method, SourceRange R)
0136 : Expr(ObjCBoxedExprClass, T, VK_PRValue, OK_Ordinary), SubExpr(E),
0137 BoxingMethod(method), Range(R) {
0138 setDependence(computeDependence(this));
0139 }
0140 explicit ObjCBoxedExpr(EmptyShell Empty)
0141 : Expr(ObjCBoxedExprClass, Empty) {}
0142
0143 Expr *getSubExpr() { return cast<Expr>(SubExpr); }
0144 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
0145
0146 ObjCMethodDecl *getBoxingMethod() const {
0147 return BoxingMethod;
0148 }
0149
0150
0151
0152 bool isExpressibleAsConstantInitializer() const {
0153 return !BoxingMethod && SubExpr;
0154 }
0155
0156 SourceLocation getAtLoc() const { return Range.getBegin(); }
0157
0158 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
0159 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
0160
0161 SourceRange getSourceRange() const LLVM_READONLY {
0162 return Range;
0163 }
0164
0165
0166 child_range children() { return child_range(&SubExpr, &SubExpr+1); }
0167
0168 const_child_range children() const {
0169 return const_child_range(&SubExpr, &SubExpr + 1);
0170 }
0171
0172 using const_arg_iterator = ConstExprIterator;
0173
0174 const_arg_iterator arg_begin() const {
0175 return reinterpret_cast<Stmt const * const*>(&SubExpr);
0176 }
0177
0178 const_arg_iterator arg_end() const {
0179 return reinterpret_cast<Stmt const * const*>(&SubExpr + 1);
0180 }
0181
0182 static bool classof(const Stmt *T) {
0183 return T->getStmtClass() == ObjCBoxedExprClass;
0184 }
0185 };
0186
0187
0188
0189 class ObjCArrayLiteral final
0190 : public Expr,
0191 private llvm::TrailingObjects<ObjCArrayLiteral, Expr *> {
0192 unsigned NumElements;
0193 SourceRange Range;
0194 ObjCMethodDecl *ArrayWithObjectsMethod;
0195
0196 ObjCArrayLiteral(ArrayRef<Expr *> Elements,
0197 QualType T, ObjCMethodDecl * Method,
0198 SourceRange SR);
0199
0200 explicit ObjCArrayLiteral(EmptyShell Empty, unsigned NumElements)
0201 : Expr(ObjCArrayLiteralClass, Empty), NumElements(NumElements) {}
0202
0203 public:
0204 friend class ASTStmtReader;
0205 friend TrailingObjects;
0206
0207 static ObjCArrayLiteral *Create(const ASTContext &C,
0208 ArrayRef<Expr *> Elements,
0209 QualType T, ObjCMethodDecl * Method,
0210 SourceRange SR);
0211
0212 static ObjCArrayLiteral *CreateEmpty(const ASTContext &C,
0213 unsigned NumElements);
0214
0215 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
0216 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
0217 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
0218
0219
0220 Expr **getElements() { return getTrailingObjects<Expr *>(); }
0221
0222
0223 const Expr * const *getElements() const {
0224 return getTrailingObjects<Expr *>();
0225 }
0226
0227
0228 unsigned getNumElements() const { return NumElements; }
0229
0230
0231 Expr *getElement(unsigned Index) {
0232 assert((Index < NumElements) && "Arg access out of range!");
0233 return getElements()[Index];
0234 }
0235 const Expr *getElement(unsigned Index) const {
0236 assert((Index < NumElements) && "Arg access out of range!");
0237 return getElements()[Index];
0238 }
0239
0240 ObjCMethodDecl *getArrayWithObjectsMethod() const {
0241 return ArrayWithObjectsMethod;
0242 }
0243
0244
0245 child_range children() {
0246 return child_range(reinterpret_cast<Stmt **>(getElements()),
0247 reinterpret_cast<Stmt **>(getElements()) + NumElements);
0248 }
0249
0250 const_child_range children() const {
0251 auto Children = const_cast<ObjCArrayLiteral *>(this)->children();
0252 return const_child_range(Children.begin(), Children.end());
0253 }
0254
0255 static bool classof(const Stmt *T) {
0256 return T->getStmtClass() == ObjCArrayLiteralClass;
0257 }
0258 };
0259
0260
0261
0262 struct ObjCDictionaryElement {
0263
0264 Expr *Key;
0265
0266
0267 Expr *Value;
0268
0269
0270 SourceLocation EllipsisLoc;
0271
0272
0273
0274 std::optional<unsigned> NumExpansions;
0275
0276
0277 bool isPackExpansion() const { return EllipsisLoc.isValid(); }
0278 };
0279
0280 }
0281
0282 namespace clang {
0283
0284
0285 struct ObjCDictionaryLiteral_KeyValuePair {
0286 Expr *Key;
0287 Expr *Value;
0288 };
0289
0290
0291
0292
0293 struct ObjCDictionaryLiteral_ExpansionData {
0294
0295
0296 SourceLocation EllipsisLoc;
0297
0298
0299
0300 unsigned NumExpansionsPlusOne;
0301 };
0302
0303
0304
0305 class ObjCDictionaryLiteral final
0306 : public Expr,
0307 private llvm::TrailingObjects<ObjCDictionaryLiteral,
0308 ObjCDictionaryLiteral_KeyValuePair,
0309 ObjCDictionaryLiteral_ExpansionData> {
0310
0311 unsigned NumElements : 31;
0312
0313
0314
0315
0316
0317
0318
0319
0320 LLVM_PREFERRED_TYPE(bool)
0321 unsigned HasPackExpansions : 1;
0322
0323 SourceRange Range;
0324 ObjCMethodDecl *DictWithObjectsMethod;
0325
0326 using KeyValuePair = ObjCDictionaryLiteral_KeyValuePair;
0327 using ExpansionData = ObjCDictionaryLiteral_ExpansionData;
0328
0329 ObjCDictionaryLiteral(ArrayRef<ObjCDictionaryElement> VK,
0330 bool HasPackExpansions,
0331 QualType T, ObjCMethodDecl *method,
0332 SourceRange SR);
0333
0334 explicit ObjCDictionaryLiteral(EmptyShell Empty, unsigned NumElements,
0335 bool HasPackExpansions)
0336 : Expr(ObjCDictionaryLiteralClass, Empty), NumElements(NumElements),
0337 HasPackExpansions(HasPackExpansions) {}
0338
0339 size_t numTrailingObjects(OverloadToken<KeyValuePair>) const {
0340 return NumElements;
0341 }
0342
0343 public:
0344 friend class ASTStmtReader;
0345 friend class ASTStmtWriter;
0346 friend TrailingObjects;
0347
0348 static ObjCDictionaryLiteral *Create(const ASTContext &C,
0349 ArrayRef<ObjCDictionaryElement> VK,
0350 bool HasPackExpansions,
0351 QualType T, ObjCMethodDecl *method,
0352 SourceRange SR);
0353
0354 static ObjCDictionaryLiteral *CreateEmpty(const ASTContext &C,
0355 unsigned NumElements,
0356 bool HasPackExpansions);
0357
0358
0359
0360 unsigned getNumElements() const { return NumElements; }
0361
0362 ObjCDictionaryElement getKeyValueElement(unsigned Index) const {
0363 assert((Index < NumElements) && "Arg access out of range!");
0364 const KeyValuePair &KV = getTrailingObjects<KeyValuePair>()[Index];
0365 ObjCDictionaryElement Result = {KV.Key, KV.Value, SourceLocation(),
0366 std::nullopt};
0367 if (HasPackExpansions) {
0368 const ExpansionData &Expansion =
0369 getTrailingObjects<ExpansionData>()[Index];
0370 Result.EllipsisLoc = Expansion.EllipsisLoc;
0371 if (Expansion.NumExpansionsPlusOne > 0)
0372 Result.NumExpansions = Expansion.NumExpansionsPlusOne - 1;
0373 }
0374 return Result;
0375 }
0376
0377 ObjCMethodDecl *getDictWithObjectsMethod() const {
0378 return DictWithObjectsMethod;
0379 }
0380
0381 SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
0382 SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
0383 SourceRange getSourceRange() const LLVM_READONLY { return Range; }
0384
0385
0386 child_range children() {
0387
0388
0389 static_assert(sizeof(KeyValuePair) == sizeof(Stmt *) * 2,
0390 "KeyValuePair is expected size");
0391 return child_range(
0392 reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()),
0393 reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()) +
0394 NumElements * 2);
0395 }
0396
0397 const_child_range children() const {
0398 auto Children = const_cast<ObjCDictionaryLiteral *>(this)->children();
0399 return const_child_range(Children.begin(), Children.end());
0400 }
0401
0402 static bool classof(const Stmt *T) {
0403 return T->getStmtClass() == ObjCDictionaryLiteralClass;
0404 }
0405 };
0406
0407
0408
0409
0410 class ObjCEncodeExpr : public Expr {
0411 TypeSourceInfo *EncodedType;
0412 SourceLocation AtLoc, RParenLoc;
0413
0414 public:
0415 ObjCEncodeExpr(QualType T, TypeSourceInfo *EncodedType, SourceLocation at,
0416 SourceLocation rp)
0417 : Expr(ObjCEncodeExprClass, T, VK_LValue, OK_Ordinary),
0418 EncodedType(EncodedType), AtLoc(at), RParenLoc(rp) {
0419 setDependence(computeDependence(this));
0420 }
0421
0422 explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){}
0423
0424 SourceLocation getAtLoc() const { return AtLoc; }
0425 void setAtLoc(SourceLocation L) { AtLoc = L; }
0426 SourceLocation getRParenLoc() const { return RParenLoc; }
0427 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
0428
0429 QualType getEncodedType() const { return EncodedType->getType(); }
0430
0431 TypeSourceInfo *getEncodedTypeSourceInfo() const { return EncodedType; }
0432
0433 void setEncodedTypeSourceInfo(TypeSourceInfo *EncType) {
0434 EncodedType = EncType;
0435 }
0436
0437 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
0438 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
0439
0440
0441 child_range children() {
0442 return child_range(child_iterator(), child_iterator());
0443 }
0444
0445 const_child_range children() const {
0446 return const_child_range(const_child_iterator(), const_child_iterator());
0447 }
0448
0449 static bool classof(const Stmt *T) {
0450 return T->getStmtClass() == ObjCEncodeExprClass;
0451 }
0452 };
0453
0454
0455 class ObjCSelectorExpr : public Expr {
0456 Selector SelName;
0457 SourceLocation AtLoc, RParenLoc;
0458
0459 public:
0460 ObjCSelectorExpr(QualType T, Selector selInfo, SourceLocation at,
0461 SourceLocation rp)
0462 : Expr(ObjCSelectorExprClass, T, VK_PRValue, OK_Ordinary),
0463 SelName(selInfo), AtLoc(at), RParenLoc(rp) {
0464 setDependence(ExprDependence::None);
0465 }
0466 explicit ObjCSelectorExpr(EmptyShell Empty)
0467 : Expr(ObjCSelectorExprClass, Empty) {}
0468
0469 Selector getSelector() const { return SelName; }
0470 void setSelector(Selector S) { SelName = S; }
0471
0472 SourceLocation getAtLoc() const { return AtLoc; }
0473 SourceLocation getRParenLoc() const { return RParenLoc; }
0474 void setAtLoc(SourceLocation L) { AtLoc = L; }
0475 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
0476
0477 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
0478 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
0479
0480
0481 unsigned getNumArgs() const { return SelName.getNumArgs(); }
0482
0483
0484 child_range children() {
0485 return child_range(child_iterator(), child_iterator());
0486 }
0487
0488 const_child_range children() const {
0489 return const_child_range(const_child_iterator(), const_child_iterator());
0490 }
0491
0492 static bool classof(const Stmt *T) {
0493 return T->getStmtClass() == ObjCSelectorExprClass;
0494 }
0495 };
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505 class ObjCProtocolExpr : public Expr {
0506 ObjCProtocolDecl *TheProtocol;
0507 SourceLocation AtLoc, ProtoLoc, RParenLoc;
0508
0509 public:
0510 friend class ASTStmtReader;
0511 friend class ASTStmtWriter;
0512
0513 ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, SourceLocation at,
0514 SourceLocation protoLoc, SourceLocation rp)
0515 : Expr(ObjCProtocolExprClass, T, VK_PRValue, OK_Ordinary),
0516 TheProtocol(protocol), AtLoc(at), ProtoLoc(protoLoc), RParenLoc(rp) {
0517 setDependence(ExprDependence::None);
0518 }
0519 explicit ObjCProtocolExpr(EmptyShell Empty)
0520 : Expr(ObjCProtocolExprClass, Empty) {}
0521
0522 ObjCProtocolDecl *getProtocol() const { return TheProtocol; }
0523 void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; }
0524
0525 SourceLocation getProtocolIdLoc() const { return ProtoLoc; }
0526 SourceLocation getAtLoc() const { return AtLoc; }
0527 SourceLocation getRParenLoc() const { return RParenLoc; }
0528 void setAtLoc(SourceLocation L) { AtLoc = L; }
0529 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
0530
0531 SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; }
0532 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
0533
0534
0535 child_range children() {
0536 return child_range(child_iterator(), child_iterator());
0537 }
0538
0539 const_child_range children() const {
0540 return const_child_range(const_child_iterator(), const_child_iterator());
0541 }
0542
0543 static bool classof(const Stmt *T) {
0544 return T->getStmtClass() == ObjCProtocolExprClass;
0545 }
0546 };
0547
0548
0549 class ObjCIvarRefExpr : public Expr {
0550 ObjCIvarDecl *D;
0551 Stmt *Base;
0552 SourceLocation Loc;
0553
0554
0555 SourceLocation OpLoc;
0556
0557
0558 LLVM_PREFERRED_TYPE(bool)
0559 bool IsArrow : 1;
0560
0561
0562 LLVM_PREFERRED_TYPE(bool)
0563 bool IsFreeIvar : 1;
0564
0565 public:
0566 ObjCIvarRefExpr(ObjCIvarDecl *d, QualType t, SourceLocation l,
0567 SourceLocation oploc, Expr *base, bool arrow = false,
0568 bool freeIvar = false)
0569 : Expr(ObjCIvarRefExprClass, t, VK_LValue,
0570 d->isBitField() ? OK_BitField : OK_Ordinary),
0571 D(d), Base(base), Loc(l), OpLoc(oploc), IsArrow(arrow),
0572 IsFreeIvar(freeIvar) {
0573 setDependence(computeDependence(this));
0574 }
0575
0576 explicit ObjCIvarRefExpr(EmptyShell Empty)
0577 : Expr(ObjCIvarRefExprClass, Empty) {}
0578
0579 ObjCIvarDecl *getDecl() { return D; }
0580 const ObjCIvarDecl *getDecl() const { return D; }
0581 void setDecl(ObjCIvarDecl *d) { D = d; }
0582
0583 const Expr *getBase() const { return cast<Expr>(Base); }
0584 Expr *getBase() { return cast<Expr>(Base); }
0585 void setBase(Expr * base) { Base = base; }
0586
0587 bool isArrow() const { return IsArrow; }
0588 bool isFreeIvar() const { return IsFreeIvar; }
0589 void setIsArrow(bool A) { IsArrow = A; }
0590 void setIsFreeIvar(bool A) { IsFreeIvar = A; }
0591
0592 SourceLocation getLocation() const { return Loc; }
0593 void setLocation(SourceLocation L) { Loc = L; }
0594
0595 SourceLocation getBeginLoc() const LLVM_READONLY {
0596 return isFreeIvar() ? Loc : getBase()->getBeginLoc();
0597 }
0598 SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
0599
0600 SourceLocation getOpLoc() const { return OpLoc; }
0601 void setOpLoc(SourceLocation L) { OpLoc = L; }
0602
0603
0604 child_range children() { return child_range(&Base, &Base+1); }
0605
0606 const_child_range children() const {
0607 return const_child_range(&Base, &Base + 1);
0608 }
0609
0610 static bool classof(const Stmt *T) {
0611 return T->getStmtClass() == ObjCIvarRefExprClass;
0612 }
0613 };
0614
0615
0616
0617 class ObjCPropertyRefExpr : public Expr {
0618 private:
0619
0620
0621
0622
0623 llvm::PointerIntPair<NamedDecl *, 1, bool> PropertyOrGetter;
0624
0625
0626
0627
0628 enum MethodRefFlags {
0629 MethodRef_None = 0,
0630 MethodRef_Getter = 0x1,
0631 MethodRef_Setter = 0x2
0632 };
0633
0634
0635 llvm::PointerIntPair<ObjCMethodDecl *, 2, unsigned> SetterAndMethodRefFlags;
0636
0637
0638
0639
0640
0641
0642 SourceLocation IdLoc;
0643
0644
0645
0646
0647 SourceLocation ReceiverLoc;
0648 llvm::PointerUnion<Stmt *, const Type *, ObjCInterfaceDecl *> Receiver;
0649
0650 public:
0651 ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK,
0652 ExprObjectKind OK, SourceLocation l, Expr *base)
0653 : Expr(ObjCPropertyRefExprClass, t, VK, OK), PropertyOrGetter(PD, false),
0654 IdLoc(l), Receiver(base) {
0655 assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
0656 setDependence(computeDependence(this));
0657 }
0658
0659 ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, ExprValueKind VK,
0660 ExprObjectKind OK, SourceLocation l, SourceLocation sl,
0661 QualType st)
0662 : Expr(ObjCPropertyRefExprClass, t, VK, OK), PropertyOrGetter(PD, false),
0663 IdLoc(l), ReceiverLoc(sl), Receiver(st.getTypePtr()) {
0664 assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
0665 setDependence(computeDependence(this));
0666 }
0667
0668 ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
0669 QualType T, ExprValueKind VK, ExprObjectKind OK,
0670 SourceLocation IdLoc, Expr *Base)
0671 : Expr(ObjCPropertyRefExprClass, T, VK, OK),
0672 PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
0673 IdLoc(IdLoc), Receiver(Base) {
0674 assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
0675 setDependence(computeDependence(this));
0676 }
0677
0678 ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
0679 QualType T, ExprValueKind VK, ExprObjectKind OK,
0680 SourceLocation IdLoc, SourceLocation SuperLoc,
0681 QualType SuperTy)
0682 : Expr(ObjCPropertyRefExprClass, T, VK, OK),
0683 PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
0684 IdLoc(IdLoc), ReceiverLoc(SuperLoc), Receiver(SuperTy.getTypePtr()) {
0685 assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
0686 setDependence(computeDependence(this));
0687 }
0688
0689 ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
0690 QualType T, ExprValueKind VK, ExprObjectKind OK,
0691 SourceLocation IdLoc, SourceLocation ReceiverLoc,
0692 ObjCInterfaceDecl *Receiver)
0693 : Expr(ObjCPropertyRefExprClass, T, VK, OK),
0694 PropertyOrGetter(Getter, true), SetterAndMethodRefFlags(Setter, 0),
0695 IdLoc(IdLoc), ReceiverLoc(ReceiverLoc), Receiver(Receiver) {
0696 assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
0697 setDependence(computeDependence(this));
0698 }
0699
0700 explicit ObjCPropertyRefExpr(EmptyShell Empty)
0701 : Expr(ObjCPropertyRefExprClass, Empty) {}
0702
0703 bool isImplicitProperty() const { return PropertyOrGetter.getInt(); }
0704 bool isExplicitProperty() const { return !PropertyOrGetter.getInt(); }
0705
0706 ObjCPropertyDecl *getExplicitProperty() const {
0707 assert(!isImplicitProperty());
0708 return cast<ObjCPropertyDecl>(PropertyOrGetter.getPointer());
0709 }
0710
0711 ObjCMethodDecl *getImplicitPropertyGetter() const {
0712 assert(isImplicitProperty());
0713 return cast_or_null<ObjCMethodDecl>(PropertyOrGetter.getPointer());
0714 }
0715
0716 ObjCMethodDecl *getImplicitPropertySetter() const {
0717 assert(isImplicitProperty());
0718 return SetterAndMethodRefFlags.getPointer();
0719 }
0720
0721 Selector getGetterSelector() const {
0722 if (isImplicitProperty())
0723 return getImplicitPropertyGetter()->getSelector();
0724 return getExplicitProperty()->getGetterName();
0725 }
0726
0727 Selector getSetterSelector() const {
0728 if (isImplicitProperty())
0729 return getImplicitPropertySetter()->getSelector();
0730 return getExplicitProperty()->getSetterName();
0731 }
0732
0733
0734
0735
0736 bool isMessagingGetter() const {
0737 return SetterAndMethodRefFlags.getInt() & MethodRef_Getter;
0738 }
0739
0740
0741
0742
0743 bool isMessagingSetter() const {
0744 return SetterAndMethodRefFlags.getInt() & MethodRef_Setter;
0745 }
0746
0747 void setIsMessagingGetter(bool val = true) {
0748 setMethodRefFlag(MethodRef_Getter, val);
0749 }
0750
0751 void setIsMessagingSetter(bool val = true) {
0752 setMethodRefFlag(MethodRef_Setter, val);
0753 }
0754
0755 const Expr *getBase() const { return cast<Expr>(cast<Stmt *>(Receiver)); }
0756 Expr *getBase() { return cast<Expr>(cast<Stmt *>(Receiver)); }
0757
0758 SourceLocation getLocation() const { return IdLoc; }
0759
0760 SourceLocation getReceiverLocation() const { return ReceiverLoc; }
0761
0762 QualType getSuperReceiverType() const {
0763 return QualType(cast<const Type *>(Receiver), 0);
0764 }
0765
0766 ObjCInterfaceDecl *getClassReceiver() const {
0767 return cast<ObjCInterfaceDecl *>(Receiver);
0768 }
0769
0770 bool isObjectReceiver() const { return isa<Stmt *>(Receiver); }
0771 bool isSuperReceiver() const { return isa<const Type *>(Receiver); }
0772 bool isClassReceiver() const { return isa<ObjCInterfaceDecl *>(Receiver); }
0773
0774
0775 QualType getReceiverType(const ASTContext &ctx) const;
0776
0777 SourceLocation getBeginLoc() const LLVM_READONLY {
0778 return isObjectReceiver() ? getBase()->getBeginLoc()
0779 : getReceiverLocation();
0780 }
0781
0782 SourceLocation getEndLoc() const LLVM_READONLY { return IdLoc; }
0783
0784
0785 child_range children() {
0786 if (isa<Stmt *>(Receiver)) {
0787 Stmt **begin = reinterpret_cast<Stmt**>(&Receiver);
0788 return child_range(begin, begin+1);
0789 }
0790 return child_range(child_iterator(), child_iterator());
0791 }
0792
0793 const_child_range children() const {
0794 auto Children = const_cast<ObjCPropertyRefExpr *>(this)->children();
0795 return const_child_range(Children.begin(), Children.end());
0796 }
0797
0798 static bool classof(const Stmt *T) {
0799 return T->getStmtClass() == ObjCPropertyRefExprClass;
0800 }
0801
0802 private:
0803 friend class ASTStmtReader;
0804 friend class ASTStmtWriter;
0805
0806 void setExplicitProperty(ObjCPropertyDecl *D, unsigned methRefFlags) {
0807 PropertyOrGetter.setPointer(D);
0808 PropertyOrGetter.setInt(false);
0809 SetterAndMethodRefFlags.setPointer(nullptr);
0810 SetterAndMethodRefFlags.setInt(methRefFlags);
0811 }
0812
0813 void setImplicitProperty(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
0814 unsigned methRefFlags) {
0815 PropertyOrGetter.setPointer(Getter);
0816 PropertyOrGetter.setInt(true);
0817 SetterAndMethodRefFlags.setPointer(Setter);
0818 SetterAndMethodRefFlags.setInt(methRefFlags);
0819 }
0820
0821 void setBase(Expr *Base) { Receiver = Base; }
0822 void setSuperReceiver(QualType T) { Receiver = T.getTypePtr(); }
0823 void setClassReceiver(ObjCInterfaceDecl *D) { Receiver = D; }
0824
0825 void setLocation(SourceLocation L) { IdLoc = L; }
0826 void setReceiverLocation(SourceLocation Loc) { ReceiverLoc = Loc; }
0827
0828 void setMethodRefFlag(MethodRefFlags flag, bool val) {
0829 unsigned f = SetterAndMethodRefFlags.getInt();
0830 if (val)
0831 f |= flag;
0832 else
0833 f &= ~flag;
0834 SetterAndMethodRefFlags.setInt(f);
0835 }
0836 };
0837
0838
0839
0840 class ObjCSubscriptRefExpr : public Expr {
0841
0842 SourceLocation RBracket;
0843
0844
0845
0846
0847 enum { BASE, KEY, END_EXPR };
0848 Stmt* SubExprs[END_EXPR];
0849
0850 ObjCMethodDecl *GetAtIndexMethodDecl;
0851
0852
0853
0854 ObjCMethodDecl *SetAtIndexMethodDecl;
0855
0856 public:
0857 ObjCSubscriptRefExpr(Expr *base, Expr *key, QualType T, ExprValueKind VK,
0858 ExprObjectKind OK, ObjCMethodDecl *getMethod,
0859 ObjCMethodDecl *setMethod, SourceLocation RB)
0860 : Expr(ObjCSubscriptRefExprClass, T, VK, OK), RBracket(RB),
0861 GetAtIndexMethodDecl(getMethod), SetAtIndexMethodDecl(setMethod) {
0862 SubExprs[BASE] = base;
0863 SubExprs[KEY] = key;
0864 setDependence(computeDependence(this));
0865 }
0866
0867 explicit ObjCSubscriptRefExpr(EmptyShell Empty)
0868 : Expr(ObjCSubscriptRefExprClass, Empty) {}
0869
0870 SourceLocation getRBracket() const { return RBracket; }
0871 void setRBracket(SourceLocation RB) { RBracket = RB; }
0872
0873 SourceLocation getBeginLoc() const LLVM_READONLY {
0874 return SubExprs[BASE]->getBeginLoc();
0875 }
0876
0877 SourceLocation getEndLoc() const LLVM_READONLY { return RBracket; }
0878
0879 Expr *getBaseExpr() const { return cast<Expr>(SubExprs[BASE]); }
0880 void setBaseExpr(Stmt *S) { SubExprs[BASE] = S; }
0881
0882 Expr *getKeyExpr() const { return cast<Expr>(SubExprs[KEY]); }
0883 void setKeyExpr(Stmt *S) { SubExprs[KEY] = S; }
0884
0885 ObjCMethodDecl *getAtIndexMethodDecl() const {
0886 return GetAtIndexMethodDecl;
0887 }
0888
0889 ObjCMethodDecl *setAtIndexMethodDecl() const {
0890 return SetAtIndexMethodDecl;
0891 }
0892
0893 bool isArraySubscriptRefExpr() const {
0894 return getKeyExpr()->getType()->isIntegralOrEnumerationType();
0895 }
0896
0897 child_range children() {
0898 return child_range(SubExprs, SubExprs+END_EXPR);
0899 }
0900
0901 const_child_range children() const {
0902 return const_child_range(SubExprs, SubExprs + END_EXPR);
0903 }
0904
0905 static bool classof(const Stmt *T) {
0906 return T->getStmtClass() == ObjCSubscriptRefExprClass;
0907 }
0908
0909 private:
0910 friend class ASTStmtReader;
0911 };
0912
0913
0914
0915
0916
0917
0918
0919
0920
0921
0922
0923
0924
0925
0926
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939 class ObjCMessageExpr final
0940 : public Expr,
0941 private llvm::TrailingObjects<ObjCMessageExpr, void *, SourceLocation> {
0942 public:
0943
0944 enum ReceiverKind {
0945
0946 Class = 0,
0947
0948
0949 Instance,
0950
0951
0952 SuperClass,
0953
0954
0955 SuperInstance
0956 };
0957
0958 private:
0959
0960
0961
0962 uintptr_t SelectorOrMethod = 0;
0963
0964 enum { NumArgsBitWidth = 16 };
0965
0966
0967
0968 unsigned NumArgs : NumArgsBitWidth;
0969
0970
0971
0972
0973
0974 LLVM_PREFERRED_TYPE(ReceiverKind)
0975 unsigned Kind : 8;
0976
0977
0978
0979
0980
0981
0982 LLVM_PREFERRED_TYPE(bool)
0983 unsigned HasMethod : 1;
0984
0985
0986
0987 LLVM_PREFERRED_TYPE(bool)
0988 unsigned IsDelegateInitCall : 1;
0989
0990
0991
0992 LLVM_PREFERRED_TYPE(bool)
0993 unsigned IsImplicit : 1;
0994
0995
0996
0997 LLVM_PREFERRED_TYPE(SelectorLocationsKind)
0998 unsigned SelLocsKind : 2;
0999
1000
1001
1002 SourceLocation SuperLoc;
1003
1004
1005
1006 SourceLocation LBracLoc, RBracLoc;
1007
1008 ObjCMessageExpr(EmptyShell Empty, unsigned NumArgs)
1009 : Expr(ObjCMessageExprClass, Empty), Kind(0), HasMethod(false),
1010 IsDelegateInitCall(false), IsImplicit(false), SelLocsKind(0) {
1011 setNumArgs(NumArgs);
1012 }
1013
1014 ObjCMessageExpr(QualType T, ExprValueKind VK,
1015 SourceLocation LBracLoc,
1016 SourceLocation SuperLoc,
1017 bool IsInstanceSuper,
1018 QualType SuperType,
1019 Selector Sel,
1020 ArrayRef<SourceLocation> SelLocs,
1021 SelectorLocationsKind SelLocsK,
1022 ObjCMethodDecl *Method,
1023 ArrayRef<Expr *> Args,
1024 SourceLocation RBracLoc,
1025 bool isImplicit);
1026 ObjCMessageExpr(QualType T, ExprValueKind VK,
1027 SourceLocation LBracLoc,
1028 TypeSourceInfo *Receiver,
1029 Selector Sel,
1030 ArrayRef<SourceLocation> SelLocs,
1031 SelectorLocationsKind SelLocsK,
1032 ObjCMethodDecl *Method,
1033 ArrayRef<Expr *> Args,
1034 SourceLocation RBracLoc,
1035 bool isImplicit);
1036 ObjCMessageExpr(QualType T, ExprValueKind VK,
1037 SourceLocation LBracLoc,
1038 Expr *Receiver,
1039 Selector Sel,
1040 ArrayRef<SourceLocation> SelLocs,
1041 SelectorLocationsKind SelLocsK,
1042 ObjCMethodDecl *Method,
1043 ArrayRef<Expr *> Args,
1044 SourceLocation RBracLoc,
1045 bool isImplicit);
1046
1047 size_t numTrailingObjects(OverloadToken<void *>) const { return NumArgs + 1; }
1048
1049 void setNumArgs(unsigned Num) {
1050 assert((Num >> NumArgsBitWidth) == 0 && "Num of args is out of range!");
1051 NumArgs = Num;
1052 }
1053
1054 void initArgsAndSelLocs(ArrayRef<Expr *> Args,
1055 ArrayRef<SourceLocation> SelLocs,
1056 SelectorLocationsKind SelLocsK);
1057
1058
1059 void *getReceiverPointer() const { return *getTrailingObjects<void *>(); }
1060
1061
1062 void setReceiverPointer(void *Value) {
1063 *getTrailingObjects<void *>() = Value;
1064 }
1065
1066 SelectorLocationsKind getSelLocsKind() const {
1067 return (SelectorLocationsKind)SelLocsKind;
1068 }
1069
1070 bool hasStandardSelLocs() const {
1071 return getSelLocsKind() != SelLoc_NonStandard;
1072 }
1073
1074
1075
1076 SourceLocation *getStoredSelLocs() {
1077 return getTrailingObjects<SourceLocation>();
1078 }
1079 const SourceLocation *getStoredSelLocs() const {
1080 return getTrailingObjects<SourceLocation>();
1081 }
1082
1083
1084
1085 unsigned getNumStoredSelLocs() const {
1086 if (hasStandardSelLocs())
1087 return 0;
1088 return getNumSelectorLocs();
1089 }
1090
1091 static ObjCMessageExpr *alloc(const ASTContext &C,
1092 ArrayRef<Expr *> Args,
1093 SourceLocation RBraceLoc,
1094 ArrayRef<SourceLocation> SelLocs,
1095 Selector Sel,
1096 SelectorLocationsKind &SelLocsK);
1097 static ObjCMessageExpr *alloc(const ASTContext &C,
1098 unsigned NumArgs,
1099 unsigned NumStoredSelLocs);
1100
1101 public:
1102 friend class ASTStmtReader;
1103 friend class ASTStmtWriter;
1104 friend TrailingObjects;
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131 static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1132 ExprValueKind VK,
1133 SourceLocation LBracLoc,
1134 SourceLocation SuperLoc,
1135 bool IsInstanceSuper,
1136 QualType SuperType,
1137 Selector Sel,
1138 ArrayRef<SourceLocation> SelLocs,
1139 ObjCMethodDecl *Method,
1140 ArrayRef<Expr *> Args,
1141 SourceLocation RBracLoc,
1142 bool isImplicit);
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167 static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1168 ExprValueKind VK,
1169 SourceLocation LBracLoc,
1170 TypeSourceInfo *Receiver,
1171 Selector Sel,
1172 ArrayRef<SourceLocation> SelLocs,
1173 ObjCMethodDecl *Method,
1174 ArrayRef<Expr *> Args,
1175 SourceLocation RBracLoc,
1176 bool isImplicit);
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201 static ObjCMessageExpr *Create(const ASTContext &Context, QualType T,
1202 ExprValueKind VK,
1203 SourceLocation LBracLoc,
1204 Expr *Receiver,
1205 Selector Sel,
1206 ArrayRef<SourceLocation> SeLocs,
1207 ObjCMethodDecl *Method,
1208 ArrayRef<Expr *> Args,
1209 SourceLocation RBracLoc,
1210 bool isImplicit);
1211
1212
1213
1214
1215
1216
1217
1218
1219 static ObjCMessageExpr *CreateEmpty(const ASTContext &Context,
1220 unsigned NumArgs,
1221 unsigned NumStoredSelLocs);
1222
1223
1224
1225
1226 bool isImplicit() const { return IsImplicit; }
1227
1228
1229
1230 ReceiverKind getReceiverKind() const { return (ReceiverKind)Kind; }
1231
1232
1233
1234
1235
1236
1237 QualType getCallReturnType(ASTContext &Ctx) const;
1238
1239
1240 SourceRange getReceiverRange() const;
1241
1242
1243
1244 bool isInstanceMessage() const {
1245 return getReceiverKind() == Instance || getReceiverKind() == SuperInstance;
1246 }
1247
1248
1249
1250 bool isClassMessage() const {
1251 return getReceiverKind() == Class || getReceiverKind() == SuperClass;
1252 }
1253
1254
1255
1256 Expr *getInstanceReceiver() {
1257 if (getReceiverKind() == Instance)
1258 return static_cast<Expr *>(getReceiverPointer());
1259
1260 return nullptr;
1261 }
1262 const Expr *getInstanceReceiver() const {
1263 return const_cast<ObjCMessageExpr*>(this)->getInstanceReceiver();
1264 }
1265
1266
1267
1268 void setInstanceReceiver(Expr *rec) {
1269 Kind = Instance;
1270 setReceiverPointer(rec);
1271 }
1272
1273
1274
1275 QualType getClassReceiver() const {
1276 if (TypeSourceInfo *TSInfo = getClassReceiverTypeInfo())
1277 return TSInfo->getType();
1278
1279 return {};
1280 }
1281
1282
1283
1284 TypeSourceInfo *getClassReceiverTypeInfo() const {
1285 if (getReceiverKind() == Class)
1286 return reinterpret_cast<TypeSourceInfo *>(getReceiverPointer());
1287 return nullptr;
1288 }
1289
1290 void setClassReceiver(TypeSourceInfo *TSInfo) {
1291 Kind = Class;
1292 setReceiverPointer(TSInfo);
1293 }
1294
1295
1296
1297 SourceLocation getSuperLoc() const {
1298 if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass)
1299 return SuperLoc;
1300
1301 return SourceLocation();
1302 }
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313 QualType getReceiverType() const;
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325 ObjCInterfaceDecl *getReceiverInterface() const;
1326
1327
1328
1329
1330
1331
1332 QualType getSuperType() const {
1333 if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass)
1334 return QualType::getFromOpaquePtr(getReceiverPointer());
1335
1336 return QualType();
1337 }
1338
1339 void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper) {
1340 Kind = IsInstanceSuper? SuperInstance : SuperClass;
1341 SuperLoc = Loc;
1342 setReceiverPointer(T.getAsOpaquePtr());
1343 }
1344
1345 Selector getSelector() const;
1346
1347 void setSelector(Selector S) {
1348 HasMethod = false;
1349 SelectorOrMethod = reinterpret_cast<uintptr_t>(S.getAsOpaquePtr());
1350 }
1351
1352 const ObjCMethodDecl *getMethodDecl() const {
1353 if (HasMethod)
1354 return reinterpret_cast<const ObjCMethodDecl *>(SelectorOrMethod);
1355
1356 return nullptr;
1357 }
1358
1359 ObjCMethodDecl *getMethodDecl() {
1360 if (HasMethod)
1361 return reinterpret_cast<ObjCMethodDecl *>(SelectorOrMethod);
1362
1363 return nullptr;
1364 }
1365
1366 void setMethodDecl(ObjCMethodDecl *MD) {
1367 HasMethod = true;
1368 SelectorOrMethod = reinterpret_cast<uintptr_t>(MD);
1369 }
1370
1371 ObjCMethodFamily getMethodFamily() const {
1372 if (HasMethod) return getMethodDecl()->getMethodFamily();
1373 return getSelector().getMethodFamily();
1374 }
1375
1376
1377
1378 unsigned getNumArgs() const { return NumArgs; }
1379
1380
1381
1382 Expr **getArgs() {
1383 return reinterpret_cast<Expr **>(getTrailingObjects<void *>() + 1);
1384 }
1385 const Expr * const *getArgs() const {
1386 return reinterpret_cast<const Expr *const *>(getTrailingObjects<void *>() +
1387 1);
1388 }
1389
1390
1391 Expr *getArg(unsigned Arg) {
1392 assert(Arg < NumArgs && "Arg access out of range!");
1393 return getArgs()[Arg];
1394 }
1395 const Expr *getArg(unsigned Arg) const {
1396 assert(Arg < NumArgs && "Arg access out of range!");
1397 return getArgs()[Arg];
1398 }
1399
1400
1401 void setArg(unsigned Arg, Expr *ArgExpr) {
1402 assert(Arg < NumArgs && "Arg access out of range!");
1403 getArgs()[Arg] = ArgExpr;
1404 }
1405
1406
1407
1408
1409 bool isDelegateInitCall() const { return IsDelegateInitCall; }
1410 void setDelegateInitCall(bool isDelegate) { IsDelegateInitCall = isDelegate; }
1411
1412 SourceLocation getLeftLoc() const { return LBracLoc; }
1413 SourceLocation getRightLoc() const { return RBracLoc; }
1414
1415 SourceLocation getSelectorStartLoc() const {
1416 if (isImplicit())
1417 return getBeginLoc();
1418 return getSelectorLoc(0);
1419 }
1420
1421 SourceLocation getSelectorLoc(unsigned Index) const {
1422 assert(Index < getNumSelectorLocs() && "Index out of range!");
1423 if (hasStandardSelLocs())
1424 return getStandardSelectorLoc(
1425 Index, getSelector(), getSelLocsKind() == SelLoc_StandardWithSpace,
1426 llvm::ArrayRef(const_cast<Expr **>(getArgs()), getNumArgs()),
1427 RBracLoc);
1428 return getStoredSelLocs()[Index];
1429 }
1430
1431 void getSelectorLocs(SmallVectorImpl<SourceLocation> &SelLocs) const;
1432
1433 unsigned getNumSelectorLocs() const {
1434 if (isImplicit())
1435 return 0;
1436 Selector Sel = getSelector();
1437 if (Sel.isUnarySelector())
1438 return 1;
1439 return Sel.getNumArgs();
1440 }
1441
1442 void setSourceRange(SourceRange R) {
1443 LBracLoc = R.getBegin();
1444 RBracLoc = R.getEnd();
1445 }
1446
1447 SourceLocation getBeginLoc() const LLVM_READONLY { return LBracLoc; }
1448 SourceLocation getEndLoc() const LLVM_READONLY { return RBracLoc; }
1449
1450
1451 child_range children();
1452
1453 const_child_range children() const;
1454
1455 using arg_iterator = ExprIterator;
1456 using const_arg_iterator = ConstExprIterator;
1457
1458 llvm::iterator_range<arg_iterator> arguments() {
1459 return llvm::make_range(arg_begin(), arg_end());
1460 }
1461
1462 llvm::iterator_range<const_arg_iterator> arguments() const {
1463 return llvm::make_range(arg_begin(), arg_end());
1464 }
1465
1466 arg_iterator arg_begin() { return reinterpret_cast<Stmt **>(getArgs()); }
1467
1468 arg_iterator arg_end() {
1469 return reinterpret_cast<Stmt **>(getArgs() + NumArgs);
1470 }
1471
1472 const_arg_iterator arg_begin() const {
1473 return reinterpret_cast<Stmt const * const*>(getArgs());
1474 }
1475
1476 const_arg_iterator arg_end() const {
1477 return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs);
1478 }
1479
1480 static bool classof(const Stmt *T) {
1481 return T->getStmtClass() == ObjCMessageExprClass;
1482 }
1483 };
1484
1485
1486
1487 class ObjCIsaExpr : public Expr {
1488
1489 Stmt *Base;
1490
1491
1492 SourceLocation IsaMemberLoc;
1493
1494
1495 SourceLocation OpLoc;
1496
1497
1498 bool IsArrow;
1499
1500 public:
1501 ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, SourceLocation oploc,
1502 QualType ty)
1503 : Expr(ObjCIsaExprClass, ty, VK_LValue, OK_Ordinary), Base(base),
1504 IsaMemberLoc(l), OpLoc(oploc), IsArrow(isarrow) {
1505 setDependence(computeDependence(this));
1506 }
1507
1508
1509 explicit ObjCIsaExpr(EmptyShell Empty) : Expr(ObjCIsaExprClass, Empty) {}
1510
1511 void setBase(Expr *E) { Base = E; }
1512 Expr *getBase() const { return cast<Expr>(Base); }
1513
1514 bool isArrow() const { return IsArrow; }
1515 void setArrow(bool A) { IsArrow = A; }
1516
1517
1518
1519 SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; }
1520 void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; }
1521
1522 SourceLocation getOpLoc() const { return OpLoc; }
1523 void setOpLoc(SourceLocation L) { OpLoc = L; }
1524
1525 SourceLocation getBeginLoc() const LLVM_READONLY {
1526 return getBase()->getBeginLoc();
1527 }
1528
1529 SourceLocation getBaseLocEnd() const LLVM_READONLY {
1530 return getBase()->getEndLoc();
1531 }
1532
1533 SourceLocation getEndLoc() const LLVM_READONLY { return IsaMemberLoc; }
1534
1535 SourceLocation getExprLoc() const LLVM_READONLY { return IsaMemberLoc; }
1536
1537
1538 child_range children() { return child_range(&Base, &Base+1); }
1539
1540 const_child_range children() const {
1541 return const_child_range(&Base, &Base + 1);
1542 }
1543
1544 static bool classof(const Stmt *T) {
1545 return T->getStmtClass() == ObjCIsaExprClass;
1546 }
1547 };
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571 class ObjCIndirectCopyRestoreExpr : public Expr {
1572 friend class ASTReader;
1573 friend class ASTStmtReader;
1574
1575 Stmt *Operand;
1576
1577
1578
1579 explicit ObjCIndirectCopyRestoreExpr(EmptyShell Empty)
1580 : Expr(ObjCIndirectCopyRestoreExprClass, Empty) {}
1581
1582 void setShouldCopy(bool shouldCopy) {
1583 ObjCIndirectCopyRestoreExprBits.ShouldCopy = shouldCopy;
1584 }
1585
1586 public:
1587 ObjCIndirectCopyRestoreExpr(Expr *operand, QualType type, bool shouldCopy)
1588 : Expr(ObjCIndirectCopyRestoreExprClass, type, VK_LValue, OK_Ordinary),
1589 Operand(operand) {
1590 setShouldCopy(shouldCopy);
1591 setDependence(computeDependence(this));
1592 }
1593
1594 Expr *getSubExpr() { return cast<Expr>(Operand); }
1595 const Expr *getSubExpr() const { return cast<Expr>(Operand); }
1596
1597
1598
1599 bool shouldCopy() const { return ObjCIndirectCopyRestoreExprBits.ShouldCopy; }
1600
1601 child_range children() { return child_range(&Operand, &Operand+1); }
1602
1603 const_child_range children() const {
1604 return const_child_range(&Operand, &Operand + 1);
1605 }
1606
1607
1608 SourceLocation getBeginLoc() const LLVM_READONLY {
1609 return Operand->getBeginLoc();
1610 }
1611 SourceLocation getEndLoc() const LLVM_READONLY {
1612 return Operand->getEndLoc();
1613 }
1614
1615 SourceLocation getExprLoc() const LLVM_READONLY {
1616 return getSubExpr()->getExprLoc();
1617 }
1618
1619 static bool classof(const Stmt *s) {
1620 return s->getStmtClass() == ObjCIndirectCopyRestoreExprClass;
1621 }
1622 };
1623
1624
1625
1626
1627
1628
1629
1630 class ObjCBridgedCastExpr final
1631 : public ExplicitCastExpr,
1632 private llvm::TrailingObjects<ObjCBridgedCastExpr, CXXBaseSpecifier *> {
1633 friend class ASTStmtReader;
1634 friend class ASTStmtWriter;
1635 friend class CastExpr;
1636 friend TrailingObjects;
1637
1638 SourceLocation LParenLoc;
1639 SourceLocation BridgeKeywordLoc;
1640 LLVM_PREFERRED_TYPE(ObjCBridgeCastKind)
1641 unsigned Kind : 2;
1642
1643 public:
1644 ObjCBridgedCastExpr(SourceLocation LParenLoc, ObjCBridgeCastKind Kind,
1645 CastKind CK, SourceLocation BridgeKeywordLoc,
1646 TypeSourceInfo *TSInfo, Expr *Operand)
1647 : ExplicitCastExpr(ObjCBridgedCastExprClass, TSInfo->getType(),
1648 VK_PRValue, CK, Operand, 0, false, TSInfo),
1649 LParenLoc(LParenLoc), BridgeKeywordLoc(BridgeKeywordLoc), Kind(Kind) {}
1650
1651
1652 explicit ObjCBridgedCastExpr(EmptyShell Shell)
1653 : ExplicitCastExpr(ObjCBridgedCastExprClass, Shell, 0, false) {}
1654
1655 SourceLocation getLParenLoc() const { return LParenLoc; }
1656
1657
1658 ObjCBridgeCastKind getBridgeKind() const {
1659 return static_cast<ObjCBridgeCastKind>(Kind);
1660 }
1661
1662
1663 StringRef getBridgeKindName() const;
1664
1665
1666 SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; }
1667
1668 SourceLocation getBeginLoc() const LLVM_READONLY { return LParenLoc; }
1669
1670 SourceLocation getEndLoc() const LLVM_READONLY {
1671 return getSubExpr()->getEndLoc();
1672 }
1673
1674 static bool classof(const Stmt *T) {
1675 return T->getStmtClass() == ObjCBridgedCastExprClass;
1676 }
1677 };
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692 class ObjCAvailabilityCheckExpr : public Expr {
1693 friend class ASTStmtReader;
1694
1695 VersionTuple VersionToCheck;
1696 SourceLocation AtLoc, RParen;
1697
1698 public:
1699 ObjCAvailabilityCheckExpr(VersionTuple VersionToCheck, SourceLocation AtLoc,
1700 SourceLocation RParen, QualType Ty)
1701 : Expr(ObjCAvailabilityCheckExprClass, Ty, VK_PRValue, OK_Ordinary),
1702 VersionToCheck(VersionToCheck), AtLoc(AtLoc), RParen(RParen) {
1703 setDependence(ExprDependence::None);
1704 }
1705
1706 explicit ObjCAvailabilityCheckExpr(EmptyShell Shell)
1707 : Expr(ObjCAvailabilityCheckExprClass, Shell) {}
1708
1709 SourceLocation getBeginLoc() const { return AtLoc; }
1710 SourceLocation getEndLoc() const { return RParen; }
1711 SourceRange getSourceRange() const { return {AtLoc, RParen}; }
1712
1713
1714 bool hasVersion() const { return !VersionToCheck.empty(); }
1715 VersionTuple getVersion() const { return VersionToCheck; }
1716
1717 child_range children() {
1718 return child_range(child_iterator(), child_iterator());
1719 }
1720
1721 const_child_range children() const {
1722 return const_child_range(const_child_iterator(), const_child_iterator());
1723 }
1724
1725 static bool classof(const Stmt *T) {
1726 return T->getStmtClass() == ObjCAvailabilityCheckExprClass;
1727 }
1728 };
1729
1730 }
1731
1732 #endif