[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 08:21:38 PST 2020


jroelofs marked 4 inline comments as done and an inline comment as not done.
jroelofs added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/misc/NoIncludeCPPCheck.cpp:62
+      Check.diag(HashLoc, "suspicious #include")
+          << FixItHint::CreateReplacement(FilenameRange,
+                                          ((IsAngled ? "<" : "\"") + FileName +
----------------
njames93 wrote:
> jroelofs wrote:
> > 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.
> How about the case if someone wants to (for whatever reason) include something like this:
> 
> ```
> #include "example.h"
> #include "example.cpp"
> ```
> That looks intentional and a fix it shouldn't be emitted.
I'd imagine that people doing this intentionally (unity builds come to mind) would turn off this check. That said, is there something better this check could be doing to accommodate those people?


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