[LLVMdev] Removing std::vector from APIs (was Re: Mutating the elements of a ConstantArray)
Chris Lattner
clattner at apple.com
Thu May 14 10:08:41 PDT 2009
On May 14, 2009, at 4:56 AM, Jay Foad wrote:
> 2009/4/1 Chris Lattner <clattner at apple.com>:
>> As far API design goes, we're in a mixed state. I'd strongly prefer
>> to get rid of std::vector from the various interfaces, f.e.
>> creating a
>> constant array currently requires passing in an std::vector. For
>> these sorts of interfaces, we should migrate to passing in a
>> "Constant
>> *const* / unsigned" pair. This allows use with a C array, a
>> SmallVector, std::vector, or any other container with sequential
>> storage.
>
> I've made a start on this for the constructors of StructType and
> FunctionType. I've attached the patch so far, which is just enough to
> build lib/VMCore/. Before I continue with it:
Great!
> 1. Is this still the way you want to go?
Yes
> 2. Do you care about breaking out-of-tree code that creates struct or
> function types? I'm happy to convert cfe and llvm-gcc myself.
Nope, we expect people with out of tree code to update themselves.
> 3. Are there any logistical problems with committing a wide-reaching
> patch like this?
I don't think so.
> 3. Any comments on the patch itself?
The one major thing to be aware of is that it isn't safe to use &V[0]
when V is an empty std::vector (though it is safe for smallvector).
When converting code, just be careful so that this doesn't break {} or
void().
One minor thing is that StructType::get(NULL, 0) looks somewhat
strange to me. How about adding a zero-argument version of "get" that
returns the empty struct? That would allow code to use
StructType::get().
Thanks for working on this Jay!
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090514/e0b51d25/attachment.html>
More information about the llvm-dev
mailing list