r305437 - [clang-format] Allow git-clang-format to handle empty extensions.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 14 17:54:08 PDT 2017

Author: ericwf
Date: Wed Jun 14 19:54:08 2017
New Revision: 305437

URL: http://llvm.org/viewvc/llvm-project?rev=305437&view=rev
[clang-format] Allow git-clang-format to handle empty extensions.

Most of libc++'s header files don't use extension. This prevents
using git-clang-format on them, which is frustrating.

This patch allows empty extensions to be passed using either
the --extensions option, or the clangformat.extensions git-config


Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=305437&r1=305436&r2=305437&view=diff
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Wed Jun 14 19:54:08 2017
@@ -324,6 +324,8 @@ def filter_by_extension(dictionary, allo
   allowed_extensions = frozenset(allowed_extensions)
   for filename in list(dictionary.keys()):
     base_ext = filename.rsplit('.', 1)
+    if len(base_ext) == 1 and '' in allowed_extensions:
+        continue
     if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions:
       del dictionary[filename]

More information about the cfe-commits mailing list