diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2015-01-20 16:53:34 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2015-01-20 16:53:34 +0000 |
commit | 86dd4565ecedf4d8396cfe2a394f49216463f08e (patch) | |
tree | 97fbb3806b6a9c16aa6bbbf4366140c78a4c3b98 /clang/lib/Sema/SemaExprObjC.cpp | |
parent | 45f7f9c1abc90ad9fd90012993b45a6fc6dec0f7 (diff) | |
download | bcm5719-llvm-86dd4565ecedf4d8396cfe2a394f49216463f08e.tar.gz bcm5719-llvm-86dd4565ecedf4d8396cfe2a394f49216463f08e.zip |
Patch fixes PR21932 crash on invalid code. Using
property-dot syntax on 'super' with no super
class. Patch by Jason Haslam.
llvm-svn: 226578
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 9c3b51c623d..8bdd18ea20e 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -1751,29 +1751,30 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, IsSuper = true; if (ObjCMethodDecl *CurMethod = tryCaptureObjCSelf(receiverNameLoc)) { - if (CurMethod->isInstanceMethod()) { - ObjCInterfaceDecl *Super = - CurMethod->getClassInterface()->getSuperClass(); - if (!Super) { - // The current class does not have a superclass. - Diag(receiverNameLoc, diag::error_root_class_cannot_use_super) - << CurMethod->getClassInterface()->getIdentifier(); - return ExprError(); + if (ObjCInterfaceDecl *Class = CurMethod->getClassInterface()) { + if (CurMethod->isInstanceMethod()) { + ObjCInterfaceDecl *Super = Class->getSuperClass(); + if (!Super) { + // The current class does not have a superclass. + Diag(receiverNameLoc, diag::error_root_class_cannot_use_super) + << Class->getIdentifier(); + return ExprError(); + } + QualType T = Context.getObjCInterfaceType(Super); + T = Context.getObjCObjectPointerType(T); + + return HandleExprPropertyRefExpr(T->getAsObjCInterfacePointerType(), + /*BaseExpr*/nullptr, + SourceLocation()/*OpLoc*/, + &propertyName, + propertyNameLoc, + receiverNameLoc, T, true); } - QualType T = Context.getObjCInterfaceType(Super); - T = Context.getObjCObjectPointerType(T); - - return HandleExprPropertyRefExpr(T->getAsObjCInterfacePointerType(), - /*BaseExpr*/nullptr, - SourceLocation()/*OpLoc*/, - &propertyName, - propertyNameLoc, - receiverNameLoc, T, true); - } - // Otherwise, if this is a class method, try dispatching to our - // superclass. - IFace = CurMethod->getClassInterface()->getSuperClass(); + // Otherwise, if this is a class method, try dispatching to our + // superclass. + IFace = Class->getSuperClass(); + } } } |