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

2020-02-27 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:44 + RawStringRecommendedExtensions(Options.getLocalOrGlobal( + "RecommendedExtensions", utils::defaultHeaderFileExtensions())) { + if

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

2020-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:76 + + const auto SE = utils::getFileExtension(FileName, Check.SuspiciousExtensions); + if (!SE) Please don't use `auto` here (the type isn't

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

2020-02-25 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. In D74669#1892577 , @jroelofs wrote: > Implement review feedback: > > - Re-purpose `HeaderFileExtensionsUtils.h` to support headers *and* sources. > - Surround file extension in diagnostic with `''`s. > > I have these as

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

2020-02-25 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. In D74669#1892577 , @jroelofs wrote: > Implement review feedback: > > - Re-purpose `HeaderFileExtensionsUtils.h` to support headers *and* sources. > - Surround file extension in diagnostic with `''`s. > > I have these as two

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

2020-02-25 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 246604. jroelofs added a comment. Implement review feedback: - Re-purpose `HeaderFileExtensionsUtils.h` to support headers *and* sources. - Surround file extension in diagnostic with `''`s. I have these as two separate patches locally, but I don't know how

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

2020-02-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:50-51 + + const char *const SuspiciousExtensions[] = {".c", ".cpp", ".cxx", ".cc"}; + const char *const RecommendedExtensions[] = {"", ".h", ".hpp", ".hh"}; +

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

2020-02-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. I'd suggest possibly adding 2 Options at Global Level SourceFileExtensions and HeaderFileExtensions, both would take semicolon seperated lists. Reason they are Global is there are probably other checks that could use them. The SourceFileExtensions could be defaulted to

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

2020-02-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 245031. jroelofs added a comment. Make the diagnostics more accurate. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74669/new/ https://reviews.llvm.org/D74669 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp

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

2020-02-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked an inline comment as done. jroelofs added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:59 +Optional File = PP->LookupFile( +HashLoc /* FIXME: lies */, (FileName + RE).str(), IsAngled, nullptr,

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

2020-02-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 244994. jroelofs added a comment. Implement review feedback re: DiagLoc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74669/new/ https://reviews.llvm.org/D74669 Files:

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

2020-02-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:43 + +void SuspiciousIncludePPCallbacks::InclusionDirective( +SourceLocation HashLoc, const Token , StringRef FileName, This function is used for

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

2020-02-16 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked an inline comment as done. jroelofs added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:59 +Optional File = PP->LookupFile( +HashLoc /* FIXME: lies */, (FileName + RE).str(), IsAngled, nullptr,

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

2020-02-16 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 244884. jroelofs added a comment. git format-patch CHANGES SINCE LAST ACTION https://reviews.llvm.org/D74669/new/ https://reviews.llvm.org/D74669 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp

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

2020-02-16 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked an inline comment as done. jroelofs added inline comments. Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h:26 +/// For the user-facing documentation see: +///

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

2020-02-16 Thread Jonathan Roelofs via Phabricator via cfe-commits
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") + <<

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

2020-02-16 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 244883. jroelofs marked an inline comment as done. jroelofs added a comment. - Renamed to bugprone-suspicious-include - Removed FixIts in favor of `note:` suggestions, iff the suggested file exists on the header search path. - Removed unnecessary unused

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

2020-02-16 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/NoIncludeCPPCheck.cpp:11-13 +#include "clang/ASTMatchers/ASTMatchFinder.h" + +using namespace clang::ast_matchers; You don't need to include or use the AST matchers in a preprocessor

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

2020-02-16 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked an inline comment as done. jroelofs added a comment. In 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.

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

2020-02-16 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. I have a feeling this check should be called something along the lines of bugprone-suspicous-include. Comment at: clang-tools-extra/clang-tidy/misc/NoIncludeCPPCheck.cpp:62 + Check.diag(HashLoc, "suspicious #include") + <<

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

2020-02-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment. Herald added a subscriber: wuzish. 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 at:

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

2020-02-15 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs created this revision. jroelofs added a reviewer: aaron.ballman. Herald added subscribers: cfe-commits, kbarton, xazax.hun, mgorny, nemanjai. Herald added a project: clang. Detects and fixes suspicious code like: `#include "foo.cpp"`. Inspired by: