summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2014-08-05 05:19:37 +0000
committerBill Wendling <isanbard@gmail.com>2014-08-05 05:19:37 +0000
commit3e24ceaa26f9e1cbd67fdc8625f07bfcc9977053 (patch)
tree1a21ec0e6e1f2f877dbd91d2fd7b3b7e1db13888
parent38aafa842843e746db067b480318b30aae45c949 (diff)
Merging r214735:
------------------------------------------------------------------------ r214735 | ogoffart | 2014-08-04 10:28:11 -0700 (Mon, 04 Aug 2014) | 1 line Fix crash when accessing a property of an invalid interface ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_35@214840 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaPseudoObject.cpp22
-rw-r--r--test/SemaObjCXX/property-invalid-type.mm6
2 files changed, 15 insertions, 13 deletions
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp
index fac7774734..aa3e89ed67 100644
--- a/lib/Sema/SemaPseudoObject.cpp
+++ b/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();
diff --git a/test/SemaObjCXX/property-invalid-type.mm b/test/SemaObjCXX/property-invalid-type.mm
index e249ace3d2..5b8a848df4 100644
--- a/test/SemaObjCXX/property-invalid-type.mm
+++ b/test/SemaObjCXX/property-invalid-type.mm
@@ -7,6 +7,7 @@
@end
@interface I ()
@property A* response; // expected-error {{unknown type name 'A'}}
+@property int helper;
@end
@implementation I
@synthesize response;
@@ -16,4 +17,7 @@
}
@end
-
+void foo(I *i)
+{
+ i.helper;
+}