[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 9 14:35:42 PDT 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from some documentation and testing nits.



================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:15-17
+  #include "Velociraptor.cpp" // Warning, filename is suspicious
+  #import "Stegosaurus.c"     // Warning, fliename is suspicious
+  #include_next <stdio.c>     // Warning, filename is suspicious
----------------
Missing full stops at the end of the comments.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:24
+   Default value: ";h;hh;hpp;hxx"
+   A semicolon-separated list of filename extensions of header files (The
+   filename extensions should not contain "." prefix). For extension-less
----------------
The -> the


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:25
+   A semicolon-separated list of filename extensions of header files (The
+   filename extensions should not contain "." prefix). For extension-less
+   header files, using an empty string or leaving an empty string between ";"
----------------
contain "." -> contain a "."


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:26
+   filename extensions should not contain "." prefix). For extension-less
+   header files, using an empty string or leaving an empty string between ";"
+   if there are other filename extensions.
----------------
using -> use
leaving -> leave


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:29
+
+.. option:: HeaderFileExtensions
+
----------------
ImplementationFileExtensions ;-)


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp:7
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?
----------------
For those of you following along at home, `a.h` already exists on ToT (as does b.h). :-D


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp:10
+#include "a.cpp"
+
+#include "b.h"
----------------
Can you add a test for:
```
#include "i.cpp"
```
to show that it suggests `i.h` (which already exists in-tree) but not `i` or `i.hpp`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74669/new/

https://reviews.llvm.org/D74669





More information about the cfe-commits mailing list