[llvm] bf0de88 - code format checker: fix python error when the diff becomes empty

Nuno Lopes via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 16 00:39:06 PDT 2025


Author: Nuno Lopes
Date: 2025-04-16T08:38:37+01:00
New Revision: bf0de88696095342aaa58e5e0a0105403d5ebd5e

URL: https://github.com/llvm/llvm-project/commit/bf0de88696095342aaa58e5e0a0105403d5ebd5e
DIFF: https://github.com/llvm/llvm-project/commit/bf0de88696095342aaa58e5e0a0105403d5ebd5e.diff

LOG: code format checker: fix python error when the diff becomes empty

Added: 
    

Modified: 
    llvm/utils/git/code-format-helper.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py
index 69d654b87e856..ed102b54f9b52 100755
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -385,7 +385,9 @@ def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str
         # Each file is prefixed like:
         # 
diff  --git a/file b/file
         for file in re.split("^
diff  --git ", stdout, 0, re.MULTILINE):
-            filename = re.match("a/([^ ]+)", file.splitlines()[0])[1]
+            lines = file.splitlines()
+            match = re.match("a/([^ ]+)", lines[0] if lines else "")
+            filename = match[1] if match else ""
             if filename.endswith(".ll"):
                 undef_regex = r"(?<!%)\bundef\b"
             else:


        


More information about the llvm-commits mailing list