-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang-tidy] Check for -ignore-insert-conflict support before using it in apply_fixes in run-clang-tidy.py
#127066
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
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-clang-tidy @llvm/pr-subscribers-clang-tools-extra Author: Vicente Mataix Ferrándiz (loumalouomega) ChangesRemove legacy argument Summary:This PR removes the Full diff: https://github.com/llvm/llvm-project/pull/127066.diff 1 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
index f1b934f7139e9..acee87c860aa0 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -200,7 +200,6 @@ def apply_fixes(
) -> None:
"""Calls clang-apply-fixes on a given directory."""
invocation = [clang_apply_replacements_binary]
- invocation.append("-ignore-insert-conflict")
if args.format:
invocation.append("-format")
if args.style:
|
Could you explain more about |
In version 14.0 looks like is not anymore: clang-apply-replacements --version
clang-apply-replacements version 14.0.0clang-apply-replacements --help
USAGE: clang-apply-replacements [options] <Search Root Directory>
OPTIONS:
Formatting Options:
--format - Enable formatting of code changed by applying replacements.
Use -style to choose formatting style.
--style=<string> - Coding style, currently supports:
LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.
Use -style=file to load style configuration from
.clang-format file located in one of the parent
directories of the source file (or current
directory for stdin).
Use -style=file:<format_file_path> to explicitly specifythe configuration file.
Use -style="{key: value, ...}" to set specific
parameters, e.g.:
-style="{BasedOnStyle: llvm, IndentWidth: 8}"
--style-config=<string> - Path to a directory containing a .clang-format file
describing a formatting style to use for formatting
code when -style=file.
Generic Options:
--help - Display available options (--help-hidden for more)
--help-list - Display list of available options (--help-list-hidden for more)
--version - Display the version of this program
Replacement Options:
--remove-change-desc-files - Remove the change description files regardless of successful
merging/replacing. |
Because, it were added in Clang 15. |
PiotrZSL
left a comment
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.
Best would be to add that option to script and let user decide whatever use it or not.
Do you want me to do it? |
|
Ok, so is not legacy, but the contrary. My version of Clang is old. I can refactor if you want. |
-ignore-insert-conflict from run-clang-tidy.py-ignore-insert-conflict option in clang-apply-replacements
|
@PiotrZSL FYI |
carlosgalvezp
left a comment
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 except for some minor nits. Also, the commit message is misleading, it should be something like:
[clang-tidy] Add support for `-ignore-insert-conflict` in `run-clang-tidy.py`
Okay, I don'w know the style. BTW,I applied tour comments |
-ignore-insert-conflict option in clang-apply-replacements-ignore-insert-conflict in run-clang-tidy.py
HerrCai0907
left a comment
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. Please update release note also.
After that, feel free to ping me to merge it if you do not have permission.
You can test this locally with the following command:darker --check --diff -r 4664a4c66b816af53f596935c3aaa2eca143ae9c...80b0b797a4abb48d37455651c1ac070df00f6344 clang-tools-extra/clang-tidy/tool/run-clang-tidy.pyView the diff from darker here.--- run-clang-tidy.py 2025-02-14 11:25:07.000000 +0000
+++ run-clang-tidy.py 2025-02-16 01:14:10.095163 +0000
@@ -198,11 +198,11 @@
def apply_fixes(
args: argparse.Namespace, clang_apply_replacements_binary: str, tmpdir: str
) -> None:
"""Calls clang-apply-replacements on a given directory."""
invocation = [clang_apply_replacements_binary]
-
+
if args.ignore_insert_conflict:
invocation.append("-ignore-insert-conflict")
if args.format:
invocation.append("-format")
if args.style:
|
Can you help me?, I have no experience in this repository |
| parser.add_argument( | ||
| "-ignore-insert-conflict", | ||
| action="store_true", | ||
| default=True, |
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.
Shouldn't this be false by default and toggled to true when the option is present?
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.
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.
I was asked to preserve current behaviour
release-note is placed |
… it in `apply_fixes` in `run_clang_tidy.py`
-ignore-insert-conflict in run-clang-tidy.py-ignore-insert-conflict support before using it in apply_fixes in run-clang-tidy.py
|
I am a bit confused here. If you're using the system Clang toolchain assembled by your company (outside of your control), that toolchain should have delivered a If you are using Otherwise you might be mixing versions, standard library implementations, intrinsic headers, etc., and there will be plenty of subtle bugs lurking behind every corner! So in general, what was the original point you're trying to achieve? To me, the solution to the lack of |
I have a certain version of Ubuntu with a certain version of Clang, not custom compiled. |
It should, but does it? A typical installation comes from installing the Ubuntu packages, do they include If not, then I don't think You are not in control of the Clang/clang-tidy packages, but what about |
The script is not included in the installation, and I cannot install them, thats why I downloaded manually the script and detected the problem. I can close this, if it is too problematic. I just wanted some people to not suffer this problematic in the future. |
@loumalouomega Can you please confirm if the Clang comes from the official Debian or Ubuntu APT repository? If that is the case, I think we can, going forward, contact the maintainers of that pipeline (if the patch can't be done locally within the LLVM repo) to include this script as long as this script can be considered "user-facing" and not a developer-only tool. |
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammyFor Ubuntu 22.04 LTS (still supportedm and I cannot update it for businness reasons): |
Check for
-ignore-insert-conflictsupport before using it inapply_fixesinrun-clang-tidy.pyDetails:
supports_flag()to check ifclang-apply-replacementssupports-ignore-insert-conflictby running--help.clang-apply-replacements.