[cfe-commits] r45561 - in /cfe/trunk: Sema/Sema.cpp Sema/Sema.h Sema/SemaExpr.cpp Sema/SemaStmt.cpp include/clang/Basic/DiagnosticKinds.def test/Parser/objc-forcollection-1.m test/Parser/objc-forcollection-neg.m
fjahanian
fjahanian at apple.com
Fri Jan 4 16:03:21 PST 2008
On Jan 4, 2008, at 3:05 PM, Chris Lattner wrote:
>>
> hi Fariborz,
>
>> +bool Sema::isObjcObjectPointerType(QualType type) const {
>> + if (!type->isPointerType() && !type->isObjcQualifiedIdType())
>> + return false;
>> + if (type == Context.getObjcIdType() || type ==
>> Context.getObjcClassType() ||
>> + type->isObjcQualifiedIdType())
>> + return true;
>> +
>> + while (type->isPointerType()) {
>> + PointerType *pointerType = static_cast<PointerType*>
>> (type.getTypePtr());
>> + type = pointerType->getPointeeType();
>> + }
>> + return (type->isObjcInterfaceType() || type-
>> >isObjcQualifiedIdType());
>
> This accepts Interface**** ?
Yes. I tried to follow gcc's (which is also my implementation :). But
this may be too generous. I will have to talk to Blaine to see if I
can confine this to just top-level object pointer.
>
>> --- cfe/trunk/Sema/Sema.h (original)
>> +++ cfe/trunk/Sema/Sema.h Thu Jan 3 18:27:46 2008
>> +
>> + /// isObjcObjectPointerType - Returns tru if type is an
>> objective-c pointer
>
> tru -> true.
>> +++ cfe/trunk/Sema/SemaExpr.cpp Thu Jan 3 18:27:46 2008
>> @@ -2350,8 +2350,7 @@
>> return true;
>> }
>> } else {
>> - bool receiverIsQualId =
>> - dyn_cast<ObjcQualifiedIdType>(RExpr->getType()) != 0;
>> + bool receiverIsQualId = dyn_cast<ObjcQualifiedIdType>
>> (receiverType) != 0;
>
> Please use:
> bool receiverIsQualId = isa<ObjcQualifiedIdType>(receiverType);
>
> instead of dyn_cast.
>
>> =====================================================================
>> =========
>> --- cfe/trunk/Sema/SemaStmt.cpp (original)
>> +++ cfe/trunk/Sema/SemaStmt.cpp Thu Jan 3 18:27:46 2008
>> @@ -538,8 +538,9 @@
>> Stmt *First = static_cast<Stmt*>(first);
>> Expr *Second = static_cast<Expr*>(second);
>> Stmt *Body = static_cast<Stmt*>(body);
>> -
>> + QualType FirstType;
>> if (DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
>> + FirstType = dyn_cast<ValueDecl>(DS->getDecl())->getType();
>
> Do you know that DS->getDecl() is a valuedecl? If so, use cast<>
> not dyn_cast<>. If you don't know that it is, you have to check
> for a null pointer.
Yes. I used cast<>.
>
>> @@ -547,19 +548,21 @@
>> if (BVD && !BVD->hasLocalStorage())
>> BVD = 0;
>> if (BVD == 0)
>> + return Diag(dyn_cast<ScopedDecl>(D)->getLocation(),
>
> Likewise, use cast if you know it is a ScopedDecl. cast is more
> efficient than dyn_cast.
Ditto.
- Fariborz
>
> Thanks!
>
> -Chris
More information about the cfe-commits
mailing list