[PATCH] D53456: [Sema] Do not show unused parameter warnings when body is skipped

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 24 01:31:44 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC345122: [Sema] Do not show unused parameter warnings when body is skipped (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53456?vs=170268&id=170827#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53456

Files:
  lib/Sema/SemaDecl.cpp
  test/Index/skipped-bodies-unused.cpp


Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13037,7 +13037,7 @@
 
     if (!FD->isInvalidDecl()) {
       // Don't diagnose unused parameters of defaulted or deleted functions.
-      if (!FD->isDeleted() && !FD->isDefaulted())
+      if (!FD->isDeleted() && !FD->isDefaulted() && !FD->hasSkippedBody())
         DiagnoseUnusedParameters(FD->parameters());
       DiagnoseSizeOfParametersAndReturnValue(FD->parameters(),
                                              FD->getReturnType(), FD);
@@ -13132,7 +13132,8 @@
     assert(MD == getCurMethodDecl() && "Method parsing confused");
     MD->setBody(Body);
     if (!MD->isInvalidDecl()) {
-      DiagnoseUnusedParameters(MD->parameters());
+      if (!MD->hasSkippedBody())
+        DiagnoseUnusedParameters(MD->parameters());
       DiagnoseSizeOfParametersAndReturnValue(MD->parameters(),
                                              MD->getReturnType(), MD);
 
Index: test/Index/skipped-bodies-unused.cpp
===================================================================
--- test/Index/skipped-bodies-unused.cpp
+++ test/Index/skipped-bodies-unused.cpp
@@ -0,0 +1,8 @@
+// RUN: env CINDEXTEST_SKIP_FUNCTION_BODIES=1 c-index-test -test-load-source all %s -Wunused-parameter 2>&1 \
+// RUN: | FileCheck %s
+
+// No 'unused parameter' warnings should be shown when skipping the function bodies.
+inline int foo(int used, int unused) {
+    used = 100;
+}
+// CHECK-NOT: warning: unused parameter


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53456.170827.patch
Type: text/x-patch
Size: 1561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181024/bc40c33b/attachment-0001.bin>


More information about the cfe-commits mailing list