Skip to content

Commit 6f2a50a

Browse files
committed
[include-cleaner] Add --fail-on-changes option
When integrating clang-include-cleaner into a test suite, it's useful to have it exit with a nonzero exit status when there are suggested changes to includes so let's add --fail-on-changes to make that possible.
1 parent b7d6a54 commit 6f2a50a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ cl::opt<bool> DisableRemove{
115115
cl::init(false),
116116
cl::cat(IncludeCleaner),
117117
};
118+
cl::opt<bool> FailOnChanges{
119+
"fail-on-changes",
120+
cl::desc("Exit with a non-zero exit code if changes are suggested"),
121+
cl::cat(IncludeCleaner),
122+
};
118123

119124
std::atomic<unsigned> Errors = ATOMIC_VAR_INIT(0);
120125

@@ -410,5 +415,5 @@ int main(int argc, const char **argv) {
410415
}
411416
}
412417
}
413-
return ErrorCode || Errors != 0;
418+
return ErrorCode || Errors != 0 || (FailOnChanges && Factory.editedFiles().size() != 0);
414419
}

0 commit comments

Comments
 (0)