[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 25 04:12:48 PDT 2018


lebedev.ri added a comment.

Please improve test coverage a bit.
`-Wunused-using` is part of `-Wunused`.
And `-Wunused` is part of `-Wall`.
That needs to be tested.

Also, one small test to show that it is not on by default,
and `-Wno-unused-using` actually disables it is needed.



================
Comment at: docs/ReleaseNotes.rst:117
+
+  -Wall now includes the new warning flag `-Wunused-using`, which emits a
+  warning on using statements that are not used. This may result in new
----------------
```
``-Wall``

```


================
Comment at: docs/ReleaseNotes.rst:117
+
+  -Wall now includes the new warning flag `-Wunused-using`, which emits a
+  warning on using statements that are not used. This may result in new
----------------
lebedev.ri wrote:
> ```
> ``-Wall``
> 
> ```
```
``-Wunused-using``
```


================
Comment at: include/clang/Basic/DiagnosticGroups.td:828-829
                 // -Wunused-local-typedefs = -Wunused-local-typedef
+def : DiagGroup<"unused-usings", [UnusedUsing]>;
+                // -Wunused-usings = -Wunused-using
 
----------------
Why? gcc compatibility?


================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:282-284
+def warn_unused_using : Warning<
+  "unused using %0">,
+  InGroup<UnusedUsing>, DefaultIgnore;
----------------
http://en.cppreference.com/w/cpp/keyword/using says that there are multiple flavors.
It may be more friendlier to have more than one single message for all of them. 


================
Comment at: test/SemaCXX/referenced_alias_declaration_1.cpp:1
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wunused-using -verify %s
+
----------------
The svn attribute changes are likely unintentional.


================
Comment at: test/SemaCXX/referenced_alias_declaration_2.cpp:1
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wunused-using -verify %s
+
----------------
The svn attribute changes are likely unintentional.


================
Comment at: test/SemaCXX/referenced_using_all.cpp:1
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wunused-using -verify %s
+
----------------
The svn attribute changes are likely unintentional.


================
Comment at: test/SemaCXX/referenced_using_declaration_1.cpp:1
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wunused-using -verify %s
+
----------------
The svn attribute changes are likely unintentional.


================
Comment at: test/SemaCXX/referenced_using_declaration_2.cpp:1
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wunused-using -verify %s
+
----------------
The svn attribute changes are likely unintentional.


================
Comment at: test/SemaCXX/referenced_using_directive.cpp:1
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wunused-using -verify %s
+
----------------
The svn attribute changes are likely unintentional.


https://reviews.llvm.org/D44826





More information about the cfe-commits mailing list