From: Ted Kremenek Date: Wed, 28 Sep 2011 19:32:29 +0000 (+0000) Subject: Tweak -Wobjc-missing-super-calls to not warning about missing [super dealloc] when... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8cd8de4c0fb5f3e86dbbde5844903136c5e0e046;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140713 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 0822edf704..f1a2637077 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -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; } } diff --git a/test/SemaObjC/warn-missing-super.m b/test/SemaObjC/warn-missing-super.m index c25a691662..5dcdb57292 100644 --- a/test/SemaObjC/warn-missing-super.m +++ b/test/SemaObjC/warn-missing-super.m @@ -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'