[clang-tools-extra] [clang-tidy][misc-include-cleaner]Avoid to insert same include header multiple times (PR #65431)

Ding Fei via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 5 22:33:26 PDT 2023


================
@@ -199,6 +199,9 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
 
   tooling::HeaderIncludes HeaderIncludes(getCurrentMainFile(), Code,
                                          FileStyle->IncludeStyle);
+  // `tooling::HeaderIncludes::insert` will not modify `ExistingIncludes`. We
+  // should handle repeat include here
+  std::set<const std::string> InsertedHeader{};
----------------
danix800 wrote:

`std::set<const std::string>` won't compile, please take a look at the failed CI checking. `llvm::StringSet` might be better option if `std::string` could be switched to `StringRef`.

https://github.com/llvm/llvm-project/pull/65431


More information about the cfe-commits mailing list