Advertisement
JetForMe

Untitled

Jan 27th, 2013
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1.  
  2. void CallInst::init(Value *Func, ArrayRef<Value *> Args, const Twine &NameStr) {
  3.   assert(NumOperands == Args.size() + 1 && "NumOperands not set up?");
  4.   Op<-1>() = Func;
  5.  
  6. #ifndef NDEBUG
  7.   FunctionType *FTy =
  8.     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
  9.  
  10.   assert((Args.size() == FTy->getNumParams() ||
  11.           (FTy->isVarArg() && Args.size() > FTy->getNumParams())) &&
  12.          "Calling a function with bad signature (wrong number of arguments)!");
  13.  
  14.   for (unsigned i = 0; i != Args.size(); ++i)
  15.   {
  16.     if (i < FTy->getNumParams() && FTy->getParamType(i) != Args[i]->getType())
  17.     {
  18.         std::string s1;
  19.         raw_string_ostream argType(s1);
  20.         Args[i]->print(argType);
  21.        
  22.         std::string s2;
  23.         raw_string_ostream paramType(s2);
  24.         FTy->getParamType(i)->print(paramType);
  25.        
  26.        
  27.         std::string msg = "Attempt to pass '";
  28.         raw_string_ostream msgs(msg);
  29.         msgs << argType.str() << "' to '" << paramType.str() << "' for parameter " << i;
  30.        
  31.         dbgs() << msgs.str() << '\n';
  32.     }
  33.     assert((i >= FTy->getNumParams() ||
  34.             FTy->getParamType(i) == Args[i]->getType()) &&
  35.            "Calling a function with a bad signature (mismatched argument type)!");
  36.   }
  37. #endif
  38.  
  39.   std::copy(Args.begin(), Args.end(), op_begin());
  40.   setName(NameStr);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement