[PATCH] [ADT] IntervalMap: use AlignedCharArray.

David Blaikie dblaikie at gmail.com
Thu Mar 12 09:55:27 PDT 2015


================
Comment at: include/llvm/ADT/IntervalMap.h:970
@@ -968,9 +969,3 @@
   // The root data is either a RootLeaf or a RootBranchData instance.
-  // We can't put them in a union since C++03 doesn't allow non-trivial
-  // constructors in unions.
-  // Instead, we use a char array with pointer alignment. The alignment is
-  // ensured by the allocator member in the class, but still verified in the
-  // constructor. We don't support keys or values that are more aligned than a
-  // pointer.
-  char data[RootDataSize];
+  AlignedCharArray<AlignOf<RootLeaf>::Alignment, RootDataSize> data;
 
----------------
Like llvm::Optional you could probably use AlignedCharArrayUnion to save you having to pull out the alignment and size explicitly?

AlignedCharArrayUnion<RootLeaf, RootBranchData> should give you something with sufficient size and alignment for either type, if I'm not mistaken

http://reviews.llvm.org/D8268

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list