[Small]BitVector::reference: Explicitly default copy construction as it is deprecated...
authorDavid Blaikie <dblaikie@gmail.com>
Tue, 3 Mar 2015 18:39:00 +0000 (18:39 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 3 Mar 2015 18:39:00 +0000 (18:39 +0000)
I tried making these private & friended to the BitVector, but that
didn't work - there's one use of BitVector::reference in Clang that
actually copies it into a local variable & uses it from there, rather
than just using the result of op[] in a temporary expression.

Whether or not this is desired is debatable (we could just fix that one
use in Clang) & it's not clear which way the C++ standard falls on this
for std::bitset's reference type (it has the same bug at least in
libstdc++, but Clang's -Wdeprecated doesn't flag it, because it's in a
standard header)

While it was only BitVector::reference's copy ctor that was referenced
by user code, I made SmallBitVector::reference's copy ctor public too,
for consistency.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231099 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/BitVector.h
include/llvm/ADT/SmallBitVector.h

index 0dbe810d904321224cd38e29f59229ed48ad86cb..f58dd7356c7dd093e8550701260d306ce1a8e3ca 100644 (file)
@@ -53,7 +53,7 @@ public:
       BitPos = Idx % BITWORD_SIZE;
     }
 
-    ~reference() {}
+    reference(const reference&) = default;
 
     reference &operator=(reference t) {
       *this = bool(t);
index 22e8ccd8ea0fc6df22f187a5a8634e48b9029daa..ae3d645396fdb1f808634a44a15fbd9e3bbd0120 100644 (file)
@@ -66,6 +66,8 @@ public:
   public:
     reference(SmallBitVector &b, unsigned Idx) : TheVector(b), BitPos(Idx) {}
 
+    reference(const reference&) = default;
+
     reference& operator=(reference t) {
       *this = bool(t);
       return *this;