[PATCH] D61147: [Sema][ObjC] Disable -Wunused-parameter for ObjC methods

2019-05-03 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359864: [Sema][ObjC] Disable -Wunused-parameter for ObjC 
methods (authored by ahatanak, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61147?vs=197469=197924#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61147/new/

https://reviews.llvm.org/D61147

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaObjC/method-unused-attribute.m
  cfe/trunk/test/SemaObjC/unused.m


Index: cfe/trunk/test/SemaObjC/unused.m
===
--- cfe/trunk/test/SemaObjC/unused.m
+++ cfe/trunk/test/SemaObjC/unused.m
@@ -33,7 +33,7 @@
   // expected-note {{introduce a parameter name to make 
'x' part of the selector}} \
   // expected-note {{or insert whitespace before ':' to 
use 'x' as parameter name and have an empty entry in the selector}}
 
-(int)y:  // expected-warning {{unused}}  expected-warning {{'y' used as the 
name of the previous parameter rather than as part of the selector}} \
+(int)y:  // expected-warning {{'y' used as the name of the previous parameter 
rather than as part of the selector}} \
  // expected-note {{introduce a parameter name to make 'y' part of the 
selector}} \
  // expected-note {{or insert whitespace before ':' to use 'y' as 
parameter name and have an empty entry in the selector}}
 (int) __attribute__((unused))z { return x; }
Index: cfe/trunk/test/SemaObjC/method-unused-attribute.m
===
--- cfe/trunk/test/SemaObjC/method-unused-attribute.m
+++ cfe/trunk/test/SemaObjC/method-unused-attribute.m
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1  -fsyntax-only -Wunused-parameter -verify 
-Wno-objc-root-class %s
 
+// -Wunused-parameter ignores ObjC method parameters that are unused.
+
+// expected-no-diagnostics
+
 @interface INTF
 - (void) correct_use_of_unused: (void *) notice : (id)another_arg;
 - (void) will_warn_unused_arg: (void *) notice : (id)warn_unused;
@@ -9,7 +13,7 @@
 @implementation INTF
 - (void) correct_use_of_unused: (void *)  __attribute__((unused)) notice : 
(id) __attribute__((unused)) newarg{
 }
-- (void) will_warn_unused_arg: (void *) __attribute__((unused))  notice : 
(id)warn_unused {}  // expected-warning {{unused parameter 'warn_unused'}}
-- (void) unused_attr_on_decl_ignored: (void *)  will_warn{}  // 
expected-warning {{unused parameter 'will_warn'}}
+- (void) will_warn_unused_arg: (void *) __attribute__((unused))  notice : 
(id)warn_unused {}
+- (void) unused_attr_on_decl_ignored: (void *)  will_warn{}
 @end
 
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -13353,8 +13353,6 @@
 assert(MD == getCurMethodDecl() && "Method parsing confused");
 MD->setBody(Body);
 if (!MD->isInvalidDecl()) {
-  if (!MD->hasSkippedBody())
-DiagnoseUnusedParameters(MD->parameters());
   DiagnoseSizeOfParametersAndReturnValue(MD->parameters(),
  MD->getReturnType(), MD);
 


Index: cfe/trunk/test/SemaObjC/unused.m
===
--- cfe/trunk/test/SemaObjC/unused.m
+++ cfe/trunk/test/SemaObjC/unused.m
@@ -33,7 +33,7 @@
   // expected-note {{introduce a parameter name to make 'x' part of the selector}} \
   // expected-note {{or insert whitespace before ':' to use 'x' as parameter name and have an empty entry in the selector}}
 
-(int)y:  // expected-warning {{unused}}  expected-warning {{'y' used as the name of the previous parameter rather than as part of the selector}} \
+(int)y:  // expected-warning {{'y' used as the name of the previous parameter rather than as part of the selector}} \
  // expected-note {{introduce a parameter name to make 'y' part of the selector}} \
  // expected-note {{or insert whitespace before ':' to use 'y' as parameter name and have an empty entry in the selector}}
 (int) __attribute__((unused))z { return x; }
Index: cfe/trunk/test/SemaObjC/method-unused-attribute.m
===
--- cfe/trunk/test/SemaObjC/method-unused-attribute.m
+++ cfe/trunk/test/SemaObjC/method-unused-attribute.m
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1  -fsyntax-only -Wunused-parameter -verify -Wno-objc-root-class %s
 
+// -Wunused-parameter ignores ObjC method parameters that are unused.
+
+// expected-no-diagnostics
+
 @interface INTF
 - (void) correct_use_of_unused: (void *) notice : (id)another_arg;
 - (void) will_warn_unused_arg: (void *) notice : (id)warn_unused;
@@ -9,7 +13,7 @@
 @implementation INTF
 - (void) correct_use_of_unused: (void *) 

[PATCH] D61147: [Sema][ObjC] Disable -Wunused-parameter for ObjC methods

2019-04-30 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D61147#1479932 , @rjmccall wrote:

> I would also recommend that you go fix the warning to never fire on virtual 
> C++ methods.


I tried building clang/llvm with  -Wunused-parameter turned on and there are 
lots of places where parameters are unused other than virtual functions, in 
particular template functions and non-template functions that are called by 
other template functions. So disabling the warning on C++ virtual functions is 
probably not enough in order to make this warning more useful.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61147/new/

https://reviews.llvm.org/D61147



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61147: [Sema][ObjC] Disable -Wunused-parameter for ObjC methods

2019-04-30 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61147/new/

https://reviews.llvm.org/D61147



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61147: [Sema][ObjC] Disable -Wunused-parameter for ObjC methods

2019-04-30 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 197469.
ahatanak retitled this revision from "[Sema][ObjC] Add a flavor of 
-Wunused-parameter that doesn't diagnose unused parameters of ObjC methods" to 
"[Sema][ObjC] Disable -Wunused-parameter for ObjC methods".
ahatanak edited the summary of this revision.
ahatanak added a comment.

Disable the warning for ObjC methods.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61147/new/

https://reviews.llvm.org/D61147

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaObjC/method-unused-attribute.m
  test/SemaObjC/unused.m


Index: test/SemaObjC/unused.m
===
--- test/SemaObjC/unused.m
+++ test/SemaObjC/unused.m
@@ -33,7 +33,7 @@
   // expected-note {{introduce a parameter name to make 
'x' part of the selector}} \
   // expected-note {{or insert whitespace before ':' to 
use 'x' as parameter name and have an empty entry in the selector}}
 
-(int)y:  // expected-warning {{unused}}  expected-warning {{'y' used as the 
name of the previous parameter rather than as part of the selector}} \
+(int)y:  // expected-warning {{'y' used as the name of the previous parameter 
rather than as part of the selector}} \
  // expected-note {{introduce a parameter name to make 'y' part of the 
selector}} \
  // expected-note {{or insert whitespace before ':' to use 'y' as 
parameter name and have an empty entry in the selector}}
 (int) __attribute__((unused))z { return x; }
Index: test/SemaObjC/method-unused-attribute.m
===
--- test/SemaObjC/method-unused-attribute.m
+++ test/SemaObjC/method-unused-attribute.m
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1  -fsyntax-only -Wunused-parameter -verify 
-Wno-objc-root-class %s
 
+// -Wunused-parameter ignores ObjC method parameters that are unused.
+
+// expected-no-diagnostics
+
 @interface INTF
 - (void) correct_use_of_unused: (void *) notice : (id)another_arg;
 - (void) will_warn_unused_arg: (void *) notice : (id)warn_unused;
@@ -9,7 +13,7 @@
 @implementation INTF
 - (void) correct_use_of_unused: (void *)  __attribute__((unused)) notice : 
(id) __attribute__((unused)) newarg{
 }
-- (void) will_warn_unused_arg: (void *) __attribute__((unused))  notice : 
(id)warn_unused {}  // expected-warning {{unused parameter 'warn_unused'}}
-- (void) unused_attr_on_decl_ignored: (void *)  will_warn{}  // 
expected-warning {{unused parameter 'will_warn'}}
+- (void) will_warn_unused_arg: (void *) __attribute__((unused))  notice : 
(id)warn_unused {}
+- (void) unused_attr_on_decl_ignored: (void *)  will_warn{}
 @end
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13354,8 +13354,6 @@
 assert(MD == getCurMethodDecl() && "Method parsing confused");
 MD->setBody(Body);
 if (!MD->isInvalidDecl()) {
-  if (!MD->hasSkippedBody())
-DiagnoseUnusedParameters(MD->parameters());
   DiagnoseSizeOfParametersAndReturnValue(MD->parameters(),
  MD->getReturnType(), MD);
 


Index: test/SemaObjC/unused.m
===
--- test/SemaObjC/unused.m
+++ test/SemaObjC/unused.m
@@ -33,7 +33,7 @@
   // expected-note {{introduce a parameter name to make 'x' part of the selector}} \
   // expected-note {{or insert whitespace before ':' to use 'x' as parameter name and have an empty entry in the selector}}
 
-(int)y:  // expected-warning {{unused}}  expected-warning {{'y' used as the name of the previous parameter rather than as part of the selector}} \
+(int)y:  // expected-warning {{'y' used as the name of the previous parameter rather than as part of the selector}} \
  // expected-note {{introduce a parameter name to make 'y' part of the selector}} \
  // expected-note {{or insert whitespace before ':' to use 'y' as parameter name and have an empty entry in the selector}}
 (int) __attribute__((unused))z { return x; }
Index: test/SemaObjC/method-unused-attribute.m
===
--- test/SemaObjC/method-unused-attribute.m
+++ test/SemaObjC/method-unused-attribute.m
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1  -fsyntax-only -Wunused-parameter -verify -Wno-objc-root-class %s
 
+// -Wunused-parameter ignores ObjC method parameters that are unused.
+
+// expected-no-diagnostics
+
 @interface INTF
 - (void) correct_use_of_unused: (void *) notice : (id)another_arg;
 - (void) will_warn_unused_arg: (void *) notice : (id)warn_unused;
@@ -9,7 +13,7 @@
 @implementation INTF
 - (void) correct_use_of_unused: (void *)  __attribute__((unused)) notice : (id) __attribute__((unused)) newarg{
 }
-- (void) will_warn_unused_arg: (void *) __attribute__((unused))  notice :