summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-04-18 19:13:23 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-04-18 19:13:23 +0000
commita2c91e75c944e3599fb108db600f91c47c8b4342 (patch)
tree092909ccfde13672ccdb7764d5396c63575db358 /lib
parent0ddb097bb02ddee8f1924ee4fcca384cb18ad8c5 (diff)
objective-c: Issue diagnostic when an implicit
property accessor (getter) missing, instead of crashing. // rdar://11273060 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155036 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaPseudoObject.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp
index 3a54876771..0e6632964a 100644
--- a/lib/Sema/SemaPseudoObject.cpp
+++ b/lib/Sema/SemaPseudoObject.cpp
@@ -214,6 +214,7 @@ namespace {
ObjCMethodDecl *Setter;
Selector SetterSelector;
+ Selector GetterSelector;
public:
ObjCPropertyOpBuilder(Sema &S, ObjCPropertyRefExpr *refExpr) :
@@ -475,8 +476,24 @@ bool ObjCPropertyOpBuilder::findGetter() {
// For implicit properties, just trust the lookup we already did.
if (RefExpr->isImplicitProperty()) {
- Getter = RefExpr->getImplicitPropertyGetter();
- return (Getter != 0);
+ if ((Getter = RefExpr->getImplicitPropertyGetter())) {
+ GetterSelector = Getter->getSelector();
+ return true;
+ }
+ else {
+ // Must build the getter selector the hard way.
+ ObjCMethodDecl *setter = RefExpr->getImplicitPropertySetter();
+ assert(setter && "both setter and getter are null - cannot happen");
+ IdentifierInfo *setterName =
+ setter->getSelector().getIdentifierInfoForSlot(0);
+ const char *compStr = setterName->getNameStart();
+ compStr += 3;
+ IdentifierInfo *getterName = &S.Context.Idents.get(compStr);
+ GetterSelector =
+ S.PP.getSelectorTable().getNullarySelector(getterName);
+ return false;
+
+ }
}
ObjCPropertyDecl *prop = RefExpr->getExplicitProperty();
@@ -776,7 +793,7 @@ ObjCPropertyOpBuilder::buildIncDecOperation(Scope *Sc, SourceLocation opcLoc,
assert(RefExpr->isImplicitProperty());
S.Diag(opcLoc, diag::err_nogetter_property_incdec)
<< unsigned(UnaryOperator::isDecrementOp(opcode))
- << RefExpr->getImplicitPropertyGetter()->getSelector() // FIXME!
+ << GetterSelector
<< op->getSourceRange();
return ExprError();
}