[all-commits] [llvm/llvm-project] 9b0501: [Clang] -Wunused-but-set-parameter and -Wunused-bu...

Michael Benfield via All-commits all-commits at lists.llvm.org
Mon Apr 26 15:09:39 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9b0501abc7b515b740fb5ee929817442dd3029a5
      https://github.com/llvm/llvm-project/commit/9b0501abc7b515b740fb5ee929817442dd3029a5
  Author: Michael Benfield <mbenfield at google.com>
  Date:   2021-04-26 (Mon, 26 Apr 2021)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaStmt.cpp
    M clang/test/CodeGen/X86/x86_32-xsave.c
    M clang/test/CodeGen/X86/x86_64-xsave.c
    M clang/test/CodeGen/builtins-arm.c
    M clang/test/CodeGen/builtins-riscv.c
    M clang/test/FixIt/fixit.cpp
    M clang/test/Misc/warning-wall.c
    M clang/test/Sema/shift.c
    M clang/test/Sema/vector-gcc-compat.c
    A clang/test/Sema/warn-unused-but-set-parameters.c
    A clang/test/Sema/warn-unused-but-set-variables.c
    M clang/test/SemaCXX/goto.cpp
    M clang/test/SemaCXX/shift.cpp
    M clang/test/SemaCXX/sizeless-1.cpp
    A clang/test/SemaCXX/warn-unused-but-set-parameters-cpp.cpp
    A clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp
    M clang/test/SemaObjC/foreach.m

  Log Message:
  -----------
  [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

These are intended to mimic warnings available in gcc.

-Wunused-but-set-variable is triggered in the case of a variable which
appears on the LHS of an assignment but not otherwise used.

For instance:

  void f() {
    int x;
    x = 0;
  }

-Wunused-but-set-parameter works similarly, but for function parameters
instead of variables.

In C++, they are triggered only for scalar types; otherwise, they are
triggered for all types. This is gcc's behavior.

-Wunused-but-set-parameter is controlled by -Wextra, while
-Wunused-but-set-variable is controlled by -Wunused. This is slightly
different from gcc's behavior, but seems most consistent with clang's
behavior for -Wunused-parameter and -Wunused-variable.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D100581




More information about the All-commits mailing list