diff options
| author | Olivier Goffart <ogoffart@woboq.com> | 2014-08-04 17:28:11 +0000 |
|---|---|---|
| committer | Olivier Goffart <ogoffart@woboq.com> | 2014-08-04 17:28:11 +0000 |
| commit | f6fabcc27bf34d2237749074b85784c95d3be4b5 (patch) | |
| tree | 9252819a9c7beead38ff02ba829b4ced2e89d8a5 /clang/lib/Sema | |
| parent | 4c182c8bb10cb8131389ec1be4b0f9d3e3d03089 (diff) | |
| download | bcm5719-llvm-f6fabcc27bf34d2237749074b85784c95d3be4b5.tar.gz bcm5719-llvm-f6fabcc27bf34d2237749074b85784c95d3be4b5.zip | |
Fix crash when accessing a property of an invalid interface
llvm-svn: 214735
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaPseudoObject.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp index fac7774734c..aa3e89ed67a 100644 --- a/clang/lib/Sema/SemaPseudoObject.cpp +++ b/clang/lib/Sema/SemaPseudoObject.cpp @@ -284,7 +284,7 @@ namespace { bool tryBuildGetOfReference(Expr *op, ExprResult &result); bool findSetter(bool warn=true); bool findGetter(); - bool DiagnoseUnsupportedPropertyUse(); + void DiagnoseUnsupportedPropertyUse(); Expr *rebuildAndCaptureObject(Expr *syntacticBase) override; ExprResult buildGet() override; @@ -642,7 +642,7 @@ bool ObjCPropertyOpBuilder::findSetter(bool warn) { return false; } -bool ObjCPropertyOpBuilder::DiagnoseUnsupportedPropertyUse() { +void ObjCPropertyOpBuilder::DiagnoseUnsupportedPropertyUse() { if (S.getCurLexicalContext()->isObjCContainer() && S.getCurLexicalContext()->getDeclKind() != Decl::ObjCCategoryImpl && S.getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation) { @@ -650,10 +650,8 @@ bool ObjCPropertyOpBuilder::DiagnoseUnsupportedPropertyUse() { S.Diag(RefExpr->getLocation(), diag::err_property_function_in_objc_container); S.Diag(prop->getLocation(), diag::note_property_declare); - return true; } } - return false; } /// Capture the base object of an Objective-C property expression. @@ -679,10 +677,10 @@ Expr *ObjCPropertyOpBuilder::rebuildAndCaptureObject(Expr *syntacticBase) { /// Load from an Objective-C property reference. ExprResult ObjCPropertyOpBuilder::buildGet() { findGetter(); - if (!Getter && DiagnoseUnsupportedPropertyUse()) - return ExprError(); - - assert(Getter); + if (!Getter) { + DiagnoseUnsupportedPropertyUse(); + return ExprError(); + } if (SyntacticRefExpr) SyntacticRefExpr->setIsMessagingGetter(); @@ -720,10 +718,10 @@ ExprResult ObjCPropertyOpBuilder::buildGet() { /// value being set as the value of the property operation. ExprResult ObjCPropertyOpBuilder::buildSet(Expr *op, SourceLocation opcLoc, bool captureSetValueAsResult) { - bool hasSetter = findSetter(false); - if (!hasSetter && DiagnoseUnsupportedPropertyUse()) - return ExprError(); - assert(hasSetter); (void) hasSetter; + if (!findSetter(false)) { + DiagnoseUnsupportedPropertyUse(); + return ExprError(); + } if (SyntacticRefExpr) SyntacticRefExpr->setIsMessagingSetter(); |

