-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[include-cleaner] rename enabled flags to disable-*
#132991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[include-cleaner] rename enabled flags to disable-*
#132991
Conversation
@llvm/pr-subscribers-clang-tools-extra Author: Mohamed Emad (hulxv) ChangesCloses #132983 Full diff: https://github.com/llvm/llvm-project/pull/132991.diff 2 Files Affected:
diff --git a/clang-tools-extra/include-cleaner/test/tool.cpp b/clang-tools-extra/include-cleaner/test/tool.cpp
index d72d2317ce2b1..8b723a5bf40e2 100644
--- a/clang-tools-extra/include-cleaner/test/tool.cpp
+++ b/clang-tools-extra/include-cleaner/test/tool.cpp
@@ -6,11 +6,11 @@ int x = foo();
// CHANGE: - "foobar.h"
// CHANGE-NEXT: + "foo.h"
-// RUN: clang-include-cleaner -remove=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s
+// RUN: clang-include-cleaner -disable-remove -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=INSERT %s
// INSERT-NOT: - "foobar.h"
// INSERT: + "foo.h"
-// RUN: clang-include-cleaner -insert=0 -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s
+// RUN: clang-include-cleaner -disable-insert -print=changes %s -- -I%S/Inputs/ | FileCheck --check-prefix=REMOVE %s
// REMOVE: - "foobar.h"
// REMOVE-NOT: + "foo.h"
diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 1d9458ffc4d32..472611073f732 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -91,16 +91,16 @@ cl::opt<bool> Edit{
cl::cat(IncludeCleaner),
};
-cl::opt<bool> Insert{
- "insert",
- cl::desc("Allow header insertions"),
- cl::init(true),
+cl::opt<bool> DisableInsert{
+ "disable-insert",
+ cl::desc("DIsable header insertions"),
+ cl::init(false),
cl::cat(IncludeCleaner),
};
-cl::opt<bool> Remove{
- "remove",
- cl::desc("Allow header removals"),
- cl::init(true),
+cl::opt<bool> DisableRemove{
+ "disable-remove",
+ cl::desc("Disable header removals"),
+ cl::init(false),
cl::cat(IncludeCleaner),
};
@@ -183,9 +183,9 @@ class Action : public clang::ASTFrontendAction {
auto Results =
analyze(AST.Roots, PP.MacroReferences, PP.Includes, &PI,
getCompilerInstance().getPreprocessor(), HeaderFilter);
- if (!Insert)
+ if (DisableInsert)
Results.Missing.clear();
- if (!Remove)
+ if (DisableRemove)
Results.Unused.clear();
std::string Final = fixIncludes(Results, AbsPath, Code, getStyle(AbsPath));
|
@AaronBallman @hokein can you please review this PR? It has been opened for a long time without any review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a deprecation period for this change? This will break anyone using the old names in scripts and whatnot.
Also, the changes will need something in the release notes so users know about the new names.
Is there a specific way to mark flags as deprecated? I didn't find anything like that in |
It would be useful but I don't think we have any such functionality currently. You could either try to pipe in that functionality to the command line APIs, or you could manually implement one-off logic just for include-cleaner, I think either is reasonable. |
9bbae72
to
e2f78ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think the things that are missing are:
- If
Insert
orRemove
is true, we should diagnose those as being deprecated and recommend usingdisable-insert
ordisable-remove
instead. - A release note should be added to clang-tools-extra/docs/ReleaseNotes.rst so users know about the change and new flags.
- Test coverage in clang-tools-extra/include-cleaner/test to test that we get the deprecation warning only when expected (for both options) and that the new options behave the same as the old options.
Is there a specific format for this note? |
Oops, I meant "if they're used", so yes. :-)
Something along the lines of:
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor cleanups, but I think we're pretty close!
2035040
to
d9d8481
Compare
I think all is fine now |
@AaronBallman Do you think we need to work on something in CommandLine to make the deprecation of commands easier and standardised for all tools? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Do you need me to land the changes on your behalf?
It might be nice, but isn't a requirement for this patch. We don't deprecate command line options too often, so it may not be worth the effort. |
Yup, I don't have access yet |
I'll push the changes once precommit CI goes green. Thank you for the improvement! |
FYI: it looks like precommit CI found a failure with one of the tests |
Closes #132983