summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-08-22 16:57:26 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-08-22 16:57:26 +0000
commit78e9debf68d4a2b7ae27fddf7665c8bd9638b6dc (patch)
tree8618f9b4146041d295126681727d7f546563572b /clang/lib/Sema/SemaExprObjC.cpp
parentefd1375f2a441f759a9b6afc8df2802bb2e47291 (diff)
downloadbcm5719-llvm-78e9debf68d4a2b7ae27fddf7665c8bd9638b6dc.tar.gz
bcm5719-llvm-78e9debf68d4a2b7ae27fddf7665c8bd9638b6dc.zip
Objective-C. Warn if user has made explicit call
to +initilize as this results in an extra call to this method. rdar://16628028 llvm-svn: 216271
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaExprObjC.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 582e1834d48..cbf41b5069a 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -1137,6 +1137,7 @@ ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
case OMF_mutableCopy:
case OMF_new:
case OMF_self:
+ case OMF_initialize:
case OMF_performSelector:
break;
}
@@ -2230,6 +2231,17 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
RequireCompleteType(LBracLoc, Method->getReturnType(),
diag::err_illegal_message_expr_incomplete_type))
return ExprError();
+
+ // Warn about explicit call of +initialize on its own class.
+ if (Method && Method->getMethodFamily() == OMF_initialize) {
+ const ObjCInterfaceDecl *ID =
+ dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext());
+ if (ID == Class) {
+ Diag(Loc, diag::warn_direct_initialize_call);
+ Diag(Method->getLocation(), diag::note_method_declared_at)
+ << Method->getDeclName();
+ }
+ }
// Construct the appropriate ObjCMessageExpr.
ObjCMessageExpr *Result;
@@ -2652,6 +2664,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
case OMF_mutableCopy:
case OMF_new:
case OMF_self:
+ case OMF_initialize:
break;
case OMF_dealloc:
OpenPOWER on IntegriCloud