Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Declare move constructors with "noexcept".
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 27 Feb 2020 20:28:53 +0000 (21:28 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 27 Feb 2020 21:36:40 +0000 (22:36 +0100)
include/simgrid/Exception.hpp
include/simgrid/kernel/future.hpp
include/simgrid/simix/blocking_simcall.hpp
include/xbt/functional.hpp
include/xbt/string.hpp
src/mc/sosp/ChunkedData.hpp

index 613ca5a..159e87b 100644 (file)
@@ -85,6 +85,8 @@ public:
       : std::runtime_error(std::move(message)), throwpoint_(std::move(throwpoint))
   {
   }
+  Exception(const Exception&)     = default;
+  Exception(Exception&&) noexcept = default;
   ~Exception(); // DO NOT define it here -- see Exception.cpp for a rationale
 
   /** Return the information about where the exception was thrown */
@@ -106,6 +108,8 @@ public:
       : Exception(std::move(throwpoint), std::move(message))
   {
   }
+  TimeoutException(const TimeoutException&)     = default;
+  TimeoutException(TimeoutException&&) noexcept = default;
 };
 
 XBT_ATTRIB_DEPRECATED_v328("Please use simgrid::TimeoutException") typedef TimeoutException TimeoutError;
@@ -117,6 +121,8 @@ public:
       : Exception(std::move(throwpoint), std::move(message))
   {
   }
+  HostFailureException(const HostFailureException&)     = default;
+  HostFailureException(HostFailureException&&) noexcept = default;
 };
 
 /** Exception raised when a communication fails because of the network or because of the remote host */
@@ -126,6 +132,8 @@ public:
       : Exception(std::move(throwpoint), std::move(message))
   {
   }
+  NetworkFailureException(const NetworkFailureException&)     = default;
+  NetworkFailureException(NetworkFailureException&&) noexcept = default;
 };
 
 /** Exception raised when a storage fails */
@@ -135,6 +143,8 @@ public:
       : Exception(std::move(throwpoint), std::move(message))
   {
   }
+  StorageFailureException(const StorageFailureException&)     = default;
+  StorageFailureException(StorageFailureException&&) noexcept = default;
 };
 
 /** Exception raised when a VM fails */
@@ -144,6 +154,8 @@ public:
       : Exception(std::move(throwpoint), std::move(message))
   {
   }
+  VmFailureException(const VmFailureException&)     = default;
+  VmFailureException(VmFailureException&&) noexcept = default;
 };
 
 /** Exception raised when something got canceled before completion */
@@ -153,6 +165,8 @@ public:
       : Exception(std::move(throwpoint), std::move(message))
   {
   }
+  CancelException(const CancelException&)     = default;
+  CancelException(CancelException&&) noexcept = default;
 };
 
 /** Exception raised when something is going wrong during the simulation tracing */
@@ -162,6 +176,8 @@ public:
       : Exception(std::move(throwpoint), std::move(message))
   {
   }
+  TracingError(const TracingError&)     = default;
+  TracingError(TracingError&&) noexcept = default;
 };
 
 /** Exception raised when something is going wrong during the parsing of XML files */
@@ -171,6 +187,8 @@ public:
       : Exception(XBT_THROW_POINT, xbt::string_printf("Parse error at %s:%d: %s", file.c_str(), line, msg.c_str()))
   {
   }
+  ParseError(const ParseError&)     = default;
+  ParseError(ParseError&&) noexcept = default;
 };
 
 class XBT_PUBLIC ForcefulKillException {
index 7a1a1d3..4891f13 100644 (file)
@@ -283,13 +283,9 @@ public:
 
   // Move type:
   Future(Future&) = delete;
-  Future& operator=(Future&) = delete;
-  Future(Future&& that) : state_(std::move(that.state_)) {}
-  Future& operator=(Future&& that)
-  {
-    state_ = std::move(that.state_);
-    return *this;
-  }
+  Future& operator=(const Future&) = delete;
+  Future(Future&&) noexcept        = default;
+  Future& operator=(Future&&) noexcept = default;
 
   /** Whether the future is valid:.
    *
@@ -451,9 +447,9 @@ public:
   // Move type
   Promise(Promise const&) = delete;
   Promise& operator=(Promise const&) = delete;
-  Promise(Promise&& that) : state_(std::move(that.state_)) { std::swap(future_get_, that.future_get_); }
+  Promise(Promise&& that) noexcept : state_(std::move(that.state_)) { std::swap(future_get_, that.future_get_); }
 
-  Promise& operator=(Promise&& that)
+  Promise& operator=(Promise&& that) noexcept
   {
     this->state_ = std::move(that.state_);
     this->future_get_ = that.future_get_;
@@ -508,8 +504,8 @@ public:
   // Move type
   Promise(Promise const&) = delete;
   Promise& operator=(Promise const&) = delete;
-  Promise(Promise&& that) : state_(std::move(that.state_)) { std::swap(future_get_, that.future_get_); }
-  Promise& operator=(Promise&& that)
+  Promise(Promise&& that) noexcept : state_(std::move(that.state_)) { std::swap(future_get_, that.future_get_); }
+  Promise& operator=(Promise&& that) noexcept
   {
     this->state_ = std::move(that.state_);
     this->future_get_ = that.future_get_;
index c4d550d..e524ec5 100644 (file)
@@ -80,6 +80,8 @@ class Future {
 public:
   Future() { /* Nothing to do*/}
   explicit Future(simgrid::kernel::Future<T> future) : future_(std::move(future)) {}
+  Future(Future&&) noexcept = default;
+  Future& operator=(Future&&) noexcept = default;
 
   bool valid() const { return future_.valid(); }
   T get()
index b7e361e..145e461 100644 (file)
@@ -162,7 +162,7 @@ public:
 
   Task(Task const&) = delete;
 
-  Task(Task&& that)
+  Task(Task&& that) noexcept
   {
     if (that.vtable_ && that.vtable_->move)
       that.vtable_->move(buffer_, that.buffer_);
@@ -172,7 +172,7 @@ public:
     that.vtable_ = nullptr;
   }
   Task& operator=(Task const& that) = delete;
-  Task& operator=(Task&& that)
+  Task& operator=(Task&& that) noexcept
   {
     this->clear();
     if (that.vtable_ && that.vtable_->move)
index 89311f0..99520e6 100644 (file)
@@ -89,7 +89,7 @@ public:
   string() : string(&NUL, 0) {}
   explicit string(const char* s) : string(s, strlen(s)) {}
   string(string const& s) : string(s.c_str(), s.size()) {}
-  string(string&& s) : str(std::move(s.str))
+  string(string&& s) noexcept : str(std::move(s.str))
   {
     s.str.len  = 0;
     s.str.data = &NUL;
index 352214c..11d8316 100644 (file)
@@ -46,7 +46,7 @@ public:
     for (std::size_t const& pageno : pagenos_)
       store_->ref_page(pageno);
   }
-  ChunkedData(ChunkedData&& that) : pagenos_(std::move(that.pagenos_))
+  ChunkedData(ChunkedData&& that) noexcept : pagenos_(std::move(that.pagenos_))
   {
     std::swap(store_, that.store_);
     that.pagenos_.clear();
@@ -62,7 +62,7 @@ public:
     }
     return *this;
   }
-  ChunkedData& operator=(ChunkedData&& that)
+  ChunkedData& operator=(ChunkedData&& that) noexcept
   {
     this->clear();
     store_      = that.store_;