r214735 - Fix crash when accessing a property of an invalid interface
Olivier Goffart
ogoffart at woboq.com
Mon Aug 4 10:28:12 PDT 2014
Author: ogoffart
Date: Mon Aug 4 12:28:11 2014
New Revision: 214735
URL: http://llvm.org/viewvc/llvm-project?rev=214735&view=rev
Log:
Fix crash when accessing a property of an invalid interface
Modified:
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/test/SemaObjCXX/property-invalid-type.mm
Modified: cfe/trunk/lib/Sema/SemaPseudoObject.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaPseudoObject.cpp?rev=214735&r1=214734&r2=214735&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/trunk/lib/Sema/SemaPseudoObject.cpp Mon Aug 4 12:28:11 2014
@@ -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(b
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::DiagnoseUnsu
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::rebuildAndC
/// 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::buildG
/// 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();
Modified: cfe/trunk/test/SemaObjCXX/property-invalid-type.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/property-invalid-type.mm?rev=214735&r1=214734&r2=214735&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/property-invalid-type.mm (original)
+++ cfe/trunk/test/SemaObjCXX/property-invalid-type.mm Mon Aug 4 12:28:11 2014
@@ -7,6 +7,7 @@
@end
@interface I ()
@property A* response; // expected-error {{unknown type name 'A'}}
+ at property int helper;
@end
@implementation I
@synthesize response;
@@ -16,4 +17,7 @@
}
@end
-
+void foo(I *i)
+{
+ i.helper;
+}
More information about the cfe-commits
mailing list