Author: Congcong Cai
Date: 2024-06-07T13:32:18+08:00
New Revision: c5ff983fe4a3180e13c7244a6ce9f5994b4379b4

URL: 
https://github.com/llvm/llvm-project/commit/c5ff983fe4a3180e13c7244a6ce9f5994b4379b4
DIFF: 
https://github.com/llvm/llvm-project/commit/c5ff983fe4a3180e13c7244a6ce9f5994b4379b4.diff

LOG: [clang-tidy] refactor misc-header-include-cycle (#94697)

1. merge valid check
2. use range base loop

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp
index 37bc577c646ab..cdb5e6b16069b 100644
--- a/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp
@@ -130,20 +130,15 @@ class CyclicDependencyCallbacks : public PPCallbacks {
         << FileName;
 
     const bool IsIncludePathValid =
-        std::all_of(Files.rbegin(), It, [](const Include &Elem) {
+        std::all_of(Files.rbegin(), It + 1, [](const Include &Elem) {
           return !Elem.Name.empty() && Elem.Loc.isValid();
         });
-
     if (!IsIncludePathValid)
       return;
 
-    auto CurrentIt = Files.rbegin();
-    do {
-      if (CurrentIt->Loc.isValid())
-        Check.diag(CurrentIt->Loc, "'%0' included from here",
-                   DiagnosticIDs::Note)
-            << CurrentIt->Name;
-    } while (CurrentIt++ != It);
+    for (const Include &I : llvm::make_range(Files.rbegin(), It + 1))
+      Check.diag(I.Loc, "'%0' included from here", DiagnosticIDs::Note)
+          << I.Name;
   }
 
   bool isFileIgnored(StringRef FileName) const {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to