[llvm] r269711 - Add a (size, value) constructor to TinyPtrVector.

Richard Smith via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 14:57:47 PDT 2016


Author: rsmith
Date: Mon May 16 16:57:47 2016
New Revision: 269711

URL: http://llvm.org/viewvc/llvm-project?rev=269711&view=rev
Log:
Add a (size, value) constructor to TinyPtrVector.

Modified:
    llvm/trunk/include/llvm/ADT/TinyPtrVector.h

Modified: llvm/trunk/include/llvm/ADT/TinyPtrVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/TinyPtrVector.h?rev=269711&r1=269710&r2=269711&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/TinyPtrVector.h (original)
+++ llvm/trunk/include/llvm/ADT/TinyPtrVector.h Mon May 16 16:57:47 2016
@@ -104,8 +104,16 @@ public:
   /// This also is a constructor for individual array elements due to the single
   /// element constructor for ArrayRef.
   explicit TinyPtrVector(ArrayRef<EltTy> Elts)
-      : Val(Elts.size() == 1 ? PtrUnion(Elts[0])
-                             : PtrUnion(new VecTy(Elts.begin(), Elts.end()))) {}
+      : Val(Elts.empty()
+                ? PtrUnion()
+                : Elts.size() == 1
+                      ? PtrUnion(Elts[0])
+                      : PtrUnion(new VecTy(Elts.begin(), Elts.end()))) {}
+
+  TinyPtrVector(size_t Count, EltTy Value)
+      : Val(Count == 0 ? PtrUnion()
+                       : Count == 1 ? PtrUnion(Value)
+                                    : PtrUnion(new VecTy(Count, Value))) {}
 
   // implicit conversion operator to ArrayRef.
   operator ArrayRef<EltTy>() const {




More information about the llvm-commits mailing list