haowei created this revision.
haowei requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

fallback-style is a frequently used flag in clang_format, however, it was not 
supported by clang-format-diff.py script. This change adds this flag.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109550

Files:
  clang/tools/clang-format/clang-format-diff.py


Index: clang/tools/clang-format/clang-format-diff.py
===================================================================
--- clang/tools/clang-format/clang-format-diff.py
+++ clang/tools/clang-format/clang-format-diff.py
@@ -58,6 +58,12 @@
   parser.add_argument('-style',
                       help='formatting style to apply (LLVM, GNU, Google, 
Chromium, '
                       'Microsoft, Mozilla, WebKit)')
+  parser.add_argument('-fallback-style',
+                      dest='fallback_style',
+                      help='The name of the predefined style used as a'
+                      'fallback in case clang-format is invoked with'
+                      '-style=file, but can not find the .clang-format'
+                      'file to use.')
   parser.add_argument('-binary', default='clang-format',
                       help='location of binary to use for clang-format')
   args = parser.parse_args()
@@ -103,6 +109,8 @@
     command.extend(lines)
     if args.style:
       command.extend(['-style', args.style])
+    if args.fallback_style:
+      command.extend(['-fallback-style', args.fallback_style])
 
     try:
       p = subprocess.Popen(command,


Index: clang/tools/clang-format/clang-format-diff.py
===================================================================
--- clang/tools/clang-format/clang-format-diff.py
+++ clang/tools/clang-format/clang-format-diff.py
@@ -58,6 +58,12 @@
   parser.add_argument('-style',
                       help='formatting style to apply (LLVM, GNU, Google, Chromium, '
                       'Microsoft, Mozilla, WebKit)')
+  parser.add_argument('-fallback-style',
+                      dest='fallback_style',
+                      help='The name of the predefined style used as a'
+                      'fallback in case clang-format is invoked with'
+                      '-style=file, but can not find the .clang-format'
+                      'file to use.')
   parser.add_argument('-binary', default='clang-format',
                       help='location of binary to use for clang-format')
   args = parser.parse_args()
@@ -103,6 +109,8 @@
     command.extend(lines)
     if args.style:
       command.extend(['-style', args.style])
+    if args.fallback_style:
+      command.extend(['-fallback-style', args.fallback_style])
 
     try:
       p = subprocess.Popen(command,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to