Cleanup: work around clang-format differences between versions

Ref T73747
This commit is contained in:
Brecht Van Lommel 2020-02-15 13:51:46 +01:00
parent 924fe50e97
commit f0c991a380
8 changed files with 55 additions and 51 deletions

@ -15,6 +15,11 @@
* limitations under the License. * limitations under the License.
*/ */
/* clang-format off */
/* #define __forceinline triggers a bug in some clang-format versions, disable
* format for entire file to keep results consistent. */
#ifndef __UTIL_DEFINES_H__ #ifndef __UTIL_DEFINES_H__
#define __UTIL_DEFINES_H__ #define __UTIL_DEFINES_H__

@ -14,34 +14,20 @@
* limitations under the License. * limitations under the License.
*/ */
/* clang-format off */
/* #define static_assert triggers a bug in some clang-format versions, disable
* format for entire file to keep results consistent. */
#ifndef __UTIL_STATIC_ASSERT_H__ #ifndef __UTIL_STATIC_ASSERT_H__
#define __UTIL_STATIC_ASSERT_H__ #define __UTIL_STATIC_ASSERT_H__
CCL_NAMESPACE_BEGIN CCL_NAMESPACE_BEGIN
/* TODO(sergey): In theory CUDA might work with own static assert #ifdef __KERNEL_OPECL__
* implementation since it's just pure C++. # define static_assert(statement, message)
*/
#ifdef __KERNEL_GPU__
# ifndef static_assert
# define static_assert(statement, message)
# endif
#endif /* __KERNEL_GPU__ */ #endif /* __KERNEL_GPU__ */
/* TODO(sergey): For until C++11 is a bare minimum for us,
* we do a bit of a trickery to show meaningful message so
* it's more or less clear what's wrong when building without
* C++11.
*
* The thing here is: our non-C++11 implementation doesn't
* have a way to print any message after preprocessor
* substitution so we rely on the message which is passed to
* static_assert() since that's the only message visible when
* compilation fails.
*
* After C++11 bump it should be possible to glue structure
* name to the error message,
*/
#define static_assert_align(st, align) \ #define static_assert_align(st, align) \
static_assert((sizeof(st) % (align) == 0), "Structure must be strictly aligned") // NOLINT static_assert((sizeof(st) % (align) == 0), "Structure must be strictly aligned") // NOLINT

@ -34,7 +34,9 @@
static void ghost_fatal_error_dialog(const char *msg) static void ghost_fatal_error_dialog(const char *msg)
{ {
/* clang-format off */
@autoreleasepool { @autoreleasepool {
/* clang-format on */
NSString *message = [NSString stringWithFormat:@"Error opening window:\n%s", msg]; NSString *message = [NSString stringWithFormat:@"Error opening window:\n%s", msg];
NSAlert *alert = [[NSAlert alloc] init]; NSAlert *alert = [[NSAlert alloc] init];
@ -335,7 +337,9 @@ static const OSType METAL_CORE_VIDEO_PIXEL_FORMAT = kCVPixelFormatType_32BGRA;
void GHOST_ContextCGL::metalInit() void GHOST_ContextCGL::metalInit()
{ {
/* clang-format off */
@autoreleasepool { @autoreleasepool {
/* clang-format on */
id<MTLDevice> device = m_metalLayer.device; id<MTLDevice> device = m_metalLayer.device;
// Create a command queue for blit/present operation // Create a command queue for blit/present operation
@ -530,7 +534,9 @@ void GHOST_ContextCGL::metalUpdateFramebuffer()
void GHOST_ContextCGL::metalSwapBuffers() void GHOST_ContextCGL::metalSwapBuffers()
{ {
/* clang-format off */
@autoreleasepool { @autoreleasepool {
/* clang-format on */
updateDrawingContext(); updateDrawingContext();
glFlush(); glFlush();

@ -952,7 +952,9 @@ static NSCursor *getImageCursor(GHOST_TStandardCursor shape, NSString *name, NSP
const int index = (int)shape; const int index = (int)shape;
if (!loaded[index]) { if (!loaded[index]) {
/* Load image from file in application Resources folder. */ /* Load image from file in application Resources folder. */
/* clang-format off */
@autoreleasepool { @autoreleasepool {
/* clang-format on */
NSImage *image = [NSImage imageNamed:name]; NSImage *image = [NSImage imageNamed:name];
if (image != NULL) { if (image != NULL) {
cursors[index] = [[NSCursor alloc] initWithImage:image hotSpot:hotspot]; cursors[index] = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];

@ -1977,7 +1977,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh,
if (mode & PBVH_Collapse) { if (mode & PBVH_Collapse) {
EdgeQueue q; EdgeQueue q;
BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert * [2]), 0, 128, BLI_MEMPOOL_NOP); BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *) * 2, 0, 128, BLI_MEMPOOL_NOP);
EdgeQueueContext eq_ctx = { EdgeQueueContext eq_ctx = {
&q, &q,
queue_pool, queue_pool,
@ -1996,7 +1996,7 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *bvh,
if (mode & PBVH_Subdivide) { if (mode & PBVH_Subdivide) {
EdgeQueue q; EdgeQueue q;
BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert * [2]), 0, 128, BLI_MEMPOOL_NOP); BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *) * 2, 0, 128, BLI_MEMPOOL_NOP);
EdgeQueueContext eq_ctx = { EdgeQueueContext eq_ctx = {
&q, &q,
queue_pool, queue_pool,

@ -14,8 +14,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
/* clang-format off */
/* #define typeof() triggers a bug in some clang-format versions, disable format
* for entire file to keep results consistent. */
#ifndef __BLI_COMPILER_COMPAT_H__ #ifndef __BLI_COMPILER_COMPAT_H__
# define __BLI_COMPILER_COMPAT_H__ #define __BLI_COMPILER_COMPAT_H__
/** \file /** \file
* \ingroup bli * \ingroup bli
@ -23,32 +28,32 @@
* Use to help with cross platform portability. * Use to help with cross platform portability.
*/ */
# if defined(_MSC_VER) #if defined(_MSC_VER)
# define alloca _alloca # define alloca _alloca
# endif #endif
# if (defined(__GNUC__) || defined(__clang__)) && defined(__cplusplus) #if (defined(__GNUC__) || defined(__clang__)) && defined(__cplusplus)
extern "C++" { extern "C++" {
/* Some magic to be sure we don't have reference in the type. */ /* Some magic to be sure we don't have reference in the type. */
template<typename T> static inline T decltype_helper(T x) template<typename T> static inline T decltype_helper(T x)
{ {
return x; return x;
} }
# define typeof(x) decltype(decltype_helper(x)) #define typeof(x) decltype(decltype_helper(x))
} }
# endif #endif
/* little macro so inline keyword works */ /* little macro so inline keyword works */
# if defined(_MSC_VER) #if defined(_MSC_VER)
# define BLI_INLINE static __forceinline # define BLI_INLINE static __forceinline
# else #else
# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__)) # define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
# endif #endif
# if defined(__GNUC__) #if defined(__GNUC__)
# define BLI_NOINLINE __attribute__((noinline)) # define BLI_NOINLINE __attribute__((noinline))
# else #else
# define BLI_NOINLINE # define BLI_NOINLINE
# endif #endif
#endif /* __BLI_COMPILER_COMPAT_H__ */ #endif /* __BLI_COMPILER_COMPAT_H__ */

@ -637,16 +637,15 @@ template<typename KeyT, typename ValueT, typename Allocator = GuardedAllocator>
template<typename ForwardKeyT, typename ForwardValueT> template<typename ForwardKeyT, typename ForwardValueT>
bool add_override__impl(ForwardKeyT &&key, ForwardValueT &&value) bool add_override__impl(ForwardKeyT &&key, ForwardValueT &&value)
{ {
return this->add_or_modify( auto create_func = [&](ValueT *dst) {
std::forward<ForwardKeyT>(key), new (dst) ValueT(std::forward<ForwardValueT>(value));
[&](ValueT *dst) { return true;
new (dst) ValueT(std::forward<ForwardValueT>(value)); };
return true; auto modify_func = [&](ValueT *old_value) {
}, *old_value = std::forward<ForwardValueT>(value);
[&](ValueT *old_value) { return false;
*old_value = std::forward<ForwardValueT>(value); };
return false; return this->add_or_modify(std::forward<ForwardKeyT>(key), create_func, modify_func);
});
} }
template<typename ForwardKeyT, typename ForwardValueT> template<typename ForwardKeyT, typename ForwardValueT>

@ -2943,7 +2943,8 @@ void ED_region_info_draw(ARegion *ar,
float fill_color[4], float fill_color[4],
const bool full_redraw) const bool full_redraw)
{ {
ED_region_info_draw_multiline(ar, (const char * [2]){text, NULL}, fill_color, full_redraw); const char *text_array[2] = {text, NULL};
ED_region_info_draw_multiline(ar, text_array, fill_color, full_redraw);
} }
#define MAX_METADATA_STR 1024 #define MAX_METADATA_STR 1024