summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/cppcoreguidelines-owning-memory-containers.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2019-10-11 12:05:42 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2019-10-11 12:05:42 +0000
commit885c559369fe3d6323898c17787bd0454065fc34 (patch)
treeba43b987e078f4c2a033acc71ad3d7f1ee385a11 /clang-tools-extra/test/clang-tidy/cppcoreguidelines-owning-memory-containers.cpp
parent9f6a873268e1ad9855873d9d8007086c0d01cf4f (diff)
downloadbcm5719-llvm-885c559369fe3d6323898c17787bd0454065fc34.tar.gz
bcm5719-llvm-885c559369fe3d6323898c17787bd0454065fc34.zip
[ClangTidy] Separate tests for infrastructure and checkers
Summary: This change moves tests for checkers and infrastructure into separate directories, making it easier to find infrastructure tests. Tests for checkers are already easy to find because they are named after the checker. Tests for infrastructure were difficult to find because they were outnumbered by tests for checkers. Now they are in a separate directory. Reviewers: jfb, jdoerfert, lebedev.ri Subscribers: srhines, nemanjai, aheejin, kbarton, christof, mgrang, arphaman, jfb, lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68807 llvm-svn: 374540
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/cppcoreguidelines-owning-memory-containers.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/cppcoreguidelines-owning-memory-containers.cpp62
1 files changed, 0 insertions, 62 deletions
diff --git a/clang-tools-extra/test/clang-tidy/cppcoreguidelines-owning-memory-containers.cpp b/clang-tools-extra/test/clang-tidy/cppcoreguidelines-owning-memory-containers.cpp
deleted file mode 100644
index d39e697c6bd..00000000000
--- a/clang-tools-extra/test/clang-tidy/cppcoreguidelines-owning-memory-containers.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-owning-memory %t
-
-namespace gsl {
-template <typename T>
-using owner = T;
-}
-
-namespace std {
-
-// Not actually a vector, but more a dynamic, fixed size array. Just to demonstrate
-// functionality or the lack of the same.
-template <typename T>
-class vector {
-public:
- vector(unsigned long size, T val) : data{new T[size]}, size{size} {
- for (unsigned long i = 0ul; i < size; ++i) {
- data[i] = val;
- }
- }
-
- T *begin() { return data; }
- T *end() { return &data[size]; }
- T &operator[](unsigned long index) { return data[index]; }
-
-private:
- T *data;
- unsigned long size;
-};
-
-} // namespace std
-
-// All of the following codesnippets should be valid with appropriate 'owner<>' anaylsis,
-// but currently the type information of 'gsl::owner<>' gets lost in typededuction.
-int main() {
- std::vector<gsl::owner<int *>> OwnerStdVector(100, nullptr);
-
- // Rangebased looping in resource vector.
- for (auto *Element : OwnerStdVector) {
- Element = new int(42);
- // CHECK-NOTES: [[@LINE-1]]:5: warning: assigning newly created 'gsl::owner<>' to non-owner 'int *'
- }
- for (auto *Element : OwnerStdVector) {
- delete Element;
- // CHECK-NOTES: [[@LINE-1]]:5: warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead
- // CHECK-NOTES: [[@LINE-3]]:8: note: variable declared here
- }
-
- // Indexbased looping in resource vector.
- for (int i = 0; i < 100; ++i) {
- OwnerStdVector[i] = new int(42);
- // CHECK-NOTES: [[@LINE-1]]:5: warning: assigning newly created 'gsl::owner<>' to non-owner 'int *'
- }
- for (int i = 0; i < 100; ++i) {
- delete OwnerStdVector[i];
- // CHECK-NOTES: [[@LINE-1]]:5: warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead
- // CHECK-NOTES: [[@LINE-21]]:3: note: variable declared here
- // A note gets emitted here pointing to the return value of the operator[] from the
- // vector implementation. Maybe this is considered misleading.
- }
-
- return 0;
-}
OpenPOWER on IntegriCloud