[PATCH] D74669: [clang-tidy] New check: misc-no-include-cpp

Jonathan Roelofs via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 16 06:43:10 PST 2020


jroelofs marked an inline comment as done.
jroelofs added a comment.

In D74669#1878168 <https://reviews.llvm.org/D74669#1878168>, @njames93 wrote:

> I have a feeling this check should be called something along the lines of bugprone-suspicous-include.


That's a much better name, I like it.



================
Comment at: clang-tools-extra/clang-tidy/misc/NoIncludeCPPCheck.cpp:62
+      Check.diag(HashLoc, "suspicious #include")
+          << FixItHint::CreateReplacement(FilenameRange,
+                                          ((IsAngled ? "<" : "\"") + FileName +
----------------
njames93 wrote:
> This replacement is dangerous, I have a feeling no fix-it should be provided or at least do a search of the include directories to see if file you are trying to include actually does exist. The correct file could be `*.hpp` like what boost uses for all its header files
Yeah, perhaps the FixIt should only be added if there is a single candidate replacement that exists on the `-I` path.

Another option is to not add FixIts at all, and instead emit a list of `note:`s suggesting each of the candidates.


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