[PATCH] D55307: [analyzer] MoveChecker Pt.6: Suppress the warning for the few move-safe STL classes.

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 5 10:13:24 PST 2018


Szelethus marked an inline comment as done.
Szelethus added a comment.

This looks great!

> Had to pass the checker into the visitor and make some methods non-static because globals with constructors are discouraged.

How about making the set `constexpr`?



================
Comment at: lib/StaticAnalyzer/Checkers/MoveChecker.cpp:122
   private:
+    const MoveChecker *Chk;
     // The tracked region.
----------------
Why not const reference?


================
Comment at: test/Analysis/diagnostics/explicit-suppression.cpp:22
 #ifndef SUPPRESSED
-  // expected-warning at ../Inputs/system-header-simulator-cxx.h:670 {{Called C++ object pointer is null}}
+  // expected-warning at ../Inputs/system-header-simulator-cxx.h:677 {{Called C++ object pointer is null}}
 #endif
----------------
Can't we just change this to `// expected-warning{{Called C++ object pointer is null}}`? This file is so tiny, I think it wouldn't cause much confusion, and  reduces unnecessary maintenance work.


================
Comment at: test/Analysis/use-after-move.cpp:16
 
-namespace std {
-
-typedef __typeof(sizeof(int)) size_t;
-
-template <typename>
-struct remove_reference;
-
-template <typename _Tp>
-struct remove_reference { typedef _Tp type; };
-
-template <typename _Tp>
-struct remove_reference<_Tp &> { typedef _Tp type; };
-
-template <typename _Tp>
-struct remove_reference<_Tp &&> { typedef _Tp type; };
-
-template <typename _Tp>
-typename remove_reference<_Tp>::type &&move(_Tp &&__t) {
-  return static_cast<typename remove_reference<_Tp>::type &&>(__t);
-}
-
-template <typename _Tp>
-_Tp &&forward(typename remove_reference<_Tp>::type &__t) noexcept {
-  return static_cast<_Tp &&>(__t);
-}
-
-template <class T>
-void swap(T &a, T &b) {
-  T c(std::move(a));
-  a = std::move(b);
-  b = std::move(c);
-}
-
-template <typename T>
-class vector {
-public:
-  vector();
-  void push_back(const T &t);
-};
-
-} // namespace std
+#include "Inputs/system-header-simulator-cxx.h"
 
----------------
This is cool, thanks!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55307/new/

https://reviews.llvm.org/D55307





More information about the cfe-commits mailing list