[llvm-commits] [PATCH] C Bindings: Allow reading MDNode operands
Villmow, Micah
Micah.Villmow at amd.com
Wed Sep 19 09:32:02 PDT 2012
Yeah, that is better.
> -----Original Message-----
> From: Anthony Bryant [mailto:antjbryant at gmail.com]
> Sent: Wednesday, September 19, 2012 9:29 AM
> To: Villmow, Micah; llvm-commits at cs.uiuc.edu
> Subject: Re: [llvm-commits] [PATCH] C Bindings: Allow reading MDNode
> operands
>
> On 19 September 2012 16:28, Villmow, Micah <Micah.Villmow at amd.com>
> wrote:
> > + * The passed LLVMValueRef pointer should refer to an array of
> > + LLVMValueRef at
> > + * least LLVMGetMDNodeNumOperands long.
> >
> > I think a better wording here would be something like:
> > " The passed LLVMValueRef pointer should point to memory that
> contains
> > enough space to hold the number of LLVMValueRef's returned by
> LLVMGetMDNodeNumOperands."
>
> I basically copied that comment from the one that retrieves operands
> from named metadata.
> Is this version better (attached)?
>
> > +void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest) {
> > + const MDNode *N = cast<MDNode>(unwrap(V));
> > + const unsigned numOperands = N->getNumOperands();
> > + for (unsigned i = 0; i < numOperands; i++) {
> > + Dest[i] = wrap(N->getOperand(i));
> > + }
> > +}
> >
> > What happens in the case where the LLVMValueRef is not an MDNode?
>
> As Duncan said, if you provide invalid input, it should crash rather
> than fail silently (as my first version did). This way it's easier to
> debug if you give it the wrong arguments.
>
> Thanks,
> Anthony Bryant.
More information about the llvm-commits
mailing list