https://github.com/lumirlumir created 
https://github.com/llvm/llvm-project/pull/241793

Hello,

I've added nine missing extensions to `clang-format-diff.py`’s default filter. 
These are already supported by `clang-format`, but the script silently skips 
them.

| Language | Extensions | Reference |
|---|---|---|
| C++ | `.cp` | 
[git-clang-format](https://github.com/llvm/llvm-project/blob/4e8f741d81620d640c4d25b9e78f327772e60ed7/clang/tools/clang-format/git-clang-format#L99)
 |
| CUDA | `.cu`, `.cuh` | 
[git-clang-format](https://github.com/llvm/llvm-project/blob/4e8f741d81620d640c4d25b9e78f327772e60ed7/clang/tools/clang-format/git-clang-format#L111-L112)
 |
| TableGen | `.td` | 
[Format.cpp](https://github.com/llvm/llvm-project/blob/4e8f741d81620d640c4d25b9e78f327772e60ed7/clang/lib/Format/Format.cpp#L4703-L4704)
 |
| TextProto | `.txtpb`, `.textpb`, `.pb.txt`, `.textproto`, `.asciipb` | 
[Format.cpp](https://github.com/llvm/llvm-project/blob/4e8f741d81620d640c4d25b9e78f327772e60ed7/clang/lib/Format/Format.cpp#L4696-L4702)
 |

Only the default regex changes, with the dot in `.pb.txt` escaped.

>From f8f87f0a3909e3ce3976a7433ea2a8c00b90b52a Mon Sep 17 00:00:00 2001
From: lumir <[email protected]>
Date: Thu, 12 Nov 2026 20:07:42 +0900
Subject: [PATCH] [clang-format] fix: add missing extensions to
 clang-format-diff.py's default filter

---
 clang/tools/clang-format/clang-format-diff.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/tools/clang-format/clang-format-diff.py 
b/clang/tools/clang-format/clang-format-diff.py
index 4afabe7e7df47a..3424a8a52c2975 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -62,8 +62,9 @@ def main():
     parser.add_argument(
         "-iregex",
         metavar="PATTERN",
-        default=r".*\.(?:cpp|cc|c\+\+|cxx|cppm|ccm|cxxm|c\+\+m|c|cl|h|hh|hpp"
-        
r"|hxx|m|mm|inc|[mc]?js|[mc]?ts|proto|protodevel|java|cs|json|ipynb|s?vh?)",
+        
default=r".*\.(?:cpp|cc|cp|c\+\+|cxx|cppm|ccm|cxxm|c\+\+m|c|cl|cu|cuh|h|hh|hpp"
+        
r"|hxx|m|mm|inc|[mc]?js|[mc]?ts|proto|protodevel|java|cs|json|ipynb|s?vh?"
+        r"|td|txtpb|textpb|pb\.txt|textproto|asciipb)",
         help="custom pattern selecting file paths to reformat "
         "(case insensitive, overridden by -regex)",
     )

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to