[llvm-commits] [PATCH] ExtractValueInst < UnaryInstruction
Dan Gohman
gohman at apple.com
Fri Jun 6 13:16:07 PDT 2008
On Fri, 2008-06-06 at 22:02 +0200, Gabor Greif wrote:
> > > Index: include/llvm/Instructions.h
> > > ===================================================================
> > > --- include/llvm/Instructions.h (Revision 52051)
> > > +++ include/llvm/Instructions.h (Arbeitskopie)
> > > @@ -1453,7 +1453,7 @@
> > > /// ExtractValueInst - This instruction extracts a struct
> > member or
> > > array
> > > /// element value from an aggregate value.
> > > ///
> > > -class ExtractValueInst : public Instruction {
> > > +class ExtractValueInst : public UnaryInstruction {
> > > SmallVector<unsigned, 4> Indices;
> > >
> > > ExtractValueInst(const ExtractValueInst &EVI);
> > > @@ -1526,12 +1526,13 @@
> > > Instruction *InsertBefore = 0);
> > > ExtractValueInst(Value *Agg, unsigned Idx,
> > > const std::string &Name, BasicBlock
> > *InsertAtEnd);
> > > -public:
> > > +
> > > // allocate space for exactly one operand
> > > void *operator new(size_t s) {
> > > return User::operator new(s, 1);
> > > }
> > >
> > > +public:
> >
> > With ExtractValueInst being a UnaryInstruction, can we just get rid
> > of this operator new, and just use the one inherited from
> > UnaryInstruction?
>
> Unfortunately, no. The reason is that UnaryInstruction::new is public,
> while we do not want ExtractValueInst::new to be invoked
> by clients. ExtractValueInst::Create is the way to go. This is
> the reason for making ExtractValueInst::new private.
> Maybe we can use "private: using UnaryInstruction::new;", though :-)
Why is UnaryInstruction's operator new public? If it were
protected, it seems like we wouldn't have to require all the
child classes to have their own operator new just to make it
non-public.
Thanks,
Dan
More information about the llvm-commits
mailing list