Tweak -Wobjc-missing-super-calls to not warning about missing [super dealloc] when in GC-only mode, and to not warning about missing [super finalize] when not using GC.

llvm-svn: 140713
This commit is contained in:
Ted Kremenek 2011-09-28 19:32:29 +00:00
parent 3714065a94
commit 3f443a71dc
2 changed files with 13 additions and 4 deletions

View File

@ -335,10 +335,11 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
// Only do this if the current class actually has a superclass.
if (IC->getSuperClass()) {
ObjCShouldCallSuperDealloc =
!Context.getLangOptions().ObjCAutoRefCount &&
!(Context.getLangOptions().ObjCAutoRefCount ||
Context.getLangOptions().getGC() == LangOptions::GCOnly) &&
MDecl->getMethodFamily() == OMF_dealloc;
ObjCShouldCallSuperFinalize =
!Context.getLangOptions().ObjCAutoRefCount &&
Context.getLangOptions().getGC() != LangOptions::NonGC &&
MDecl->getMethodFamily() == OMF_finalize;
}
}

View File

@ -41,8 +41,16 @@
// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
// CHECK: warn-missing-super.m:23:1: warning: method possibly missing a [super dealloc] call
// CHECK: warn-missing-super.m:25:1: warning: method possibly missing a [super finalize] call
// CHECK: 2 warnings generated.
// CHECK: 1 warning generated.
// RUN: %clang_cc1 -fsyntax-only -fobjc-gc %s 2>&1 | FileCheck --check-prefix=CHECK-GC %s
// CHECK-GC: warn-missing-super.m:23:1: warning: method possibly missing a [super dealloc] call
// CHECK-GC: warn-missing-super.m:25:1: warning: method possibly missing a [super finalize] call
// CHECK-GC: 2 warnings generated.
// RUN: %clang_cc1 -fsyntax-only -fobjc-gc-only %s 2>&1 | FileCheck --check-prefix=CHECK-GC-ONLY %s
// CHECK-GC-ONLY: warn-missing-super.m:25:1: warning: method possibly missing a [super finalize] call
// CHECK-GC-ONLY: 1 warning generated.
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-arc %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s
// CHECK-ARC: warn-missing-super.m:35:4: error: ARC forbids explicit message send of 'dealloc'