[llvm] r259942 - More workarounds for undefined behavior exposed when compiling in C++14 with

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 5 23:09:49 PST 2016


Seems it confuses msvc.
See http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/9526
http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/5449

On Sat, Feb 6, 2016 at 7:37 AM Richard Smith via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rsmith
> Date: Fri Feb  5 16:32:52 2016
> New Revision: 259942
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259942&view=rev
> Log:
> More workarounds for undefined behavior exposed when compiling in C++14
> with
> -fsized-deallocation. Disable sized deallocation for all objects derived
> from
> TrailingObjects, as we expect the storage allocated for these objects to be
> larger than the size of their dynamic type.
>
> Modified:
>     llvm/trunk/include/llvm/Support/TrailingObjects.h
>     llvm/trunk/lib/IR/AttributeImpl.h
>     llvm/trunk/unittests/Support/TrailingObjectsTest.cpp
>
> Modified: llvm/trunk/include/llvm/Support/TrailingObjects.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TrailingObjects.h?rev=259942&r1=259941&r2=259942&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/TrailingObjects.h (original)
> +++ llvm/trunk/include/llvm/Support/TrailingObjects.h Fri Feb  5 16:32:52
> 2016
> @@ -79,6 +79,11 @@ public:
>
>  /// The base class for TrailingObjects* classes.
>  class TrailingObjectsBase {
> +public:
> +  /// Disable sized deallocation for all objects with trailing object
> storage;
> +  /// the inferred size will typically not be correct.
> +  void operator delete(void *P) { return ::operator delete(P); }
> +
>  protected:
>    /// OverloadToken's purpose is to allow specifying function overloads
>    /// for different types, without actually taking the types as
> @@ -290,7 +295,8 @@ class TrailingObjects : private trailing
>    }
>
>  public:
> -  // make this (privately inherited) class public.
> +  // Make these (privately inherited) members public.
> +  using ParentType::operator delete;
>    using ParentType::OverloadToken;
>
>    /// Returns a pointer to the trailing object array of the given type
>
> Modified: llvm/trunk/lib/IR/AttributeImpl.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AttributeImpl.h?rev=259942&r1=259941&r2=259942&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/AttributeImpl.h (original)
> +++ llvm/trunk/lib/IR/AttributeImpl.h Fri Feb  5 16:32:52 2016
> @@ -171,6 +171,8 @@ class AttributeSetNode final
>    void operator=(const AttributeSetNode &) = delete;
>    AttributeSetNode(const AttributeSetNode &) = delete;
>  public:
> +  using TrailingObjects::operator delete;
> +
>    static AttributeSetNode *get(LLVMContext &C, ArrayRef<Attribute> Attrs);
>
>    bool hasAttribute(Attribute::AttrKind Kind) const {
> @@ -266,6 +268,8 @@ public:
>      }
>    }
>
> +  using TrailingObjects::operator delete;
> +
>    /// \brief Get the context that created this AttributeSetImpl.
>    LLVMContext &getContext() { return Context; }
>
>
> Modified: llvm/trunk/unittests/Support/TrailingObjectsTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TrailingObjectsTest.cpp?rev=259942&r1=259941&r2=259942&view=diff
>
> ==============================================================================
> --- llvm/trunk/unittests/Support/TrailingObjectsTest.cpp (original)
> +++ llvm/trunk/unittests/Support/TrailingObjectsTest.cpp Fri Feb  5
> 16:32:52 2016
> @@ -34,6 +34,7 @@ public:
>      void *Mem = ::operator new(totalSizeToAlloc<short>(NumShorts));
>      return new (Mem) Class1(ShortArray, NumShorts);
>    }
> +  using TrailingObjects::operator delete;
>
>    short get(unsigned Num) const { return
> getTrailingObjects<short>()[Num]; }
>
> @@ -78,6 +79,7 @@ public:
>        *C->getTrailingObjects<double>() = D;
>      return C;
>    }
> +  using TrailingObjects::operator delete;
>
>    short getShort() const {
>      if (!HasShort)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160206/8d03fbfa/attachment.html>


More information about the llvm-commits mailing list