summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-07-30 20:52:48 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-07-30 20:52:48 +0000
commitb7f03c191c316472ab6fc07890fa26fe7f36941b (patch)
treef8d00682ed75424867cf60fb8b0cae4dbcade9a8 /clang/lib
parent63282aefb91f8dbc43a55819c1333353bb317df7 (diff)
downloadbcm5719-llvm-b7f03c191c316472ab6fc07890fa26fe7f36941b.tar.gz
bcm5719-llvm-b7f03c191c316472ab6fc07890fa26fe7f36941b.zip
objective-c arc: ARC IRGen correctly assumes result
type of generated call to super dealloc is 'void' and asserts if user's dealloc is not of 'void type. This rule must be enforced in clang front-end (with a fixit) if this is not the case, instead of asserting in CodeGen. // rdar://11987838 llvm-svn: 160993
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 17c34a239d5..52ca3351500 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -197,7 +197,6 @@ static bool CheckARCMethodDecl(Sema &S, ObjCMethodDecl *method) {
ObjCMethodFamily family = method->getMethodFamily();
switch (family) {
case OMF_None:
- case OMF_dealloc:
case OMF_finalize:
case OMF_retain:
case OMF_release:
@@ -207,6 +206,24 @@ static bool CheckARCMethodDecl(Sema &S, ObjCMethodDecl *method) {
case OMF_performSelector:
return false;
+ case OMF_dealloc:
+ if (!S.Context.hasSameType(method->getResultType(), S.Context.VoidTy)) {
+ SourceRange ResultTypeRange;
+ if (const TypeSourceInfo *ResultTypeInfo
+ = method->getResultTypeSourceInfo())
+ ResultTypeRange = ResultTypeInfo->getTypeLoc().getSourceRange();
+ if (ResultTypeRange.isInvalid())
+ S.Diag(method->getLocation(), diag::error_dealloc_bad_result_type)
+ << method->getResultType()
+ << FixItHint::CreateInsertion(method->getSelectorLoc(0), "(void)");
+ else
+ S.Diag(method->getLocation(), diag::error_dealloc_bad_result_type)
+ << method->getResultType()
+ << FixItHint::CreateReplacement(ResultTypeRange, "void");
+ return true;
+ }
+ return false;
+
case OMF_init:
// If the method doesn't obey the init rules, don't bother annotating it.
if (S.checkInitMethod(method, QualType()))
OpenPOWER on IntegriCloud