Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / selection / parser_internal.h
index b8e489f6e3d187966a3c0ec250b7f4c171da5d0d..e99aa0375050c6c509efd914ef91ce0c11f50190 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2014,2015,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015,2017,2018,2019, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -58,8 +58,7 @@
 #include "selelem.h"
 
 //! Error handler needed by Bison.
-static void
-yyerror(YYLTYPE *location, yyscan_t scanner, char const *s)
+static void yyerror(YYLTYPE* location, yyscan_t scanner, char const* s)
 {
     try
     {
@@ -73,26 +72,26 @@ yyerror(YYLTYPE *location, yyscan_t scanner, char const *s)
         }
         _gmx_sel_lexer_set_exception(scanner, std::make_exception_ptr(ex));
     }
-    catch (const std::exception &)
+    catch (const std::exception&)
     {
         _gmx_sel_lexer_set_exception(scanner, std::current_exception());
     }
 }
 
 //! Logic for computing the location of the output of Bison reduction.
-#define YYLLOC_DEFAULT(Current, Rhs, N)                          \
-    do {                                                         \
-        if ((N) != 0)                                              \
-        {                                                        \
-            (Current).startIndex = YYRHSLOC(Rhs, 1).startIndex;  \
-            (Current).endIndex   = YYRHSLOC(Rhs, N).endIndex;    \
-        }                                                        \
-        else                                                     \
-        {                                                        \
-            (Current).startIndex = (Current).endIndex =          \
-                    YYRHSLOC(Rhs, 0).endIndex;                   \
-        }                                                        \
-        _gmx_sel_lexer_set_current_location(scanner, (Current)); \
+#define YYLLOC_DEFAULT(Current, Rhs, N)                                            \
+    do                                                                             \
+    {                                                                              \
+        if ((N) != 0)                                                              \
+        {                                                                          \
+            (Current).startIndex = YYRHSLOC(Rhs, 1).startIndex;                    \
+            (Current).endIndex   = YYRHSLOC(Rhs, N).endIndex;                      \
+        }                                                                          \
+        else                                                                       \
+        {                                                                          \
+            (Current).startIndex = (Current).endIndex = YYRHSLOC(Rhs, 0).endIndex; \
+        }                                                                          \
+        _gmx_sel_lexer_set_current_location(scanner, (Current));                   \
     } while (0)
 
 /*! \brief
@@ -122,28 +121,29 @@ yyerror(YYLTYPE *location, yyscan_t scanner, char const *s)
  */
 //! Starts an action that may throw exceptions.
 #define BEGIN_ACTION \
-    try {
+    try              \
+    {
 //! Finishes an action that may throw exceptions.
-#define END_ACTION                                              \
-    }                                                           \
-    catch (std::exception &ex)                                  \
-    {                                                           \
-        if (_gmx_selparser_handle_exception(scanner, &ex))      \
-        {                                                       \
-            YYERROR;                                            \
-        }                                                       \
-        else                                                    \
-        {                                                       \
-            YYABORT;                                            \
-        }                                                       \
+#define END_ACTION                                         \
+    }                                                      \
+    catch (std::exception & ex)                            \
+    {                                                      \
+        if (_gmx_selparser_handle_exception(scanner, &ex)) \
+        {                                                  \
+            YYERROR;                                       \
+        }                                                  \
+        else                                               \
+        {                                                  \
+            YYABORT;                                       \
+        }                                                  \
     }
 //! Finishes an action that may throw exceptions and does not support resuming.
-#define END_ACTION_TOPLEVEL                                     \
-    }                                                           \
-    catch (const std::exception &)                              \
-    {                                                           \
+#define END_ACTION_TOPLEVEL                                              \
+    }                                                                    \
+    catch (const std::exception&)                                        \
+    {                                                                    \
         _gmx_sel_lexer_set_exception(scanner, std::current_exception()); \
-        YYABORT;                                                \
+        YYABORT;                                                         \
     }
 //!\}
 
@@ -164,8 +164,8 @@ yyerror(YYLTYPE *location, yyscan_t scanner, char const *s)
  * Does not throw for smart pointer types.  If used with types that may throw,
  * the order of operations should be such that it is exception-safe.
  */
-template <typename ValueType> static
-ValueType get(ValueType *src)
+template<typename ValueType>
+static ValueType get(ValueType* src)
 {
     GMX_RELEASE_ASSERT(src != nullptr, "Semantic value pointers should be non-NULL");
     const std::unique_ptr<ValueType> srcGuard(src);
@@ -184,8 +184,8 @@ ValueType get(ValueType *src)
  * This should be the last statement before ::END_ACTION, except for a
  * possible ::CHECK_SEL.
  */
-template <typename ValueType> static
-void set(ValueType * &dest, ValueType value)
+template<typename ValueType>
+static void set(ValueType*& dest, ValueType value)
 {
     dest = new ValueType(std::move(value));
 }
@@ -201,8 +201,8 @@ void set(ValueType * &dest, ValueType value)
  * This should be the last statement before ::END_ACTION, except for a
  * possible ::CHECK_SEL.
  */
-template <typename ValueType> static
-void set_empty(ValueType * &dest)
+template<typename ValueType>
+static void set_empty(ValueType*& dest)
 {
     dest = new ValueType;
 }
@@ -217,9 +217,10 @@ void set_empty(ValueType * &dest)
  * exceptions.
  */
 #define CHECK_SEL(sel) \
-    if (!*(sel)) { \
-        delete (sel); \
-        YYERROR; \
+    if (!*(sel))       \
+    {                  \
+        delete (sel);  \
+        YYERROR;       \
     }
 
 #endif