[llvm] [code-format] Also include libc++ extensionless headers (PR #73142)

Louis Dionne via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 08:41:09 PST 2023


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/73142

>From 60b6c0453b1a4a49487fcf26f896db57ea1db990 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 22 Nov 2023 11:33:33 -0500
Subject: [PATCH 1/2] [code-format] Also include libc++ extensionless headers

These headers were skipped by the job because they didn't have an
extension. However, such headers are extremely common in libc++.
---
 llvm/utils/git/code-format-helper.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py
index 32745768dc74c4d..2e02c911a9a830a 100644
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -126,6 +126,9 @@ def should_be_excluded(self, path: str) -> bool:
             return True
         return False
 
+    def should_include_extensionless_file(self, path: str) -> bool:
+        return path.startswith('libcxx/include')
+
     def filter_changed_files(self, changed_files: list[str]) -> list[str]:
         filtered_files = []
         for path in changed_files:
@@ -133,6 +136,8 @@ def filter_changed_files(self, changed_files: list[str]) -> list[str]:
             if ext in (".cpp", ".c", ".h", ".hpp", ".hxx", ".cxx"):
                 if not self.should_be_excluded(path):
                     filtered_files.append(path)
+            elif ext == "" and self.should_include_extensionless_file(path):
+                filtered_files.append(path)
         return filtered_files
 
     def format_run(

>From 0235e247d3a87c118d27cf8583c253b32e7a6faf Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 22 Nov 2023 11:40:50 -0500
Subject: [PATCH 2/2] Darker

---
 llvm/utils/git/code-format-helper.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py
index 2e02c911a9a830a..f74d34bc39f299a 100644
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -127,7 +127,7 @@ def should_be_excluded(self, path: str) -> bool:
         return False
 
     def should_include_extensionless_file(self, path: str) -> bool:
-        return path.startswith('libcxx/include')
+        return path.startswith("libcxx/include")
 
     def filter_changed_files(self, changed_files: list[str]) -> list[str]:
         filtered_files = []



More information about the llvm-commits mailing list