[all-commits] [llvm/llvm-project] 460fc4: [Clang] -Wunused-but-set-variable warning - handle...

Dávid Bolvanský via All-commits all-commits at lists.llvm.org
Wed Mar 23 14:05:50 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 460fc440ad8d41ca2e3882987512989b1c188fbe
      https://github.com/llvm/llvm-project/commit/460fc440ad8d41ca2e3882987512989b1c188fbe
  Author: Dávid Bolvanský <david.bolvansky at gmail.com>
  Date:   2022-03-23 (Wed, 23 Mar 2022)

  Changed paths:
    M clang/lib/Sema/SemaExprCXX.cpp
    M clang/test/Sema/warn-unused-but-set-variables.c
    M clang/test/SemaCXX/warn-unused-but-set-variables-cpp.cpp

  Log Message:
  -----------
  [Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators

Clang fails to diagnose:
```
void test() {
    int j = 0;
    for (int i = 0; i < 1000; i++)
            j++;
    return;
}
```

Reason: Missing support for UnaryOperator.

We should not warn with volatile variables... so add check for it.

Reviewed By: efriedma

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




More information about the All-commits mailing list