[llvm] r339367 - Fix few g++ 8 warning with non obvious copy object operations

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 13 15:48:04 PDT 2018


On 09/13/2018 03:36 PM, David Blaikie via llvm-commits wrote:
> Also it doesn't look like this code was reviewed - could you revert it?
> 

This is what I thought too, but I realized I had commented on the
the actual commit: https://reviews.llvm.org/rL339367 and not
the phabricator review: https://reviews.llvm.org/D50296.  According
to the phabricator review you did review the patch.


-Tom

> On Thu, Aug 9, 2018 at 11:29 AM David Carlier via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> 
>     Author: devnexen
>     Date: Thu Aug  9 11:29:07 2018
>     New Revision: 339367
> 
>     URL: http://llvm.org/viewvc/llvm-project?rev=339367&view=rev
>     Log:
>     Fix few g++ 8 warning with non obvious copy object operations
> 
>     Reviewers: dblaikie, dexonsmith
> 
>     Reviewed By: dblaikie
> 
>     Differential Revision: https://reviews.llvm.org/D50296
> 
>     Modified:
>         llvm/trunk/include/llvm/ADT/DenseMap.h
>         llvm/trunk/include/llvm/ADT/SmallVector.h
> 
>     Modified: llvm/trunk/include/llvm/ADT/DenseMap.h
>     URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=339367&r1=339366&r2=339367&view=diff
>     ==============================================================================
>     --- llvm/trunk/include/llvm/ADT/DenseMap.h (original)
>     +++ llvm/trunk/include/llvm/ADT/DenseMap.h Thu Aug  9 11:29:07 2018
>     @@ -393,7 +393,7 @@ protected:
>          setNumTombstones(other.getNumTombstones());
> 
>          if (isPodLike<KeyT>::value && isPodLike<ValueT>::value)
>     -      memcpy(getBuckets(), other.getBuckets(),
>     +      memcpy(reinterpret_cast<void *>(getBuckets()), other.getBuckets(),
>                   getNumBuckets() * sizeof(BucketT));
>          else
>            for (size_t i = 0; i < getNumBuckets(); ++i) {
> 
>     Modified: llvm/trunk/include/llvm/ADT/SmallVector.h
>     URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=339367&r1=339366&r2=339367&view=diff
>     ==============================================================================
>     --- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
>     +++ llvm/trunk/include/llvm/ADT/SmallVector.h Thu Aug  9 11:29:07 2018
>     @@ -299,7 +299,7 @@ protected:
>          // use memcpy here. Note that I and E are iterators and thus might be
>          // invalid for memcpy if they are equal.
>          if (I != E)
>     -      memcpy(Dest, I, (E - I) * sizeof(T));
>     +      memcpy(reinterpret_cast<void *>(Dest), I, (E - I) * sizeof(T));
>        }
> 
>        /// Double the size of the allocated memory, guaranteeing space for at
>     @@ -310,7 +310,7 @@ public:
>        void push_back(const T &Elt) {
>          if (LLVM_UNLIKELY(this->size() >= this->capacity()))
>            this->grow();
>     -    memcpy(this->end(), &Elt, sizeof(T));
>     +    memcpy(reinterpret_cast<void *>(this->end()), &Elt, sizeof(T));
>          this->set_size(this->size() + 1);
>        }
> 
> 
> 
>     _______________________________________________
>     llvm-commits mailing list
>     llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
>     http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 



More information about the llvm-commits mailing list