summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2018-12-17 06:30:39 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2018-12-17 06:30:39 +0000
commitce42bd6765e91cb62559bc474410fdaeb9a35a5c (patch)
tree3d01ff7f7cc933a6b040ce7173180e7ff4cde107 /clang/test
parent2b500cbdf109cf40e04e2ad52cfa025ecea5c16f (diff)
downloadbcm5719-llvm-ce42bd6765e91cb62559bc474410fdaeb9a35a5c.tar.gz
bcm5719-llvm-ce42bd6765e91cb62559bc474410fdaeb9a35a5c.zip
[analyzer] MoveChecker: Enable by default as cplusplus.Move.
This checker warns you when you re-use an object after moving it. Mostly developed by Peter Szecsi! Differential Revision: https://reviews.llvm.org/D38675 llvm-svn: 349328
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/mismatched-iterator.cpp5
-rw-r--r--clang/test/Analysis/use-after-move.cpp20
2 files changed, 14 insertions, 11 deletions
diff --git a/clang/test/Analysis/mismatched-iterator.cpp b/clang/test/Analysis/mismatched-iterator.cpp
index 23f54d3f796..756d0954435 100644
--- a/clang/test/Analysis/mismatched-iterator.cpp
+++ b/clang/test/Analysis/mismatched-iterator.cpp
@@ -100,7 +100,7 @@ void good_move_find2(std::vector<int> &v1, std::vector<int> &v2, int n) {
void good_move_find3(std::vector<int> &v1, std::vector<int> &v2, int n) {
auto i0 = v2.cend();
v1 = std::move(v2);
- v2.push_back(n);
+ v2.push_back(n); // expected-warning{{Method called on moved-from object of type 'std::vector'}}
std::find(v2.cbegin(), i0, n); // no-warning
}
@@ -125,6 +125,7 @@ void bad_move_find1(std::vector<int> &v1, std::vector<int> &v2, int n) {
auto i0 = v2.cbegin();
v1 = std::move(v2);
std::find(i0, v2.cend(), n); // expected-warning{{Iterators of different containers used where the same container is expected}}
+ // expected-warning@-1{{Method called on moved-from object of type 'std::vector'}}
}
void bad_insert_find(std::vector<int> &v1, std::vector<int> &v2, int n, int m) {
@@ -167,12 +168,14 @@ void bad_move(std::vector<int> &v1, std::vector<int> &v2) {
const auto i0 = ++v2.cbegin();
v1 = std::move(v2);
v2.erase(i0); // expected-warning{{Container accessed using foreign iterator argument}}
+ // expected-warning@-1{{Method called on moved-from object of type 'std::vector'}}
}
void bad_move_find2(std::vector<int> &v1, std::vector<int> &v2, int n) {
auto i0 = --v2.cend();
v1 = std::move(v2);
std::find(i0, v2.cend(), n); // expected-warning{{Iterators of different containers used where the same container is expected}}
+ // expected-warning@-1{{Method called on moved-from object of type 'std::vector'}}
}
void bad_move_find3(std::vector<int> &v1, std::vector<int> &v2, int n) {
diff --git a/clang/test/Analysis/use-after-move.cpp b/clang/test/Analysis/use-after-move.cpp
index 652f08f45cb..280724512f8 100644
--- a/clang/test/Analysis/use-after-move.cpp
+++ b/clang/test/Analysis/use-after-move.cpp
@@ -1,30 +1,30 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
// RUN: -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
// RUN: -analyzer-config exploration_strategy=unexplored_first_queue\
// RUN: -analyzer-checker debug.ExprInspection
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
// RUN: -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
// RUN: -analyzer-config exploration_strategy=dfs -DDFS=1\
// RUN: -analyzer-checker debug.ExprInspection
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
// RUN: -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
// RUN: -analyzer-config exploration_strategy=unexplored_first_queue\
-// RUN: -analyzer-config alpha.cplusplus.Move:WarnOn=KnownsOnly -DPEACEFUL\
+// RUN: -analyzer-config cplusplus.Move:WarnOn=KnownsOnly -DPEACEFUL\
// RUN: -analyzer-checker debug.ExprInspection
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
// RUN: -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
// RUN: -analyzer-config exploration_strategy=dfs -DDFS=1\
-// RUN: -analyzer-config alpha.cplusplus.Move:WarnOn=KnownsOnly -DPEACEFUL\
+// RUN: -analyzer-config cplusplus.Move:WarnOn=KnownsOnly -DPEACEFUL\
// RUN: -analyzer-checker debug.ExprInspection
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
// RUN: -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
// RUN: -analyzer-config exploration_strategy=unexplored_first_queue\
-// RUN: -analyzer-config alpha.cplusplus.Move:WarnOn=All -DAGGRESSIVE\
+// RUN: -analyzer-config cplusplus.Move:WarnOn=All -DAGGRESSIVE\
// RUN: -analyzer-checker debug.ExprInspection
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.Move -verify %s\
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
// RUN: -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
// RUN: -analyzer-config exploration_strategy=dfs -DDFS=1\
-// RUN: -analyzer-config alpha.cplusplus.Move:WarnOn=All -DAGGRESSIVE\
+// RUN: -analyzer-config cplusplus.Move:WarnOn=All -DAGGRESSIVE\
// RUN: -analyzer-checker debug.ExprInspection
#include "Inputs/system-header-simulator-cxx.h"
OpenPOWER on IntegriCloud