[Bf-blender-cvs] [949da198282] temp-clang-format: clang-format: disable formatting via comments where possible

Campbell Barton noreply at git.blender.org
Mon Jan 14 02:12:03 CET 2019


Commit: 949da198282aea9aff18adef07335413c32c9063
Author: Campbell Barton
Date:   Mon Jan 14 12:11:49 2019 +1100
Branches: temp-clang-format
https://developer.blender.org/rB949da198282aea9aff18adef07335413c32c9063

clang-format: disable formatting via comments where possible

===================================================================

M	clang-format-paths.py
M	source/blender/blenlib/BLI_compiler_typecheck.h
M	source/blender/blenlib/BLI_utildefines_variadic.h
M	source/blender/blenlib/intern/fnmatch.c
M	source/blender/blenlib/intern/sort.c
M	tests/gtests/blenlib/BLI_ressource_strings.h

===================================================================

diff --git a/clang-format-paths.py b/clang-format-paths.py
index bd9f7b8184e..fb7d7dbe1f5 100755
--- a/clang-format-paths.py
+++ b/clang-format-paths.py
@@ -45,15 +45,6 @@ extensions = (
 
 ignore_files = {
     "intern/cycles/render/sobol.cpp",  # Too heavy for clang-format
-
-    # could use clang-format on/off
-    "source/blender/blenlib/BLI_compiler_typecheck.h",    # Over wraps args.
-    "source/blender/blenlib/BLI_utildefines_variadic.h",  # Over wraps args.
-    "tests/gtests/blenlib/BLI_ressource_strings.h",       # Large data file, not helpful to format.
-
-
-    "source/blender/blenlib/intern/sort.c",               # Copied from FreeBSD, don't reformat.
-    "source/blender/blenlib/intern/fnmatch.c",            # Copied from GNU libc, don't reformat.
 }
 if os.sep != "/":
     ignore_files = set(f.replace("/", os.sep) for f in ignore_files)
diff --git a/source/blender/blenlib/BLI_compiler_typecheck.h b/source/blender/blenlib/BLI_compiler_typecheck.h
index 74638938214..2393989ea1c 100644
--- a/source/blender/blenlib/BLI_compiler_typecheck.h
+++ b/source/blender/blenlib/BLI_compiler_typecheck.h
@@ -89,7 +89,8 @@
  * \endcode
  */
 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
-
+/* Over wrapped args. */
+/* clang-format off */
 #define _VA_CHECK_TYPE_ANY2(v, a0) \
 	((void)_Generic((v), a0: 0))
 #define _VA_CHECK_TYPE_ANY3(v, a0, b0) \
@@ -377,6 +378,7 @@
 	t1: 0, u1: 0, v1: 0, w1: 0, x1: 0, y1: 0, z1: 0, a2: 0, b2: 0, c2: 0, d2: 0, e2: 0, f2: 0, g2: 0, h2: 0, i2: 0, \
 	j2: 0, k2: 0))
 #  define CHECK_TYPE_ANY(...) VA_NARGS_CALL_OVERLOAD(_VA_CHECK_TYPE_ANY, __VA_ARGS__)
+/* clang-format off */
 #else
 #  define CHECK_TYPE_ANY(...) (void)0
 #endif
@@ -400,6 +402,8 @@
  *     print("    %s: r " % (": r, ".join(args)))
  * \endcode
  */
+/* Over wrapped args. */
+/* clang-format off */
 #define _VA_GENERIC_TYPE_ANY2(r, a0) \
 	a0: r
 #define _VA_GENERIC_TYPE_ANY3(r, a0, b0) \
@@ -677,6 +681,7 @@
 	q0: r, r0: r, s0: r, t0: r, u0: r, v0: r, w0: r, x0: r, y0: r, z0: r, a1: r, b1: r, c1: r, d1: r, e1: r, f1: r, \
 	g1: r, h1: r, i1: r, j1: r, k1: r, l1: r, m1: r, n1: r, o1: r, p1: r, q1: r, r1: r, s1: r, t1: r, u1: r, v1: r, \
 	w1: r, x1: r, y1: r, z1: r, a2: r, b2: r, c2: r, d2: r, e2: r, f2: r, g2: r, h2: r, i2: r, j2: r, k2: r
+/* clang-format off */
 
 #  define GENERIC_TYPE_ANY(...) VA_NARGS_CALL_OVERLOAD(_VA_GENERIC_TYPE_ANY, __VA_ARGS__)
 
diff --git a/source/blender/blenlib/BLI_utildefines_variadic.h b/source/blender/blenlib/BLI_utildefines_variadic.h
index 7c15754fd83..9b250774c04 100644
--- a/source/blender/blenlib/BLI_utildefines_variadic.h
+++ b/source/blender/blenlib/BLI_utildefines_variadic.h
@@ -25,6 +25,9 @@
  *  \ingroup bli
  */
 
+/* Over wrapped args. */
+/* clang-format off */
+
 /* --- internal helpers --- */
 #define _VA_NARGS_GLUE(x, y) x y
 #define _VA_NARGS_RETURN_COUNT(\
@@ -47,4 +50,6 @@
 #define VA_NARGS_CALL_OVERLOAD(name, ...) \
 	_VA_NARGS_GLUE(_VA_NARGS_OVERLOAD_MACRO(name, VA_NARGS_COUNT(__VA_ARGS__)), (__VA_ARGS__))
 
+/* clang-format on */
+
 #endif  /* __BLI_UTILDEFINES_VARIADIC_H__ */
diff --git a/source/blender/blenlib/intern/fnmatch.c b/source/blender/blenlib/intern/fnmatch.c
index 36c1ef394a2..aa4b4c34aec 100644
--- a/source/blender/blenlib/intern/fnmatch.c
+++ b/source/blender/blenlib/intern/fnmatch.c
@@ -19,6 +19,10 @@
 
 #ifdef WIN32
 
+
+/* Maintained by GLIBC. */
+/* clang-format off */
+
 /* Enable GNU extensions in fnmatch.h.  */
 #ifndef _GNU_SOURCE
 # define _GNU_SOURCE	1
@@ -237,6 +241,8 @@ fnmatch (const char *pattern, const char *string, int flags)
 
 #endif /* _LIBC or not __GNU_LIBRARY__.  */
 
+/* clang-format off */
+
 #else
 
 /* intentionally empty for UNIX */
diff --git a/source/blender/blenlib/intern/sort.c b/source/blender/blenlib/intern/sort.c
index 19fea87fb41..51d23182bef 100644
--- a/source/blender/blenlib/intern/sort.c
+++ b/source/blender/blenlib/intern/sort.c
@@ -44,6 +44,9 @@
 #  undef min
 #endif
 
+/* Maintained by FreeBSD. */
+/* clang-format off */
+
 /**
  * qsort, copied from FreeBSD source.
  * with only very minor edits, see:
@@ -184,4 +187,6 @@ loop:
 	}
 }
 
+/* clang-format on */
+
 #endif  /* __GLIBC__ */
diff --git a/tests/gtests/blenlib/BLI_ressource_strings.h b/tests/gtests/blenlib/BLI_ressource_strings.h
index 819cf893575..da28a05d7ea 100644
--- a/tests/gtests/blenlib/BLI_ressource_strings.h
+++ b/tests/gtests/blenlib/BLI_ressource_strings.h
@@ -3,6 +3,9 @@
 #ifndef __BLENDER_TESTING_BLI_RESSOURCE_STRING_H__
 #define __BLENDER_TESTING_BLI_RESSOURCE_STRING_H__
 
+/* Data file, don't format. */
+/* clang-format off */
+
 const char words10k[] =
 "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam auctor ultrices purus tincidunt mollis. Vestibulum "
 "tincidunt imperdiet molestie. Vivamus posuere, risus ut mollis rutrum, lacus nulla mollis velit, consectetur auctor "
@@ -602,4 +605,6 @@ const char words10k[] =
 #endif
 ;
 
+/* clang-format on */
+
 #endif  /* __BLENDER_TESTING_BLI_RESSOURCE_STRING_H__ */



More information about the Bf-blender-cvs mailing list