diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-23 04:53:18 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-08-23 04:53:18 +0000 |
commit | 4e90bc39f052ea0046d40aebbb42732ad1f21f50 (patch) | |
tree | 2f2fcb62ea720a41475540b1ea0a706eb186b7c2 /lib | |
parent | ea93e40785ffeadfac66b948c95f9490ec26207a (diff) |
Fix undefined behavior: don't call ObjCInterfaceDecl::isArcWeakrefUnavailable
on a null pointer. (This function happens to work for a null 'this' pointer, so
no test.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162427 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaType.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 3e72c2d06f..94ddc239cd 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -3611,11 +3611,12 @@ static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, while (const PointerType *ptr = T->getAs<PointerType>()) T = ptr->getPointeeType(); if (const ObjCObjectPointerType *ObjT = T->getAs<ObjCObjectPointerType>()) { - ObjCInterfaceDecl *Class = ObjT->getInterfaceDecl(); - if (Class->isArcWeakrefUnavailable()) { - S.Diag(AttrLoc, diag::err_arc_unsupported_weak_class); - S.Diag(ObjT->getInterfaceDecl()->getLocation(), - diag::note_class_declared); + if (ObjCInterfaceDecl *Class = ObjT->getInterfaceDecl()) { + if (Class->isArcWeakrefUnavailable()) { + S.Diag(AttrLoc, diag::err_arc_unsupported_weak_class); + S.Diag(ObjT->getInterfaceDecl()->getLocation(), + diag::note_class_declared); + } } } } |