]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Exception fixes and cleanup (clang-tidy) 5940/head
authorTimo Heister <timo.heister@gmail.com>
Wed, 21 Feb 2018 18:05:44 +0000 (13:05 -0500)
committerTimo Heister <timo.heister@gmail.com>
Wed, 21 Feb 2018 22:02:57 +0000 (17:02 -0500)
- mark DeclExceptionX with NOLINT (ignore that we copy args)
- adjust some DeclExceptionX arguments
- cleanup/simplify string concat that clang-tidy complains about

include/deal.II/base/exceptions.h
source/base/exceptions.cc

index b8ca87b1a949585991f3d8f6921bbf651b54268a..2132351efa5a4c53a6da7ffb972cd61bb0d25313 100644 (file)
@@ -468,7 +468,7 @@ namespace deal_II_exceptions
 #define DeclException1(Exception1, type1, outsequence)                    \
   class Exception1 : public dealii::ExceptionBase {                       \
   public:                                                                 \
-    Exception1 (const type1 a1) : arg1 (a1) {}                            \
+    Exception1 (const type1 a1) : arg1 (a1) {}    /*NOLINT*/              \
     virtual ~Exception1 () noexcept {}                                    \
     virtual void print_info (std::ostream &out) const {                   \
       out << "    " outsequence << std::endl;                             \
@@ -487,7 +487,7 @@ namespace deal_II_exceptions
 #define DeclException2(Exception2, type1, type2, outsequence)             \
   class Exception2 : public dealii::ExceptionBase {                       \
   public:                                                                 \
-    Exception2 (const type1 a1, const type2 a2) :                         \
+    Exception2 (const type1 a1, const type2 a2) : /*NOLINT*/              \
       arg1 (a1), arg2(a2) {}                                              \
     virtual ~Exception2 () noexcept {}                                    \
     virtual void print_info (std::ostream &out) const {                   \
@@ -508,7 +508,7 @@ namespace deal_II_exceptions
 #define DeclException3(Exception3, type1, type2, type3, outsequence)      \
   class Exception3 : public dealii::ExceptionBase {                       \
   public:                                                                 \
-    Exception3 (const type1 a1, const type2 a2, const type3 a3) :         \
+    Exception3 (const type1 a1, const type2 a2, const type3 a3) : /*NOLINT*/ \
       arg1 (a1), arg2(a2), arg3(a3) {}                                    \
     virtual ~Exception3 () noexcept {}                                    \
     virtual void print_info (std::ostream &out) const {                   \
@@ -530,8 +530,8 @@ namespace deal_II_exceptions
 #define DeclException4(Exception4, type1, type2, type3, type4, outsequence) \
   class Exception4 : public dealii::ExceptionBase {                       \
   public:                                                                 \
-    Exception4 (const type1 a1, const type2 a2,                           \
-                const type3 a3, const type4 a4) :                         \
+    Exception4 (const type1 a1, const type2 a2,   /*NOLINT*/              \
+                const type3 a3, const type4 a4) : /*NOLINT*/              \
       arg1 (a1), arg2(a2), arg3(a3), arg4(a4) {}                          \
     virtual ~Exception4 () noexcept {}                                    \
     virtual void print_info (std::ostream &out) const {                   \
@@ -554,8 +554,8 @@ namespace deal_II_exceptions
 #define DeclException5(Exception5, type1, type2, type3, type4, type5, outsequence) \
   class Exception5 : public dealii::ExceptionBase {                       \
   public:                                                                 \
-    Exception5 (const type1 a1, const type2 a2, const type3 a3,           \
-                const type4 a4, const type5 a5) :                         \
+    Exception5 (const type1 a1, const type2 a2, const type3 a3,/*NOLINT*/ \
+                const type4 a4, const type5 a5) :              /*NOLINT*/ \
       arg1 (a1), arg2(a2), arg3(a3), arg4(a4), arg5(a5) {}                \
     virtual ~Exception5 () noexcept {}                                    \
     virtual void print_info (std::ostream &out) const {                   \
index 64f8f31425d9770952abb4b5bdbe084eb02e2aa8..b2b113ed3e166ad84615d5e4de59b64bef2e1329 100644 (file)
@@ -244,6 +244,9 @@ void ExceptionBase::print_stack_trace (std::ostream &out) const
       std::string functionname = stacktrace_entry.substr (pos_start+1,
                                                           pos_end-pos_start-1);
 
+      stacktrace_entry = stacktrace_entry.substr(0, pos_start);
+      stacktrace_entry += ": ";
+
       // demangle, and if successful replace old mangled string by
       // unmangled one (skipping address and offset). treat "main"
       // differently, since it is apparently demangled as "unsigned int"
@@ -266,28 +269,16 @@ void ExceptionBase::print_stack_trace (std::ostream &out) const
             realname.erase (realname.find (", boost::tuples::null_type>"),
                             std::string (", boost::tuples::null_type").size());
 
-          stacktrace_entry = stacktrace_entry.substr(0, pos_start)
-                             +
-                             ": "
-                             +
-                             realname;
+          stacktrace_entry += realname;
         }
       else
-        stacktrace_entry = stacktrace_entry.substr(0, pos_start)
-                           +
-                           ": "
-                           +
-                           functionname;
+        stacktrace_entry += functionname;
 
       free (p);
 
 #else
 
-      stacktrace_entry = stacktrace_entry.substr(0, pos_start)
-                         +
-                         ": "
-                         +
-                         functionname;
+      stacktrace_entry += functionname;
 #endif
 
       // then output what we have

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.