Skip to content

Commit 526ab47

Browse files
committed
Restore r142914 and r142915, now with missing file and apparent
GCC compiler workaround. llvm-svn: 142931
1 parent c0ecd1f commit 526ab47

33 files changed

+702
-441
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ class ASTContext : public llvm::RefCountedBase<ASTContext> {
496496
CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
497497
CanQualType VoidPtrTy, NullPtrTy;
498498
CanQualType DependentTy, OverloadTy, BoundMemberTy, UnknownAnyTy;
499-
CanQualType ARCUnbridgedCastTy;
499+
CanQualType PseudoObjectTy, ARCUnbridgedCastTy;
500500
CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy;
501501

502502
// Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.

clang/include/clang/AST/BuiltinTypes.def

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,24 @@ PLACEHOLDER_TYPE(Overload, OverloadTy)
179179
// x->foo # if only contains non-static members
180180
PLACEHOLDER_TYPE(BoundMember, BoundMemberTy)
181181

182+
// The type of an expression which refers to a pseudo-object,
183+
// such as those introduced by Objective C's @property or
184+
// VS.NET's __property declarations. A placeholder type. The
185+
// pseudo-object is actually accessed by emitting a call to
186+
// some sort of function or method; typically there is a pair
187+
// of a setter and a getter, with the setter used if the
188+
// pseudo-object reference is used syntactically as the
189+
// left-hand-side of an assignment operator.
190+
//
191+
// A pseudo-object reference naming an Objective-C @property is
192+
// always a dot access with a base of object-pointer type,
193+
// e.g. 'x.foo'.
194+
//
195+
// In VS.NET, a __property declaration creates an implicit
196+
// member with an associated name, which can then be named
197+
// in any of the normal ways an ordinary member could be.
198+
PLACEHOLDER_TYPE(PseudoObject, PseudoObjectTy)
199+
182200
// __builtin_any_type. A placeholder type. Useful for clients
183201
// like debuggers that don't know what type to give something.
184202
// Only a small number of operations are valid on expressions of

clang/include/clang/AST/Expr.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,12 +1456,26 @@ class UnaryOperator : public Expr {
14561456

14571457
bool isPrefix() const { return isPrefix(getOpcode()); }
14581458
bool isPostfix() const { return isPostfix(getOpcode()); }
1459+
1460+
static bool isIncrementOp(Opcode Op) {
1461+
return Op == UO_PreInc || Op == UO_PostInc;
1462+
}
14591463
bool isIncrementOp() const {
1460-
return Opc == UO_PreInc || Opc == UO_PostInc;
1464+
return isIncrementOp(getOpcode());
1465+
}
1466+
1467+
static bool isDecrementOp(Opcode Op) {
1468+
return Op == UO_PreDec || Op == UO_PostDec;
14611469
}
1470+
bool isDecrementOp() const {
1471+
return isDecrementOp(getOpcode());
1472+
}
1473+
1474+
static bool isIncrementDecrementOp(Opcode Op) { return Op <= UO_PreDec; }
14621475
bool isIncrementDecrementOp() const {
1463-
return Opc <= UO_PreDec;
1476+
return isIncrementDecrementOp(getOpcode());
14641477
}
1478+
14651479
static bool isArithmeticOp(Opcode Op) {
14661480
return Op >= UO_Plus && Op <= UO_LNot;
14671481
}

clang/include/clang/AST/ExprObjC.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ class ObjCIvarRefExpr : public Expr {
227227

228228
/// ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC
229229
/// property.
230-
///
231230
class ObjCPropertyRefExpr : public Expr {
232231
private:
233232
/// If the bool is true, this is an implicit property reference; the
@@ -237,6 +236,11 @@ class ObjCPropertyRefExpr : public Expr {
237236
llvm::PointerIntPair<NamedDecl*, 1, bool> PropertyOrGetter;
238237
ObjCMethodDecl *Setter;
239238

239+
// FIXME: Maybe we should store the property identifier here,
240+
// because it's not rederivable from the other data when there's an
241+
// implicit property with no getter (because the 'foo' -> 'setFoo:'
242+
// transformation is lossy on the first character).
243+
240244
SourceLocation IdLoc;
241245

242246
/// \brief When the receiver in property access is 'super', this is
@@ -255,6 +259,7 @@ class ObjCPropertyRefExpr : public Expr {
255259
base->containsUnexpandedParameterPack()),
256260
PropertyOrGetter(PD, false), Setter(0),
257261
IdLoc(l), ReceiverLoc(), Receiver(base) {
262+
assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
258263
}
259264

260265
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,
@@ -265,6 +270,7 @@ class ObjCPropertyRefExpr : public Expr {
265270
st->containsUnexpandedParameterPack()),
266271
PropertyOrGetter(PD, false), Setter(0),
267272
IdLoc(l), ReceiverLoc(sl), Receiver(st.getTypePtr()) {
273+
assert(t->isSpecificPlaceholderType(BuiltinType::PseudoObject));
268274
}
269275

270276
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
@@ -275,6 +281,7 @@ class ObjCPropertyRefExpr : public Expr {
275281
Base->containsUnexpandedParameterPack()),
276282
PropertyOrGetter(Getter, true), Setter(Setter),
277283
IdLoc(IdLoc), ReceiverLoc(), Receiver(Base) {
284+
assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
278285
}
279286

280287
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
@@ -284,6 +291,7 @@ class ObjCPropertyRefExpr : public Expr {
284291
: Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false),
285292
PropertyOrGetter(Getter, true), Setter(Setter),
286293
IdLoc(IdLoc), ReceiverLoc(SuperLoc), Receiver(SuperTy.getTypePtr()) {
294+
assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
287295
}
288296

289297
ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
@@ -293,6 +301,7 @@ class ObjCPropertyRefExpr : public Expr {
293301
: Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false, false),
294302
PropertyOrGetter(Getter, true), Setter(Setter),
295303
IdLoc(IdLoc), ReceiverLoc(ReceiverLoc), Receiver(Receiver) {
304+
assert(T->isSpecificPlaceholderType(BuiltinType::PseudoObject));
296305
}
297306

298307
explicit ObjCPropertyRefExpr(EmptyShell Empty)
@@ -348,14 +357,15 @@ class ObjCPropertyRefExpr : public Expr {
348357
if (const ObjCMethodDecl *Getter = PDecl->getGetterMethodDecl())
349358
ResultType = Getter->getResultType();
350359
else
351-
ResultType = getType();
360+
ResultType = PDecl->getType();
352361
} else {
353362
const ObjCMethodDecl *Getter = getImplicitPropertyGetter();
354-
ResultType = Getter->getResultType(); // with reference!
363+
if (Getter)
364+
ResultType = Getter->getResultType(); // with reference!
355365
}
356366
return ResultType;
357367
}
358-
368+
359369
QualType getSetterArgType() const {
360370
QualType ArgType;
361371
if (isImplicitProperty()) {

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,16 +3612,22 @@ def ext_gnu_ptr_func_arith : Extension<
36123612
"arithmetic on%select{ a|}0 pointer%select{|s}0 to%select{ the|}2 function "
36133613
"type%select{|s}2 %1%select{| and %3}2 is a GNU extension">,
36143614
InGroup<PointerArith>;
3615-
def error_readonly_property_assignment : Error<
3616-
"assigning to property with 'readonly' attribute not allowed">;
36173615
def error_readonly_message_assignment : Error<
36183616
"assigning to 'readonly' return result of an objective-c message not allowed">;
36193617
def ext_integer_increment_complex : Extension<
36203618
"ISO C does not support '++'/'--' on complex integer type %0">;
36213619
def ext_integer_complement_complex : Extension<
36223620
"ISO C does not support '~' for complex conjugation of %0">;
3623-
def error_nosetter_property_assignment : Error<
3624-
"setter method is needed to assign to object using property" " assignment syntax">;
3621+
def err_nosetter_property_assignment : Error<
3622+
"%select{assignment to readonly property|"
3623+
"no setter method %1 for assignment to property}0">;
3624+
def err_nosetter_property_incdec : Error<
3625+
"%select{%select{increment|decrement}1 of readonly property|"
3626+
"no setter method %2 for %select{increment|decrement}1 of property}0">;
3627+
def err_nogetter_property_compound_assignment : Error<
3628+
"a getter method is needed to perform a compound assignment on a property">;
3629+
def err_nogetter_property_incdec : Error<
3630+
"no getter method %1 for %select{increment|decrement} of property">;
36253631
def error_no_subobject_property_setting : Error<
36263632
"expression is not assignable">;
36273633
def err_qualified_objc_access : Error<

clang/include/clang/Sema/Sema.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5319,6 +5319,8 @@ class Sema {
53195319
ObjCMethodDecl *LookupMethodInQualifiedType(Selector Sel,
53205320
const ObjCObjectPointerType *OPT,
53215321
bool IsInstance);
5322+
ObjCMethodDecl *LookupMethodInObjectType(Selector Sel, QualType Ty,
5323+
bool IsInstance);
53225324

53235325
bool inferObjCARCLifetime(ValueDecl *decl);
53245326

@@ -5777,10 +5779,13 @@ class Sema {
57775779
// For compound assignment, pass both expressions and the converted type.
57785780
QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
57795781
Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType);
5780-
5781-
void ConvertPropertyForLValue(ExprResult &LHS, ExprResult &RHS,
5782-
QualType& LHSTy);
5783-
ExprResult ConvertPropertyForRValue(Expr *E);
5782+
5783+
ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc,
5784+
UnaryOperatorKind Opcode, Expr *Op);
5785+
ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc,
5786+
BinaryOperatorKind Opcode,
5787+
Expr *LHS, Expr *RHS);
5788+
ExprResult checkPseudoObjectRValue(Expr *E);
57845789

57855790
QualType CheckConditionalOperands( // C99 6.5.15
57865791
ExprResult &Cond, ExprResult &LHS, ExprResult &RHS,

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,9 @@ namespace clang {
556556
/// \brief The OpenCL 'half' / ARM NEON __fp16 type.
557557
PREDEF_TYPE_HALF_ID = 33,
558558
/// \brief ARC's unbridged-cast placeholder type.
559-
PREDEF_TYPE_ARC_UNBRIDGED_CAST = 34
559+
PREDEF_TYPE_ARC_UNBRIDGED_CAST = 34,
560+
/// \brief The pseudo-object placeholder type.
561+
PREDEF_TYPE_PSEUDO_OBJECT = 35
560562
};
561563

562564
/// \brief The number of predefined type IDs that are reserved for

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target) {
461461
// Placeholder type for bound members.
462462
InitBuiltinType(BoundMemberTy, BuiltinType::BoundMember);
463463

464+
// Placeholder type for pseudo-objects.
465+
InitBuiltinType(PseudoObjectTy, BuiltinType::PseudoObject);
466+
464467
// "any" type; useful for debugger-like clients.
465468
InitBuiltinType(UnknownAnyTy, BuiltinType::UnknownAny);
466469

clang/lib/AST/Type.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,7 @@ const char *BuiltinType::getName(const PrintingPolicy &Policy) const {
14931493
case NullPtr: return "nullptr_t";
14941494
case Overload: return "<overloaded function type>";
14951495
case BoundMember: return "<bound member function type>";
1496+
case PseudoObject: return "<pseudo-object type>";
14961497
case Dependent: return "<dependent type>";
14971498
case UnknownAny: return "<unknown type>";
14981499
case ARCUnbridgedCast: return "<ARC unbridged cast type>";

clang/lib/AST/TypeLoc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
238238
case BuiltinType::BoundMember:
239239
case BuiltinType::UnknownAny:
240240
case BuiltinType::ARCUnbridgedCast:
241+
case BuiltinType::PseudoObject:
241242
case BuiltinType::ObjCId:
242243
case BuiltinType::ObjCClass:
243244
case BuiltinType::ObjCSel:

0 commit comments

Comments
 (0)