mstorsjo created this revision.
mstorsjo added a reviewer: bkramer.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang.

This fixes the following warning:

  In file included from 
../tools/clang/lib/Tooling/Transformer/Transformer.cpp:9:
  ../tools/clang/include/clang/Tooling/Transformer/Transformer.h: In 
instantiation of ‘llvm::Error clang::tooling::detail::populateMetadata(const 
clang::transformer::RewriteRuleWith<MetadataT>&, size_t, const 
clang::ast_matchers::MatchFinder::MatchResult&, 
clang::tooling::TransformerResult<T>&) [with T = void; size_t = long unsigned 
int]’:
  ../tools/clang/include/clang/Tooling/Transformer/Transformer.h:179:34:   
required from ‘void 
clang::tooling::detail::WithMetadataImpl<T>::onMatchImpl(const 
clang::ast_matchers::MatchFinder::MatchResult&) [with T = void]’
  ../tools/clang/include/clang/Tooling/Transformer/Transformer.h:156:8:   
required from here
  ../tools/clang/include/clang/Tooling/Transformer/Transformer.h:120:25: 
warning: parameter ‘SelectedCase’ set but not used [-Wunused-but-set-parameter]
    120 |                  size_t SelectedCase,
        |                  ~~~~~~~^~~~~~~~~~~~

The issue is fixed in GCC 10 and later, but this silences the noisy
warning in older versions. See 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827
for more details about the bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132920

Files:
  clang/include/clang/Tooling/Transformer/Transformer.h


Index: clang/include/clang/Tooling/Transformer/Transformer.h
===================================================================
--- clang/include/clang/Tooling/Transformer/Transformer.h
+++ clang/include/clang/Tooling/Transformer/Transformer.h
@@ -120,6 +120,11 @@
                  size_t SelectedCase,
                  const ast_matchers::MatchFinder::MatchResult &Match,
                  TransformerResult<T> &Result) {
+  // Silence a false positive GCC -Wunused-but-set-parameter warning in 
constexpr
+  // cases, by marking SelectedCase as used. See
+  // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827 for details. The issue 
is
+  // fixed in GCC 10.
+  (void)SelectedCase;
   if constexpr (!std::is_void_v<T>) {
     auto Metadata = Rule.Metadata[SelectedCase]->eval(Match);
     if (!Metadata)


Index: clang/include/clang/Tooling/Transformer/Transformer.h
===================================================================
--- clang/include/clang/Tooling/Transformer/Transformer.h
+++ clang/include/clang/Tooling/Transformer/Transformer.h
@@ -120,6 +120,11 @@
                  size_t SelectedCase,
                  const ast_matchers::MatchFinder::MatchResult &Match,
                  TransformerResult<T> &Result) {
+  // Silence a false positive GCC -Wunused-but-set-parameter warning in constexpr
+  // cases, by marking SelectedCase as used. See
+  // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827 for details. The issue is
+  // fixed in GCC 10.
+  (void)SelectedCase;
   if constexpr (!std::is_void_v<T>) {
     auto Metadata = Rule.Metadata[SelectedCase]->eval(Match);
     if (!Metadata)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to