Skip to content

Commit c5ff983

Browse files
authored
[clang-tidy] refactor misc-header-include-cycle (#94697)
1. merge valid check 2. use range base loop
1 parent a6350d6 commit c5ff983

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,15 @@ class CyclicDependencyCallbacks : public PPCallbacks {
130130
<< FileName;
131131

132132
const bool IsIncludePathValid =
133-
std::all_of(Files.rbegin(), It, [](const Include &Elem) {
133+
std::all_of(Files.rbegin(), It + 1, [](const Include &Elem) {
134134
return !Elem.Name.empty() && Elem.Loc.isValid();
135135
});
136-
137136
if (!IsIncludePathValid)
138137
return;
139138

140-
auto CurrentIt = Files.rbegin();
141-
do {
142-
if (CurrentIt->Loc.isValid())
143-
Check.diag(CurrentIt->Loc, "'%0' included from here",
144-
DiagnosticIDs::Note)
145-
<< CurrentIt->Name;
146-
} while (CurrentIt++ != It);
139+
for (const Include &I : llvm::make_range(Files.rbegin(), It + 1))
140+
Check.diag(I.Loc, "'%0' included from here", DiagnosticIDs::Note)
141+
<< I.Name;
147142
}
148143

149144
bool isFileIgnored(StringRef FileName) const {

0 commit comments

Comments
 (0)