[LLVMdev] use of CallInst()

Ryan M. Lefever lefever at crhc.uiuc.edu
Wed Mar 7 03:18:50 PST 2007


> Args needs to be an array of the arguments and NumArgs needs to be the
> size of the array. If you have a std::vector then you can just:
> 
> new CallInst(F, &ArgVec[0], ArgVec.size(), ...)

Doesn't the code above make an assumption about how std::vector is 
implemented?  If ArgVec is defined as

std::vector<Value*> ArgVec;

then &ArgVec[0] returns a Value**.  Let us define

Value** Params = &ArgVec[0];

The constructor for CallInst accesses Params using the [] operator in a 
for loop.  That should only work if the std::vector<Value*> is 
implemented using an array of Value*s.  I looked at the documentation 
for STL and did not see anything about vector being guaranteed to be 
implemented as an array.

Am I missing something?  If not, why was direct support for a 
std:vector<Value*> removed from the CallInst constructor?

I apologize if I am misinterpreting things.



More information about the llvm-dev mailing list