diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-04 23:43:03 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-04 23:43:03 +0000 |
commit | 6b2d47d8299ffd74c4418936da2322ce988340f5 (patch) | |
tree | 03f5ef2b90816eccb0076519ab5a3621e4d3fa8b /clang/lib/ARCMigrate/Transforms.cpp | |
parent | b0a48e1dd808fb95d46cc3f80089ea3b08a49ed6 (diff) | |
download | bcm5719-llvm-6b2d47d8299ffd74c4418936da2322ce988340f5.tar.gz bcm5719-llvm-6b2d47d8299ffd74c4418936da2322ce988340f5.zip |
[arcmt] In GC, error out when there is a call that returns a pointer to
GC managed non-objc object memory.
llvm-svn: 143747
Diffstat (limited to 'clang/lib/ARCMigrate/Transforms.cpp')
-rw-r--r-- | clang/lib/ARCMigrate/Transforms.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/ARCMigrate/Transforms.cpp b/clang/lib/ARCMigrate/Transforms.cpp index 0decdd6b43b..d0c9bc69c85 100644 --- a/clang/lib/ARCMigrate/Transforms.cpp +++ b/clang/lib/ARCMigrate/Transforms.cpp @@ -324,6 +324,26 @@ MigrationContext::~MigrationContext() { delete *I; } +bool MigrationContext::isGCOwnedNonObjC(QualType T) { + while (!T.isNull()) { + if (const AttributedType *AttrT = T->getAs<AttributedType>()) { + if (AttrT->getAttrKind() == AttributedType::attr_objc_ownership) + return !AttrT->getModifiedType()->isObjCRetainableType(); + } + + if (T->isArrayType()) + T = Pass.Ctx.getBaseElementType(T); + else if (const PointerType *PT = T->getAs<PointerType>()) + T = PT->getPointeeType(); + else if (const ReferenceType *RT = T->getAs<ReferenceType>()) + T = RT->getPointeeType(); + else + break; + } + + return false; +} + void MigrationContext::traverse(TranslationUnitDecl *TU) { ASTTransform(*this).TraverseDecl(TU); } |