aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-12-02 01:19:52 +0000
committerJohn McCall <rjmccall@apple.com>2010-12-02 01:19:52 +0000
commit12f78a6741a4cb3d904340f8d3d2714568b50e7a (patch)
tree7d3c0d003eb7060d7a7a985d6f4fa284f9207c35
parent9d0b2b728b9a431546b11252793844bf7506ec84 (diff)
Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ObjCPropertyRefExpr
into the latter. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120643 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ExprObjC.h244
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h1
-rw-r--r--include/clang/Basic/StmtNodes.td1
-rw-r--r--include/clang/Serialization/ASTBitCodes.h2
-rw-r--r--lib/AST/Expr.cpp40
-rw-r--r--lib/AST/ExprClassification.cpp18
-rw-r--r--lib/AST/ExprConstant.cpp1
-rw-r--r--lib/AST/StmtDumper.cpp34
-rw-r--r--lib/AST/StmtPrinter.cpp18
-rw-r--r--lib/AST/StmtProfile.cpp19
-rw-r--r--lib/Checker/CheckObjCDealloc.cpp4
-rw-r--r--lib/Checker/GRExprEngine.cpp8
-rw-r--r--lib/CodeGen/CGBlocks.cpp7
-rw-r--r--lib/CodeGen/CGExpr.cpp25
-rw-r--r--lib/CodeGen/CGExprAgg.cpp7
-rw-r--r--lib/CodeGen/CGExprComplex.cpp4
-rw-r--r--lib/CodeGen/CGExprScalar.cpp4
-rw-r--r--lib/CodeGen/CGObjC.cpp118
-rw-r--r--lib/CodeGen/CGValue.h12
-rw-r--r--lib/CodeGen/CodeGenFunction.h5
-rw-r--r--lib/CodeGen/Mangle.cpp1
-rw-r--r--lib/Rewrite/RewriteObjC.cpp82
-rw-r--r--lib/Sema/SemaExpr.cpp56
-rw-r--r--lib/Sema/SemaExprObjC.cpp19
-rw-r--r--lib/Sema/SemaStmt.cpp12
-rw-r--r--lib/Sema/TreeTransform.h99
-rw-r--r--lib/Serialization/ASTReaderStmt.cpp50
-rw-r--r--lib/Serialization/ASTWriterStmt.cpp40
-rw-r--r--tools/libclang/CIndex.cpp2
-rw-r--r--tools/libclang/CXCursor.cpp2
30 files changed, 351 insertions, 584 deletions
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h
index 75e02e768e..c0f4c1b750 100644
--- a/include/clang/AST/ExprObjC.h
+++ b/include/clang/AST/ExprObjC.h
@@ -14,14 +14,13 @@
#ifndef LLVM_CLANG_AST_EXPROBJC_H
#define LLVM_CLANG_AST_EXPROBJC_H
+#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
#include "clang/Basic/IdentifierTable.h"
namespace clang {
class IdentifierInfo;
class ASTContext;
- class ObjCMethodDecl;
- class ObjCPropertyDecl;
/// ObjCStringLiteral, used for Objective-C string literals
/// i.e. @"foo".
@@ -229,17 +228,20 @@ public:
///
class ObjCPropertyRefExpr : public Expr {
private:
- ObjCPropertyDecl *AsProperty;
+ /// If the bool is true, this is an implicit property reference; the
+ /// pointer is an (optional) ObjCMethodDecl and Setter may be set.
+ /// if the bool is false, this is an explicit property reference;
+ /// the pointer is an ObjCPropertyDecl and Setter is always null.
+ llvm::PointerIntPair<NamedDecl*, 1, bool> PropertyOrGetter;
+ ObjCMethodDecl *Setter;
+
SourceLocation IdLoc;
/// \brief When the receiver in property access is 'super', this is
- /// the location of the 'super' keyword.
- SourceLocation SuperLoc;
-
- /// \brief When the receiver in property access is 'super', this is
- /// the type associated with 'super' keyword. A null type indicates
- /// that this is not a 'super' receiver.
- llvm::PointerUnion<Stmt*, Type*> BaseExprOrSuperType;
+ /// the location of the 'super' keyword. When it's an interface,
+ /// this is that interface.
+ SourceLocation ReceiverLoc;
+ llvm::PointerUnion3<Stmt*, Type*, ObjCInterfaceDecl*> Receiver;
public:
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,
@@ -247,44 +249,103 @@ public:
SourceLocation l, Expr *base)
: Expr(ObjCPropertyRefExprClass, t, VK, OK,
/*TypeDependent=*/false, base->isValueDependent()),
- AsProperty(PD), IdLoc(l), BaseExprOrSuperType(base) {
+ PropertyOrGetter(PD, false), Setter(0),
+ IdLoc(l), ReceiverLoc(), Receiver(base) {
}
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,
ExprValueKind VK, ExprObjectKind OK,
SourceLocation l, SourceLocation sl, QualType st)
- : Expr(ObjCPropertyRefExprClass, t, VK, OK,
- /*TypeDependent=*/false, false),
- AsProperty(PD), IdLoc(l), SuperLoc(sl),
- BaseExprOrSuperType(st.getTypePtr()) {
+ : Expr(ObjCPropertyRefExprClass, t, VK, OK,
+ /*TypeDependent=*/false, false),
+ PropertyOrGetter(PD, false), Setter(0),
+ IdLoc(l), ReceiverLoc(sl), Receiver(st.getTypePtr()) {
+ }
+
+ ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
+ QualType T, ExprValueKind VK, ExprObjectKind OK,
+ SourceLocation IdLoc, Expr *Base)
+ : Expr(ObjCPropertyRefExprClass, T, VK, OK, false,
+ Base->isValueDependent()),
+ PropertyOrGetter(Getter, true), Setter(Setter),
+ IdLoc(IdLoc), ReceiverLoc(), Receiver(Base) {
+ }
+
+ ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
+ QualType T, ExprValueKind VK, ExprObjectKind OK,
+ SourceLocation IdLoc,
+ SourceLocation SuperLoc, QualType SuperTy)
+ : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false),
+ PropertyOrGetter(Getter, true), Setter(Setter),
+ IdLoc(IdLoc), ReceiverLoc(SuperLoc), Receiver(SuperTy.getTypePtr()) {
+ }
+
+ ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
+ QualType T, ExprValueKind VK, ExprObjectKind OK,
+ SourceLocation IdLoc,
+ SourceLocation ReceiverLoc, ObjCInterfaceDecl *Receiver)
+ : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false),
+ PropertyOrGetter(Getter, true), Setter(Setter),
+ IdLoc(IdLoc), ReceiverLoc(ReceiverLoc), Receiver(Receiver) {
}
explicit ObjCPropertyRefExpr(EmptyShell Empty)
: Expr(ObjCPropertyRefExprClass, Empty) {}
- ObjCPropertyDecl *getProperty() const { return AsProperty; }
+ bool isImplicitProperty() const { return PropertyOrGetter.getInt(); }
+ bool isExplicitProperty() const { return !PropertyOrGetter.getInt(); }
+
+ ObjCPropertyDecl *getExplicitProperty() const {
+ assert(!isImplicitProperty());
+ return cast<ObjCPropertyDecl>(PropertyOrGetter.getPointer());
+ }
+
+ ObjCMethodDecl *getImplicitPropertyGetter() const {
+ assert(isImplicitProperty());
+ return cast_or_null<ObjCMethodDecl>(PropertyOrGetter.getPointer());
+ }
+
+ ObjCMethodDecl *getImplicitPropertySetter() const {
+ assert(isImplicitProperty());
+ return Setter;
+ }
+
+ Selector getGetterSelector() const {
+ if (isImplicitProperty())
+ return getImplicitPropertyGetter()->getSelector();
+ return getExplicitProperty()->getGetterName();
+ }
+
+ Selector getSetterSelector() const {
+ if (isImplicitProperty())
+ return getImplicitPropertySetter()->getSelector();
+ return getExplicitProperty()->getSetterName();
+ }
const Expr *getBase() const {
- return cast<Expr>(BaseExprOrSuperType.get<Stmt*>());
+ return cast<Expr>(Receiver.get<Stmt*>());
}
Expr *getBase() {
- return cast<Expr>(BaseExprOrSuperType.get<Stmt*>());
+ return cast<Expr>(Receiver.get<Stmt*>());
}
SourceLocation getLocation() const { return IdLoc; }
- SourceLocation getSuperLocation() const { return SuperLoc; }
- QualType getSuperType() const {
- Type *t = BaseExprOrSuperType.get<Type*>();
- return QualType(t, 0);
+ SourceLocation getReceiverLocation() const { return ReceiverLoc; }
+ QualType getSuperReceiverType() const {
+ return QualType(Receiver.get<Type*>(), 0);
+ }
+ ObjCInterfaceDecl *getClassReceiver() const {
+ return Receiver.get<ObjCInterfaceDecl*>();
}
- bool isSuperReceiver() const { return BaseExprOrSuperType.is<Type*>(); }
+ bool isObjectReceiver() const { return Receiver.is<Stmt*>(); }
+ bool isSuperReceiver() const { return Receiver.is<Type*>(); }
+ bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
virtual SourceRange getSourceRange() const {
- return SourceRange(
- (BaseExprOrSuperType.is<Stmt*>() ? getBase()->getLocStart()
- : getSuperLocation()),
- IdLoc);
+ return SourceRange((isObjectReceiver() ? getBase()->getLocStart()
+ : getReceiverLocation()),
+ IdLoc);
}
static bool classof(const Stmt *T) {
@@ -297,125 +358,22 @@ public:
virtual child_iterator child_end();
private:
friend class ASTStmtReader;
- void setProperty(ObjCPropertyDecl *D) { AsProperty = D; }
- void setBase(Expr *base) { BaseExprOrSuperType = base; }
- void setLocation(SourceLocation L) { IdLoc = L; }
- void setSuperLocation(SourceLocation Loc) { SuperLoc = Loc; }
- void setSuperType(QualType T) { BaseExprOrSuperType = T.getTypePtr(); }
-};
-
-/// ObjCImplicitSetterGetterRefExpr - A dot-syntax expression to access two
-/// methods; one to set a value to an 'ivar' (Setter) and the other to access
-/// an 'ivar' (Setter).
-/// An example for use of this AST is:
-/// @code
-/// @interface Test { }
-/// - (Test *)crash;
-/// - (void)setCrash: (Test*)value;
-/// @end
-/// void foo(Test *p1, Test *p2)
-/// {
-/// p2.crash = p1.crash; // Uses ObjCImplicitSetterGetterRefExpr AST
-/// }
-/// @endcode
-class ObjCImplicitSetterGetterRefExpr : public Expr {
- /// Setter - Setter method user declared for setting its 'ivar' to a value
- ObjCMethodDecl *Setter;
- /// Getter - Getter method user declared for accessing 'ivar' it controls.
- ObjCMethodDecl *Getter;
- /// Location of the member in the dot syntax notation. This is location
- /// of the getter method.
- SourceLocation MemberLoc;
- // FIXME: Swizzle these into a single pointer.
- Stmt *Base;
- ObjCInterfaceDecl *InterfaceDecl;
- /// \brief Location of the receiver class in the dot syntax notation
- /// used to call a class method setter/getter.
- SourceLocation ClassLoc;
-
- /// \brief When the receiver in dot-syntax expression is 'super',
- /// this is the location of the 'super' keyword.
- SourceLocation SuperLoc;
-
- /// \brief When the receiver in dot-syntax expression is 'super', this is
- /// the type associated with 'super' keyword.
- QualType SuperTy;
-
-public:
- ObjCImplicitSetterGetterRefExpr(ObjCMethodDecl *getter, QualType t,
- ExprValueKind VK, ExprObjectKind OK,
- ObjCMethodDecl *setter,
- SourceLocation l, Expr *base)
- : Expr(ObjCImplicitSetterGetterRefExprClass, t, VK, OK,
- /*TypeDependent=*/false, base->isValueDependent()),
- Setter(setter), Getter(getter), MemberLoc(l), Base(base),
- InterfaceDecl(0), ClassLoc(SourceLocation()) {}
-
- ObjCImplicitSetterGetterRefExpr(ObjCMethodDecl *getter, QualType t,
- ExprValueKind VK, ExprObjectKind OK,
- ObjCMethodDecl *setter,
- SourceLocation l,
- SourceLocation sl,
- QualType st)
- : Expr(ObjCImplicitSetterGetterRefExprClass, t, VK, OK,
- /*TypeDependent=*/false, false),
- Setter(setter), Getter(getter), MemberLoc(l),
- Base(0), InterfaceDecl(0), ClassLoc(SourceLocation()),
- SuperLoc(sl), SuperTy(st) {
+ void setExplicitProperty(ObjCPropertyDecl *D) {
+ PropertyOrGetter.setPointer(D);
+ PropertyOrGetter.setInt(false);
+ Setter = 0;
}
-
- ObjCImplicitSetterGetterRefExpr(ObjCMethodDecl *getter, QualType t,
- ExprValueKind VK, ExprObjectKind OK,
- ObjCMethodDecl *setter,
- SourceLocation l, ObjCInterfaceDecl *C, SourceLocation CL)
- : Expr(ObjCImplicitSetterGetterRefExprClass, t, VK, OK, false, false),
- Setter(setter), Getter(getter), MemberLoc(l), Base(0), InterfaceDecl(C),
- ClassLoc(CL) {}
- explicit ObjCImplicitSetterGetterRefExpr(EmptyShell Empty)
- : Expr(ObjCImplicitSetterGetterRefExprClass, Empty){}
-
- ObjCMethodDecl *getGetterMethod() const { return Getter; }
- ObjCMethodDecl *getSetterMethod() const { return Setter; }
- ObjCInterfaceDecl *getInterfaceDecl() const { return InterfaceDecl; }
- void setGetterMethod(ObjCMethodDecl *D) { Getter = D; }
- void setSetterMethod(ObjCMethodDecl *D) { Setter = D; }
- void setInterfaceDecl(ObjCInterfaceDecl *D) { InterfaceDecl = D; }
-
- virtual SourceRange getSourceRange() const {
- if (isSuperReceiver())
- return SourceRange(getSuperLocation(), MemberLoc);
- if (Base)
- return SourceRange(getBase()->getLocStart(), MemberLoc);
- return SourceRange(ClassLoc, MemberLoc);
- }
- const Expr *getBase() const { return cast_or_null<Expr>(Base); }
- Expr *getBase() { return cast_or_null<Expr>(Base); }
- void setBase(Expr *base) { Base = base; }
-
- SourceLocation getLocation() const { return MemberLoc; }
- void setLocation(SourceLocation L) { MemberLoc = L; }
- SourceLocation getClassLoc() const { return ClassLoc; }
- void setClassLoc(SourceLocation L) { ClassLoc = L; }
-
- SourceLocation getSuperLocation() const { return SuperLoc; }
- QualType getSuperType() const { return SuperTy; }
- /// \brief When the receiver in dot-syntax expression is 'super', this
- /// method returns true if both Base expression and Interface are null.
- bool isSuperReceiver() const { return InterfaceDecl == 0 && Base == 0; }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ObjCImplicitSetterGetterRefExprClass;
+ void setImplicitProperty(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter) {
+ PropertyOrGetter.setPointer(Getter);
+ PropertyOrGetter.setInt(true);
+ this->Setter = Setter;
}
- static bool classof(const ObjCImplicitSetterGetterRefExpr *) { return true; }
+ void setBase(Expr *Base) { Receiver = Base; }
+ void setSuperReceiver(QualType T) { Receiver = T.getTypePtr(); }
+ void setClassReceiver(ObjCInterfaceDecl *D) { Receiver = D; }
- // Iterators
- virtual child_iterator child_begin();
- virtual child_iterator child_end();
-
-private:
- friend class ASTStmtReader;
- void setSuperLocation(SourceLocation Loc) { SuperLoc = Loc; }
- void setSuperType(QualType T) { SuperTy = T; }
+ void setLocation(SourceLocation L) { IdLoc = L; }
+ void setReceiverLocation(SourceLocation Loc) { ReceiverLoc = Loc; }
};
/// \brief An expression that sends a message to the given Objective-C
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index f05ab931ec..8c70e114f9 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -1778,7 +1778,6 @@ DEF_TRAVERSE_STMT(ExtVectorElementExpr, { })
DEF_TRAVERSE_STMT(GNUNullExpr, { })
DEF_TRAVERSE_STMT(ImplicitValueInitExpr, { })
DEF_TRAVERSE_STMT(ObjCEncodeExpr, { })
-DEF_TRAVERSE_STMT(ObjCImplicitSetterGetterRefExpr, { })
DEF_TRAVERSE_STMT(ObjCIsaExpr, { })
DEF_TRAVERSE_STMT(ObjCIvarRefExpr, { })
DEF_TRAVERSE_STMT(ObjCMessageExpr, { })
diff --git a/include/clang/Basic/StmtNodes.td b/include/clang/Basic/StmtNodes.td
index c9ec0ef148..b837368841 100644
--- a/include/clang/Basic/StmtNodes.td
+++ b/include/clang/Basic/StmtNodes.td
@@ -120,7 +120,6 @@ def ObjCSelectorExpr : DStmt<Expr>;
def ObjCProtocolExpr : DStmt<Expr>;
def ObjCIvarRefExpr : DStmt<Expr>;
def ObjCPropertyRefExpr : DStmt<Expr>;
-def ObjCImplicitSetterGetterRefExpr : DStmt<Expr>;
def ObjCIsaExpr : DStmt<Expr>;
// Clang Extensions.
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 9a0fec7b12..bc3ac7357b 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -853,7 +853,7 @@ namespace clang {
EXPR_OBJC_IVAR_REF_EXPR,
/// \brief An ObjCPropertyRefExpr record.
EXPR_OBJC_PROPERTY_REF_EXPR,
- /// \brief An ObjCImplicitSetterGetterRefExpr record.
+ /// \brief UNUSED
EXPR_OBJC_KVC_REF_EXPR,
/// \brief An ObjCMessageExpr record.
EXPR_OBJC_MESSAGE_EXPR,
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 6e56603c53..265788a081 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1338,21 +1338,11 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
return false;
}
- case ObjCImplicitSetterGetterRefExprClass: { // Dot syntax for message send.
-#if 0
- const ObjCImplicitSetterGetterRefExpr *Ref =
- cast<ObjCImplicitSetterGetterRefExpr>(this);
- // FIXME: We really want the location of the '.' here.
- Loc = Ref->getLocation();
- R1 = SourceRange(Ref->getLocation(), Ref->getLocation());
- if (Ref->getBase())
- R2 = Ref->getBase()->getSourceRange();
-#else
+ case ObjCPropertyRefExprClass:
Loc = getExprLoc();
R1 = getSourceRange();
-#endif
return true;
- }
+
case StmtExprClass: {
// Statement exprs don't logically have side effects themselves, but are
// sometimes used in macros in ways that give them a type that is unused.
@@ -1635,7 +1625,6 @@ Expr::CanThrowResult Expr::CanThrow(ASTContext &C) const {
// specs.
case ObjCMessageExprClass:
case ObjCPropertyRefExprClass:
- case ObjCImplicitSetterGetterRefExprClass:
return CT_Can;
// Many other things have subexpressions, so we have to test those.
@@ -1838,8 +1827,7 @@ bool Expr::isTemporaryObject(ASTContext &C, const CXXRecordDecl *TempTy) const {
// Temporaries are by definition pr-values of class type.
if (!E->Classify(C).isPRValue()) {
// In this context, property reference is a message call and is pr-value.
- if (!isa<ObjCPropertyRefExpr>(E) &&
- !isa<ObjCImplicitSetterGetterRefExpr>(E))
+ if (!isa<ObjCPropertyRefExpr>(E))
return false;
}
@@ -2537,33 +2525,19 @@ Stmt::child_iterator ObjCIvarRefExpr::child_end() { return &Base+1; }
// ObjCPropertyRefExpr
Stmt::child_iterator ObjCPropertyRefExpr::child_begin()
{
- if (BaseExprOrSuperType.is<Stmt*>()) {
+ if (Receiver.is<Stmt*>()) {
// Hack alert!
- return reinterpret_cast<Stmt**> (&BaseExprOrSuperType);
+ return reinterpret_cast<Stmt**> (&Receiver);
}
return child_iterator();
}
Stmt::child_iterator ObjCPropertyRefExpr::child_end()
-{ return BaseExprOrSuperType.is<Stmt*>() ?
- reinterpret_cast<Stmt**> (&BaseExprOrSuperType)+1 :
+{ return Receiver.is<Stmt*>() ?
+ reinterpret_cast<Stmt**> (&Receiver)+1 :
child_iterator();
}
-// ObjCImplicitSetterGetterRefExpr
-Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_begin() {
- // If this is accessing a class member or super, skip that entry.
- // Technically, 2nd condition is sufficient. But I want to be verbose
- if (isSuperReceiver() || !Base)
- return child_iterator();
- return &Base;
-}
-Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_end() {
- if (isSuperReceiver() || !Base)
- return child_iterator();
- return &Base+1;
-}
-
// ObjCIsaExpr
Stmt::child_iterator ObjCIsaExpr::child_begin() { return &Base; }
Stmt::child_iterator ObjCIsaExpr::child_end() { return &Base+1; }
diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp
index 4025f18a3b..e55545e693 100644
--- a/lib/AST/ExprClassification.cpp
+++ b/lib/AST/ExprClassification.cpp
@@ -104,7 +104,6 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
case Expr::PredefinedExprClass:
// Property references are lvalues
case Expr::ObjCPropertyRefExprClass:
- case Expr::ObjCImplicitSetterGetterRefExprClass:
// C++ [expr.typeid]p1: The result of a typeid expression is an lvalue of...
case Expr::CXXTypeidExprClass:
// Unresolved lookups get classified as lvalues.
@@ -195,8 +194,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
Cl::Kinds K = ClassifyInternal(Ctx, Op);
if (K != Cl::CL_LValue) return K;
- if (isa<ObjCPropertyRefExpr>(Op) ||
- isa<ObjCImplicitSetterGetterRefExpr>(Op))
+ if (isa<ObjCPropertyRefExpr>(Op))
return Cl::CL_SubObjCPropertySetting;
return Cl::CL_LValue;
}
@@ -368,8 +366,7 @@ static Cl::Kinds ClassifyMemberExpr(ASTContext &Ctx, const MemberExpr *E) {
return Cl::CL_LValue;
// ObjC property accesses are not lvalues, but get special treatment.
Expr *Base = E->getBase()->IgnoreParens();
- if (isa<ObjCPropertyRefExpr>(Base) ||
- isa<ObjCImplicitSetterGetterRefExpr>(Base))
+ if (isa<ObjCPropertyRefExpr>(Base))
return Cl::CL_SubObjCPropertySetting;
return ClassifyInternal(Ctx, Base);
}
@@ -395,8 +392,7 @@ static Cl::Kinds ClassifyMemberExpr(ASTContext &Ctx, const MemberExpr *E) {
if (E->isArrow())
return Cl::CL_LValue;
Expr *Base = E->getBase()->IgnoreParenImpCasts();
- if (isa<ObjCPropertyRefExpr>(Base) ||
- isa<ObjCImplicitSetterGetterRefExpr>(Base))
+ if (isa<ObjCPropertyRefExpr>(Base))
return Cl::CL_SubObjCPropertySetting;
return ClassifyInternal(Ctx, E->getBase());
}
@@ -498,9 +494,8 @@ static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E,
// Assignment to a property in ObjC is an implicit setter access. But a
// setter might not exist.
- if (const ObjCImplicitSetterGetterRefExpr *Expr =
- dyn_cast<ObjCImplicitSetterGetterRefExpr>(E)) {
- if (Expr->getSetterMethod() == 0)
+ if (const ObjCPropertyRefExpr *Expr = dyn_cast<ObjCPropertyRefExpr>(E)) {
+ if (Expr->isImplicitProperty() && Expr->getImplicitPropertySetter() == 0)
return Cl::CM_NoSetterProperty;
}
@@ -517,8 +512,7 @@ static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E,
// Records with any const fields (recursively) are not modifiable.
if (const RecordType *R = CT->getAs<RecordType>()) {
- assert((isa<ObjCImplicitSetterGetterRefExpr>(E) ||
- isa<ObjCPropertyRefExpr>(E) ||
+ assert((isa<ObjCPropertyRefExpr>(E) ||
!Ctx.getLangOptions().CPlusPlus) &&
"C++ struct assignment should be resolved by the "
"copy assignment operator.");
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index f4685933dc..019cfc9b80 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -2506,7 +2506,6 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
case Expr::ObjCProtocolExprClass:
case Expr::ObjCIvarRefExprClass:
case Expr::ObjCPropertyRefExprClass:
- case Expr::ObjCImplicitSetterGetterRefExprClass:
case Expr::ObjCIsaExprClass:
case Expr::ShuffleVectorExprClass:
case Expr::BlockExprClass:
diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp
index 15a8d61c88..6f9a2d574b 100644
--- a/lib/AST/StmtDumper.cpp
+++ b/lib/AST/StmtDumper.cpp
@@ -172,8 +172,6 @@ namespace {
void VisitObjCSelectorExpr(ObjCSelectorExpr *Node);
void VisitObjCProtocolExpr(ObjCProtocolExpr *Node);
void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node);
- void VisitObjCImplicitSetterGetterRefExpr(
- ObjCImplicitSetterGetterRefExpr *Node);
void VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node);
};
}
@@ -607,27 +605,19 @@ void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
DumpExpr(Node);
- if (Node->isSuperReceiver())
- OS << " Kind=PropertyRef Property=\"" << Node->getProperty() << '"'
- << " super";
- else
- OS << " Kind=PropertyRef Property=\"" << Node->getProperty() << '"';
-}
-
-void StmtDumper::VisitObjCImplicitSetterGetterRefExpr(
- ObjCImplicitSetterGetterRefExpr *Node) {
- DumpExpr(Node);
+ if (Node->isImplicitProperty()) {
+ OS << " Kind=MethodRef Getter=\""
+ << Node->getImplicitPropertyGetter()->getSelector().getAsString()
+ << "\" Setter=\"";
+ if (ObjCMethodDecl *Setter = Node->getImplicitPropertySetter())
+ OS << Setter->getSelector().getAsString();
+ else
+ OS << "(null)";
+ OS << "\"";
+ } else {
+ OS << " Kind=PropertyRef Property=\"" << Node->getExplicitProperty() << '"';
+ }
- ObjCMethodDecl *Getter = Node->getGetterMethod();
- ObjCMethodDecl *Setter = Node->getSetterMethod();
- OS << " Kind=MethodRef Getter=\""
- << Getter->getSelector().getAsString()
- << "\" Setter=\"";
- if (Setter)
- OS << Setter->getSelector().getAsString();
- else
- OS << "(null)";
- OS << "\"";
if (Node->isSuperReceiver())
OS << " super";
}
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index d4791bcd0e..9dfde62deb 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -516,20 +516,10 @@ void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
OS << ".";
}
- OS << Node->getProperty()->getName();
-}
-
-void StmtPrinter::VisitObjCImplicitSetterGetterRefExpr(
- ObjCImplicitSetterGetterRefExpr *Node) {
- if (Node->isSuperReceiver())
- OS << "super.";
- else if (Node->getBase()) {
- PrintExpr(Node->getBase());
- OS << ".";
- }
- if (Node->getGetterMethod())
- OS << Node->getGetterMethod();
-
+ if (Node->isImplicitProperty())
+ OS << Node->getImplicitPropertyGetter()->getSelector().getAsString();
+ else
+ OS << Node->getExplicitProperty()->getName();
}
void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index d67f5fad6b..7f10bef713 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -866,22 +866,15 @@ void StmtProfiler::VisitObjCIvarRefExpr(ObjCIvarRefExpr *S) {
void StmtProfiler::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *S) {
VisitExpr(S);
- VisitDecl(S->getProperty());
- if (S->isSuperReceiver()) {
- ID.AddBoolean(S->isSuperReceiver());
- VisitType(S->getSuperType());
+ if (S->isImplicitProperty()) {
+ VisitDecl(S->getImplicitPropertyGetter());
+ VisitDecl(S->getImplicitPropertySetter());
+ } else {
+ VisitDecl(S->getExplicitProperty());
}
-}
-
-void StmtProfiler::VisitObjCImplicitSetterGetterRefExpr(
- ObjCImplicitSetterGetterRefExpr *S) {
- VisitExpr(S);
- VisitDecl(S->getGetterMethod());
- VisitDecl(S->getSetterMethod());
- VisitDecl(S->getInterfaceDecl());
if (S->isSuperReceiver()) {
ID.AddBoolean(S->isSuperReceiver());
- VisitType(S->getSuperType());
+ VisitType(S->getSuperReceiverType());
}
}
diff --git a/lib/Checker/CheckObjCDealloc.cpp b/lib/Checker/CheckObjCDealloc.cpp
index 11ddaca9d6..8ee6daa5c8 100644
--- a/lib/Checker/CheckObjCDealloc.cpp
+++ b/lib/Checker/CheckObjCDealloc.cpp
@@ -76,8 +76,8 @@ static bool scan_ivar_release(Stmt* S, ObjCIvarDecl* ID,
if (BinaryOperator* BO = dyn_cast<BinaryOperator>(S))
if (BO->isAssignmentOp())
if (ObjCPropertyRefExpr* PRE =
- dyn_cast<ObjCPropertyRefExpr>(BO->getLHS()->IgnoreParenCasts()))
- if (PRE->getProperty() == PD)
+ dyn_cast<ObjCPropertyRefExpr>(BO->getLHS()->IgnoreParenCasts()))
+ if (PRE->isExplicitProperty() && PRE->getExplicitProperty() == PD)
if (BO->getRHS()->isNullPointerConstant(Ctx,
Expr::NPC_ValueDependentIsNull)) {
// This is only a 'release' if the property kind is not
diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp
index a552447b30..99dcdcff41 100644
--- a/lib/Checker/GRExprEngine.cpp
+++ b/lib/Checker/GRExprEngine.cpp
@@ -852,7 +852,6 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred,
case Stmt::ObjCAtFinallyStmtClass:
case Stmt::ObjCAtTryStmtClass:
case Stmt::ObjCEncodeExprClass:
- case Stmt::ObjCImplicitSetterGetterRefExprClass:
case Stmt::ObjCIsaExprClass:
case Stmt::ObjCPropertyRefExprClass:
case Stmt::ObjCProtocolExprClass:
@@ -1221,7 +1220,6 @@ void GRExprEngine::VisitLValue(const Expr* Ex, ExplodedNode* Pred,
return;
case Stmt::ObjCPropertyRefExprClass:
- case Stmt::ObjCImplicitSetterGetterRefExprClass:
// FIXME: Property assignments are lvalues, but not really "locations".
// e.g.: self.x = something;
// Here the "self.x" really can translate to a method call (setter) when
@@ -3410,12 +3408,6 @@ void GRExprEngine::VisitBinaryOperator(const BinaryOperator* B,
Expr* LHS = B->getLHS()->IgnoreParens();
Expr* RHS = B->getRHS()->IgnoreParens();
- // FIXME: Add proper support for ObjCImplicitSetterGetterRefExpr.
- if (isa<ObjCImplicitSetterGetterRefExpr>(LHS)) {
- Visit(RHS, Pred, Dst);
- return;
- }
-
if (B->isAssignmentOp())
VisitLValue(LHS, Pred, Tmp1);
else
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 8f3e0a6326..b6cd1949cc 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -131,13 +131,6 @@ static void CollectBlockDeclRefInfo(const Stmt *S, CGBlockInfo &Info) {
if (PE->isSuperReceiver())
Info.NeedsObjCSelf = true;
}
- else if (const ObjCImplicitSetterGetterRefExpr *IE =
- dyn_cast<ObjCImplicitSetterGetterRefExpr>(S)) {
- // Getter/setter uses may also cause implicit super references,
- // which we can check for with: