aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-01-13 23:34:40 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-01-13 23:34:40 +0000
commitfa23c1d9adc99c662c1c0e192817185809d95614 (patch)
treefc7c185464569aec220f1ad5331955d880e5d36b /lib/AST/ASTContext.cpp
parent28396608ec20d44e9d1470e1ea51689bb504d0de (diff)
Implemenent objective-c's NSObject attribute as a way of ddeclaraing c-type
objects as an objective-c object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62197 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index b5487565ae..c64c1010be 100644
--- a/lib/AST/ASTContext.cpp
+++ b/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);
}
//===----------------------------------------------------------------------===//