[clang] Improve clang-format-diff help output (PR #73491)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 27 02:00:59 PST 2023
https://github.com/serge-sans-paille updated https://github.com/llvm/llvm-project/pull/73491
>From 788d03126f95ffc8d3b9701fdba73bb931e25cfc Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton at mozilla.com>
Date: Mon, 27 Nov 2023 10:17:32 +0100
Subject: [PATCH 1/2] Improve clang-format-diff help output
It is quite common to symlink clang-format-diff.py to
clang-format-diff, and in that case the help output still refers to the
.py version. Compute it instead to work in both setup.
---
clang/tools/clang-format/clang-format-diff.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py
index 892c1e38a462ff4..facaaf96dd8f90a 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -13,8 +13,8 @@
lines. This is useful to reformat all the lines touched by a specific patch.
Example usage for git/svn users:
- git diff -U0 --no-color --relative HEAD^ | clang-format-diff.py -p1 -i
- svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
+ git diff -U0 --no-color --relative HEAD^ | {clang_format_diff} -p1 -i
+ svn diff --diff-cmd=diff -x-U0 | {clang_format_diff} -i
It should be noted that the filename contained in the diff is used unmodified
to determine the source file to update. Users calling this script directly
@@ -25,6 +25,7 @@
import argparse
import difflib
+import os
import re
import subprocess
import sys
@@ -36,8 +37,10 @@
def main():
+ basename = os.path.basename(sys.argv[0])
parser = argparse.ArgumentParser(
- description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
+ description=__doc__.format(clang_format_diff=basename),
+ formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument(
"-i",
>From 4ddec8f2a65e60a701d13399a556b0acb281ed40 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton at mozilla.com>
Date: Mon, 27 Nov 2023 11:00:36 +0100
Subject: [PATCH 2/2] fixup! [clang] Avoid memcopy for small structure with
padding under -ftrivial-auto-var-init (#71677)
---
clang/tools/clang-format/clang-format-diff.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py
index facaaf96dd8f90a..b25ee8f4337518e 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -40,7 +40,7 @@ def main():
basename = os.path.basename(sys.argv[0])
parser = argparse.ArgumentParser(
description=__doc__.format(clang_format_diff=basename),
- formatter_class=argparse.RawDescriptionHelpFormatter
+ formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
"-i",
More information about the cfe-commits
mailing list