diff options
| author | Fangrui Song <maskray@google.com> | 2019-04-13 13:52:11 +0000 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2019-04-13 13:52:11 +0000 |
| commit | 67c29e2294ed83cf3f725043a236af05411b2281 (patch) | |
| tree | 601a8eefe2677efaeec3f5ddae1a1c9dcdfc926e | |
| parent | 41e284b9c3b35d0965769775e7d21e672b7ea6b0 (diff) | |
| download | bcm5719-llvm-67c29e2294ed83cf3f725043a236af05411b2281.tar.gz bcm5719-llvm-67c29e2294ed83cf3f725043a236af05411b2281.zip | |
[ADT] Fix OwningArrayRef's move ctor
llvm-svn: 358332
| -rw-r--r-- | llvm/include/llvm/ADT/ArrayRef.h | 2 | ||||
| -rw-r--r-- | llvm/unittests/ADT/ArrayRefTest.cpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h index 75bb7d690cc..773c88f7c9f 100644 --- a/llvm/include/llvm/ADT/ArrayRef.h +++ b/llvm/include/llvm/ADT/ArrayRef.h @@ -430,7 +430,7 @@ namespace llvm { std::copy(Data.begin(), Data.end(), this->begin()); } - OwningArrayRef(OwningArrayRef &&Other) { *this = Other; } + OwningArrayRef(OwningArrayRef &&Other) { *this = std::move(Other); } OwningArrayRef &operator=(OwningArrayRef &&Other) { delete[] this->data(); diff --git a/llvm/unittests/ADT/ArrayRefTest.cpp b/llvm/unittests/ADT/ArrayRefTest.cpp index a5609f89ff9..4f8275c4bb3 100644 --- a/llvm/unittests/ADT/ArrayRefTest.cpp +++ b/llvm/unittests/ADT/ArrayRefTest.cpp @@ -248,6 +248,13 @@ TEST(ArrayRefTest, makeArrayRef) { EXPECT_TRUE(AR2.equals(AR2Ref)); } +TEST(ArrayRefTest, OwningArrayRef) { + static const int A1[] = {0, 1}; + OwningArrayRef<int> A(makeArrayRef(A1)); + OwningArrayRef<int> B(std::move(A)); + EXPECT_EQ(A.data(), nullptr); +} + static_assert(is_trivially_copyable<ArrayRef<int>>::value, "trivially copyable"); |

