diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-13 23:34:40 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-13 23:34:40 +0000 |
| commit | 255c0958ddc2d06c61160ea654260f146e79092e (patch) | |
| tree | 6df78f6933ce20eae1c2cf0d851c40ef3dd45505 /clang/lib/AST | |
| parent | a63bede3c6f6560e32c18b9917905db61bba3c98 (diff) | |
| download | bcm5719-llvm-255c0958ddc2d06c61160ea654260f146e79092e.tar.gz bcm5719-llvm-255c0958ddc2d06c61160ea654260f146e79092e.zip | |
Implemenent objective-c's NSObject attribute as a way of ddeclaraing c-type
objects as an objective-c object.
llvm-svn: 62197
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b5487565ae7..c64c1010bee 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2078,6 +2078,19 @@ QualType ASTContext::getFromTargetType(unsigned Type) const { // Type Predicates. //===----------------------------------------------------------------------===// +/// isObjCNSObjectType - Return true if this is an NSObject object using +/// NSObject attribute on a c-style pointer type. +/// FIXME - Make it work directly on types. +/// +bool ASTContext::isObjCNSObjectType(QualType Ty) const { + if (TypedefType *TDT = dyn_cast<TypedefType>(Ty)) { + if (TypedefDecl *TD = TDT->getDecl()) + if (TD->getAttr<ObjCNSObjectAttr>()) + return true; + } + return false; +} + /// isObjCObjectPointerType - Returns true if type is an Objective-C pointer /// to an object type. This includes "id" and "Class" (two 'special' pointers /// to struct), Interface* (pointer to ObjCInterfaceType) and id<P> (qualified @@ -2101,7 +2114,11 @@ bool ASTContext::isObjCObjectPointerType(QualType Ty) const { return true; // If this a pointer to an interface (e.g. NSString*), it is ok. - return Ty->getAsPointerType()->getPointeeType()->isObjCInterfaceType(); + if (Ty->getAsPointerType()->getPointeeType()->isObjCInterfaceType()) + return true; + + // If is has NSObject attribute, OK as well. + return isObjCNSObjectType(Ty); } //===----------------------------------------------------------------------===// |

