Detects and fixes suspicious code like: #include "foo.cpp".
Inspired by: https://twitter.com/lefticus/status/1228458240364687360?s=20
Differential D74669
[clang-tidy] New check: bugprone-suspicious-include jroelofs on Feb 15 2020, 9:20 AM. Authored by
Details Detects and fixes suspicious code like: #include "foo.cpp". Inspired by: https://twitter.com/lefticus/status/1228458240364687360?s=20
Diff Detail
Event TimelineComment Actions How about .cc and .cxx extension? It'll be reasonable to provide option to configure list of extensions. Please add documentation and mention new check in Release Notes.
Comment Actions I have a feeling this check should be called something along the lines of bugprone-suspicous-include.
Comment Actions That's a much better name, I like it.
Comment Actions
Comment Actions I'd suggest possibly adding 2 Options at Global Level SourceFileExtensions and HeaderFileExtensions, both would take semicolon seperated lists.
Comment Actions Implement review feedback:
I have these as two separate patches locally, but I don't know how to represent that in phabricator, so I've uploaded the diff across both. If this gets approved, I intend to push them as separate commits. Comment Actions You can create a review that just re-purposes HeaderFileExtensionsUtils then set that review as a parent of this review
Comment Actions Adding the parent revision means you don't need to have those changes in this patch. It will cause issues down the line. best thing is to run a diff from this to the parent and just include those changes Comment Actions IIUC, that is what I've already done: https://reviews.llvm.org/D74669 is git show c4dd6f5903e -U999 where c4dd6f5903e is the parent of 0cda7e0b9ed. The suggestion to switch over to ;s as delimiters is what's causing this diff to still touch so many files.
Comment Actions LGTM aside from some documentation and testing nits.
Comment Actions Thanks for the review! https://github.com/llvm/llvm-project/commit/1e0669bfe05f0f48ee88152c4a1d581f484f8d67
Comment Actions Don't fire on #imports. The error on Windows suggests it would normally do the "right" thing anyway: http://45.33.8.238/win/10088/step_8.txt C:\src\llvm-project\out\gn\obj\clang-tools-extra\test\clang-tidy\checkers\Output\bugprone-suspicious-include.cpp.tmp.cpp:18:2: error: #import of type library is an unsupported Microsoft feature [clang-diagnostic-error] #import "c.c" Comment Actions Firefox uses a unified build model. For better performances in the binary, the C++ files are compiled as the same time from a single file (ex: Unified_cpp_netwerk_base3.cpp) which will include the .cpp files. This isn't a common use case, so, don't hesitate to ignore me but checks triggers 4286 new issues. About 20 of them are legit. |
";h;hh;hpp;hxx"