[cfe-commits] r168851 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaPseudoObject.cpp test/SemaObjC/error-missing-getter.m test/SemaObjC/property-user-setter.m test/SemaObjCXX/properties.mm
Eli Friedman
eli.friedman at gmail.com
Wed Nov 28 19:13:50 PST 2012
Author: efriedma
Date: Wed Nov 28 21:13:49 2012
New Revision: 168851
URL: http://llvm.org/viewvc/llvm-project?rev=168851&view=rev
Log:
Fix crash-on-invalid. <rdar://problem/12765391>.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/test/SemaObjC/error-missing-getter.m
cfe/trunk/test/SemaObjC/property-user-setter.m
cfe/trunk/test/SemaObjCXX/properties.mm
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=168851&r1=168850&r2=168851&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 28 21:13:49 2012
@@ -4182,7 +4182,7 @@
def err_invalid_property_name : Error<
"%0 is not a valid property name (accessing an object of type %1)">;
def err_getter_not_found : Error<
- "expected getter method not found on object of type %0">;
+ "no getter method for read from property">;
def err_objc_subscript_method_not_found : Error<
"expected method to %select{read|write}1 %select{dictionary|array}2 element not "
"found on object of type %0">;
Modified: cfe/trunk/lib/Sema/SemaPseudoObject.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaPseudoObject.cpp?rev=168851&r1=168850&r2=168851&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/trunk/lib/Sema/SemaPseudoObject.cpp Wed Nov 28 21:13:49 2012
@@ -113,7 +113,7 @@
Expr *rebuildSpecific(ObjCPropertyRefExpr *refExpr) {
// Fortunately, the constraint that we're rebuilding something
// with a base limits the number of cases here.
- assert(refExpr->getBase());
+ assert(refExpr->isObjectReceiver());
if (refExpr->isExplicitProperty()) {
return new (S.Context)
@@ -713,10 +713,9 @@
ExprResult ObjCPropertyOpBuilder::buildRValueOperation(Expr *op) {
// Explicit properties always have getters, but implicit ones don't.
// Check that before proceeding.
- if (RefExpr->isImplicitProperty() &&
- !RefExpr->getImplicitPropertyGetter()) {
+ if (RefExpr->isImplicitProperty() && !RefExpr->getImplicitPropertyGetter()) {
S.Diag(RefExpr->getLocation(), diag::err_getter_not_found)
- << RefExpr->getBase()->getType();
+ << RefExpr->getSourceRange();
return ExprError();
}
Modified: cfe/trunk/test/SemaObjC/error-missing-getter.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/error-missing-getter.m?rev=168851&r1=168850&r2=168851&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/error-missing-getter.m (original)
+++ cfe/trunk/test/SemaObjC/error-missing-getter.m Wed Nov 28 21:13:49 2012
@@ -9,11 +9,34 @@
@end
int func (int arg, Subclass *x) {
- if (x.setterOnly) { // expected-error {{expected getter method not found on object of type 'Subclass *'}}
+ if (x.setterOnly) { // expected-error {{no getter method for read from property}}
x.setterOnly = 1;
}
- func(x.setterOnly + 1, x); // expected-error {{expected getter method not found on object of type 'Subclass *'}}
- int i = x.setterOnly + 1; // expected-error {{expected getter method not found on object of type 'Subclass *'}}
- return x.setterOnly + 1; // expected-error {{expected getter method not found on object of type 'Subclass *'}}
+ func(x.setterOnly + 1, x); // expected-error {{no getter method for read from property}}
+ int i = x.setterOnly + 1; // expected-error {{no getter method for read from property}}
+ return x.setterOnly + 1; // expected-error {{no getter method for read from property}}
}
+// <rdar://problem/12765391>
+
+ at interface TestClass
++ (void) setSetterOnly : (int) arg;
+ at end
+
+int func2 (int arg) {
+ if (TestClass.setterOnly) { // expected-error {{no getter method for read from property}}
+ TestClass.setterOnly = 1;
+ }
+ func(TestClass.setterOnly + 1, x); // expected-error {{no getter method for read from property}}
+ int i = TestClass.setterOnly + 1; // expected-error {{no getter method for read from property}}
+ return TestClass.setterOnly + 1; // expected-error {{no getter method for read from property}}
+}
+
+ at interface Sub : Subclass
+- (int) func3;
+ at end
+ at implementation Sub
+- (int) func3 {
+ return super.setterOnly; // expected-error {{no getter method for read from property}}
+}
+ at end
Modified: cfe/trunk/test/SemaObjC/property-user-setter.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-user-setter.m?rev=168851&r1=168850&r2=168851&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-user-setter.m (original)
+++ cfe/trunk/test/SemaObjC/property-user-setter.m Wed Nov 28 21:13:49 2012
@@ -89,7 +89,7 @@
void f(C *c) {
c.Foo = 17; // OK
- g(c.Foo); // expected-error {{expected getter method not found on object of type 'C *'}}
+ g(c.Foo); // expected-error {{no getter method for read from property}}
}
@@ -132,7 +132,7 @@
self.Pxyz = 0; // expected-error {{synthesized properties 'Pxyz' and 'pxyz' both claim setter 'setPxyz:'}}
self.pxyz = 0; // expected-error {{synthesized properties 'pxyz' and 'Pxyz' both claim setter 'setPxyz:'}}
self.R = 0;
- return self.R; // expected-error {{expected getter method not found on object of type 'rdar11363363 *'}}
+ return self.R; // expected-error {{no getter method for read from property}}
}
@end
Modified: cfe/trunk/test/SemaObjCXX/properties.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/properties.mm?rev=168851&r1=168850&r2=168851&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/properties.mm (original)
+++ cfe/trunk/test/SemaObjCXX/properties.mm Wed Nov 28 21:13:49 2012
@@ -28,7 +28,7 @@
- (int) z;
@end
void test2(Test2 *a) {
- auto y = a.y; // expected-error {{expected getter method not found on object of type 'Test2 *'}}
+ auto y = a.y; // expected-error {{no getter method for read from property}}
auto z = a.z;
}
More information about the cfe-commits
mailing list