From 6fec87f3b7dd332f008bc3f21cc0c63f244270b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 20 Nov 2024 14:18:11 +0100
Subject: [PATCH] Bump to clang-format 16
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

– enable new options InsertNewlineAtEOF and RemoveSemicolon
– reformat the code accordingly

(manually cherry picked from commit 4ecb7fe5981dba35fa0fd1032087858d7cd117fd)
---
 .clang-format                                        | 2 ++
 mex/sources/k_order_welfare/approximation_welfare.cc | 2 +-
 mex/sources/libkorder/kord/kord_exception.hh         | 8 ++++----
 mex/sources/libkorder/tl/permutation.hh              | 2 +-
 mex/sources/libkorder/tl/tl_exception.hh             | 4 ++--
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/.clang-format b/.clang-format
index b2ce7c0e6d..d617cd54e8 100644
--- a/.clang-format
+++ b/.clang-format
@@ -19,9 +19,11 @@ BreakInheritanceList: AfterColon
 Cpp11BracedListStyle: true
 DeriveLineEnding: false
 IndentPPDirectives: AfterHash
+InsertNewlineAtEOF: true
 PackConstructorInitializers: NextLine
 PPIndentWidth: 1
 PointerAlignment: Left
+RemoveSemicolon: true
 SpaceAfterTemplateKeyword: false
 SpaceBeforeParens: ControlStatements
 SpaceBeforeCpp11BracedList: true
diff --git a/mex/sources/k_order_welfare/approximation_welfare.cc b/mex/sources/k_order_welfare/approximation_welfare.cc
index bb56d6e49b..da65f4d826 100644
--- a/mex/sources/k_order_welfare/approximation_welfare.cc
+++ b/mex/sources/k_order_welfare/approximation_welfare.cc
@@ -71,4 +71,4 @@ void
 ApproximationWelfare::saveRuleDerivs(const FGSContainer& W)
 {
   cond_ders = std::make_unique<FGSContainer>(W);
-}
\ No newline at end of file
+}
diff --git a/mex/sources/libkorder/kord/kord_exception.hh b/mex/sources/libkorder/kord/kord_exception.hh
index 83508ab924..da2ddefd36 100644
--- a/mex/sources/libkorder/kord/kord_exception.hh
+++ b/mex/sources/libkorder/kord/kord_exception.hh
@@ -31,14 +31,14 @@
 #define KORD_RAISE(mes) throw KordException(__FILE__, __LINE__, mes);
 
 #define KORD_RAISE_IF(expr, mes)                                                                   \
- if (expr)                                                                                         \
-  throw KordException(__FILE__, __LINE__, mes);
+  if (expr)                                                                                        \
+    throw KordException(__FILE__, __LINE__, mes);
 
 #define KORD_RAISE_X(mes, c) throw KordException(__FILE__, __LINE__, mes, c);
 
 #define KORD_RAISE_IF_X(expr, mes, c)                                                              \
- if (expr)                                                                                         \
-  throw KordException(__FILE__, __LINE__, mes, c);
+  if (expr)                                                                                        \
+    throw KordException(__FILE__, __LINE__, mes, c);
 
 class KordException
 {
diff --git a/mex/sources/libkorder/tl/permutation.hh b/mex/sources/libkorder/tl/permutation.hh
index a799532a0e..e6ead9ccc1 100644
--- a/mex/sources/libkorder/tl/permutation.hh
+++ b/mex/sources/libkorder/tl/permutation.hh
@@ -87,7 +87,7 @@ public:
   explicit Permutation(const IntSequence& s) : permap(s.size())
   {
     computeSortingMap(s);
-  };
+  }
   Permutation(const Permutation& p1, const Permutation& p2) : permap(p2.permap)
   {
     p1.apply(permap);
diff --git a/mex/sources/libkorder/tl/tl_exception.hh b/mex/sources/libkorder/tl/tl_exception.hh
index ff5adc8061..3c920e86ce 100644
--- a/mex/sources/libkorder/tl/tl_exception.hh
+++ b/mex/sources/libkorder/tl/tl_exception.hh
@@ -62,8 +62,8 @@
 #define TL_RAISE(mes) throw TLException(__FILE__, __LINE__, mes)
 
 #define TL_RAISE_IF(expr, mes)                                                                     \
- if (TL_DEBUG >= TL_DEBUG_EXCEPTION && (expr))                                                     \
-  throw TLException(__FILE__, __LINE__, mes);
+  if (TL_DEBUG >= TL_DEBUG_EXCEPTION && (expr))                                                    \
+    throw TLException(__FILE__, __LINE__, mes);
 
 /* Primitive exception class containing file name, line number and message. */
 
-- 
GitLab