当前位置: 首页>>代码示例>>C++>>正文


C++ arg_iterator::getType方法代码示例

本文整理汇总了C++中function::arg_iterator::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ arg_iterator::getType方法的具体用法?C++ arg_iterator::getType怎么用?C++ arg_iterator::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在function::arg_iterator的用法示例。


在下文中一共展示了arg_iterator::getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkFeatures

void MemoryInstrumenter::checkFeatures(Module &M) {
  // Check whether any memory allocation function can
  // potentially be pointed by function pointers.
  // Also, all intrinsic functions will be called directly,
  // i.e. not via function pointers.
  for (Module::iterator F = M.begin(); F != M.end(); ++F) {
    if (DynAAUtils::IsMalloc(F) || F->isIntrinsic()) {
      for (Value::use_iterator UI = F->use_begin(); UI != F->use_end(); ++UI) {
        User *Usr = *UI;
        assert(isa<CallInst>(Usr) || isa<InvokeInst>(Usr));
        CallSite CS(cast<Instruction>(Usr));
        for (unsigned i = 0; i < CS.arg_size(); ++i)
          assert(CS.getArgument(i) != F);
      }
    }
  }

  // Check whether memory allocation functions are captured.
  for (Module::iterator F = M.begin(); F != M.end(); ++F) {
    // 0 is the return, 1 is the first parameter.
    if (F->isDeclaration() && F->doesNotAlias(0) && !DynAAUtils::IsMalloc(F)) {
      errs().changeColor(raw_ostream::RED);
      errs() << F->getName() << "'s return value is marked noalias, ";
      errs() << "but the function is not treated as malloc.\n";
      errs().resetColor();
    }
  }

  // Sequential types except pointer types shouldn't be used as the type of
  // an instruction, a function parameter, or a global variable.
  for (Module::global_iterator GI = M.global_begin(), E = M.global_end();
       GI != E; ++GI) {
    if (isa<SequentialType>(GI->getType()))
      assert(GI->getType()->isPointerTy());
  }
  for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
    for (Function::arg_iterator AI = F->arg_begin(); AI != F->arg_end(); ++AI) {
      if (isa<SequentialType>(AI->getType()))
        assert(AI->getType()->isPointerTy());
    }
  }
  for (Module::iterator F = M.begin(); F != M.end(); ++F) {
    for (Function::iterator BB = F->begin(); BB != F->end(); ++BB) {
      for (BasicBlock::iterator Ins = BB->begin(); Ins != BB->end(); ++Ins) {
        if (isa<SequentialType>(Ins->getType()))
          assert(Ins->getType()->isPointerTy());
      }
    }
  }

  // We don't support multi-process programs for now.
  if (!HookFork)
    assert(M.getFunction("fork") == NULL);
}
开发者ID:alias-checker,项目名称:dyn-aa,代码行数:54,代码来源:MemoryInstrumenter.cpp

示例2: ConvertFunction

// Convert the given function to use normalized argument/return types.
static bool ConvertFunction(Function *Func) {
  FunctionType *FTy = Func->getFunctionType();
  FunctionType *NFTy = NormalizeFunctionType(FTy);
  if (NFTy == FTy)
    return false; // No change needed.
  Function *NewFunc = RecreateFunction(Func, NFTy);

  // Move the arguments across to the new function.
  for (Function::arg_iterator Arg = Func->arg_begin(), E = Func->arg_end(),
         NewArg = NewFunc->arg_begin();
       Arg != E; ++Arg, ++NewArg) {
    NewArg->takeName(Arg);
    if (Arg->getType() == NewArg->getType()) {
      Arg->replaceAllUsesWith(NewArg);
    } else {
      Instruction *Trunc = new TruncInst(
          NewArg, Arg->getType(), NewArg->getName() + ".arg_trunc",
          NewFunc->getEntryBlock().getFirstInsertionPt());
      Arg->replaceAllUsesWith(Trunc);
    }
  }

  if (FTy->getReturnType() != NFTy->getReturnType()) {
    // Fix up return instructions.
    Instruction::CastOps CastType =
        Func->getAttributes().hasAttribute(0, Attribute::SExt) ?
        Instruction::SExt : Instruction::ZExt;
    for (Function::iterator BB = NewFunc->begin(), E = NewFunc->end();
         BB != E;
         ++BB) {
      for (BasicBlock::iterator Iter = BB->begin(), E = BB->end();
           Iter != E; ) {
        Instruction *Inst = Iter++;
        if (ReturnInst *Ret = dyn_cast<ReturnInst>(Inst)) {
          Value *Ext = CopyDebug(
              CastInst::Create(CastType, Ret->getReturnValue(),
                               NFTy->getReturnType(),
                               Ret->getReturnValue()->getName() + ".ret_ext",
                               Ret),
              Ret);
          CopyDebug(ReturnInst::Create(Ret->getContext(), Ext, Ret), Ret);
          Ret->eraseFromParent();
        }
      }
    }
  }

  Func->eraseFromParent();
  return true;
}
开发者ID:Maher4Ever,项目名称:emscripten-fastcomp,代码行数:51,代码来源:ExpandSmallArguments.cpp

示例3: countCodeReductionForAlloca

/// analyzeFunction - Fill in the current structure with information gleaned
/// from the specified function.
void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F,
                                                       const TargetData *TD) {
  Metrics.analyzeFunction(F, TD);

  // A function with exactly one return has it removed during the inlining
  // process (see InlineFunction), so don't count it.
  // FIXME: This knowledge should really be encoded outside of FunctionInfo.
  if (Metrics.NumRets==1)
    --Metrics.NumInsts;

  ArgumentWeights.reserve(F->arg_size());
  DenseMap<Value *, unsigned> PointerArgs;
  unsigned ArgIdx = 0;
  for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
       ++I, ++ArgIdx) {
    // Count how much code can be eliminated if one of the arguments is
    // a constant or an alloca.
    ArgumentWeights.push_back(ArgInfo(countCodeReductionForConstant(Metrics, I),
                                      countCodeReductionForAlloca(Metrics, I)));

    // If the argument is a pointer, also check for pairs of pointers where
    // knowing a fixed offset between them allows simplification. This pattern
    // arises mostly due to STL algorithm patterns where pointers are used as
    // random access iterators.
    if (!I->getType()->isPointerTy())
      continue;
    PointerArgs[I] = ArgIdx;
    countCodeReductionForPointerPair(Metrics, PointerArgs, I, ArgIdx);
  }
}
开发者ID:meteogrid,项目名称:llvm,代码行数:32,代码来源:InlineCost.cpp

示例4: signaturesMatch

bool StructuredModuleEditor::signaturesMatch(Function *First,
		Function *Second) {
	if (First == NULL || Second == NULL)
		return false;

	unsigned FirstNumArgs = First->arg_size();
	unsigned SecondNumArgs = Second->arg_size();

// The number of arguments passed to the old function must match the number of
// arguments passed to the new function
	if (FirstNumArgs != SecondNumArgs)
		return false;

// Both functions must abide by the same calling convention
	if (First->getCallingConv() != Second->getCallingConv())
		return false;

// Both functions must have the same return type
	if (First->getReturnType() != Second->getReturnType())
		return false;

// Checks that the arguments to the old function are of the same type as those of
// the new function, and also that they are in the same order
	for (Function::arg_iterator I = Second->arg_begin(), J = First->arg_begin(),
			IE = Second->arg_end(); I != IE; ++I, ++J) {
		if (I->getType() != J->getType())
			return false;
	}

	return true;
}
开发者ID:32bitmicro,项目名称:fracture,代码行数:31,代码来源:StructuredModuleEditor.cpp

示例5: AddNoCaptureAttrs

/// AddNoCaptureAttrs - Deduce nocapture attributes for the SCC.
bool FunctionAttrs::AddNoCaptureAttrs(const CallGraphSCC &SCC) {
  bool Changed = false;

  // Check each function in turn, determining which pointer arguments are not
  // captured.
  for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) {
    Function *F = (*I)->getFunction();

    if (F == 0)
      // External node - skip it;
      continue;

    // Definitions with weak linkage may be overridden at linktime with
    // something that writes memory, so treat them like declarations.
    if (F->isDeclaration() || F->mayBeOverridden())
      continue;

    for (Function::arg_iterator A = F->arg_begin(), E = F->arg_end(); A!=E; ++A)
      if (A->getType()->isPointerTy() && !A->hasNoCaptureAttr() &&
          !PointerMayBeCaptured(A, true, /*StoreCaptures=*/false)) {
        A->addAttr(Attribute::NoCapture);
        ++NumNoCapture;
        Changed = true;
      }
  }

  return Changed;
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例6: instrumentPointerParameters

void MemoryInstrumenter::instrumentPointerParameters(Function *F) {
  assert(F && !F->isDeclaration());
  Instruction *Entry = F->begin()->getFirstNonPHI();
  for (Function::arg_iterator AI = F->arg_begin(); AI != F->arg_end(); ++AI) {
    if (AI->getType()->isPointerTy())
      instrumentPointer(AI, NULL, Entry);
  }
}
开发者ID:alias-checker,项目名称:dyn-aa,代码行数:8,代码来源:MemoryInstrumenter.cpp

示例7: lowerJuliaArrayArgumentsDecl

  std::vector<Type*> lowerJuliaArrayArgumentsDecl(Function* F) {
    std::vector<Type*> ArgTypes;
    Type* ReturnType = F->getReturnType();
    
    for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) {

      Type* argType = I->getType();
      if (is_jl_array_type(argType)) {
        ArgTypes.push_back(PointerType::get(ReturnType, 1));
      } else {
        ArgTypes.push_back(I->getType());
      }
      
    }

    return ArgTypes;
  }
开发者ID:havardh,项目名称:PTX.jl,代码行数:17,代码来源:lower-array-pass.cpp

示例8: checkFeatures

void MemoryInstrumenter::checkFeatures(Module &M) {
    // Check whether any memory allocation function can
    // potentially be pointed by function pointers.
    // Also, all intrinsic functions will be called directly,
    // i.e. not via function pointers.
    for (Module::iterator F = M.begin(); F != M.end(); ++F) {
        if (DynAAUtils::IsMalloc(F) || F->isIntrinsic()) {
            for (Value::use_iterator UI = F->use_begin(); UI != F->use_end(); ++UI) {
                User *Usr = *UI;
                assert(isa<CallInst>(Usr) || isa<InvokeInst>(Usr));
                CallSite CS(cast<Instruction>(Usr));
                for (unsigned i = 0; i < CS.arg_size(); ++i)
                    assert(CS.getArgument(i) != F);
            }
        }
    }

    // Check whether memory allocation functions are captured.
    for (Module::iterator F = M.begin(); F != M.end(); ++F) {
        // 0 is the return, 1 is the first parameter.
        if (F->isDeclaration() && F->doesNotAlias(0) && !DynAAUtils::IsMalloc(F)) {
            errs().changeColor(raw_ostream::RED);
            errs() << F->getName() << "'s return value is marked noalias, ";
            errs() << "but the function is not treated as malloc.\n";
            errs().resetColor();
        }
    }

    // Global variables shouldn't be of the array type.
    for (Module::global_iterator GI = M.global_begin(), E = M.global_end();
            GI != E; ++GI) {
        assert(!GI->getType()->isArrayTy());
    }
    // A function parameter or an instruction can be an array, but we don't
    // instrument such constructs for now. Issue a warning on such cases.
    for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
        for (Function::arg_iterator AI = F->arg_begin(); AI != F->arg_end(); ++AI) {
            if (AI->getType()->isArrayTy()) {
                errs().changeColor(raw_ostream::RED);
                errs() << F->getName() << ":" << *AI << " is an array\n";
                errs().resetColor();
            }
        }
    }
    for (Module::iterator F = M.begin(); F != M.end(); ++F) {
        for (Function::iterator BB = F->begin(); BB != F->end(); ++BB) {
            for (BasicBlock::iterator Ins = BB->begin(); Ins != BB->end(); ++Ins) {
                if (Ins->getType()->isArrayTy()) {
                    errs().changeColor(raw_ostream::RED);
                    errs() << F->getName() << ":" << *Ins << " is an array\n";
                    errs().resetColor();
                }
            }
        }
    }
}
开发者ID:lzto,项目名称:TxRace,代码行数:56,代码来源:MemoryInstrumenter.cpp

示例9: identify_fixed_integers

void CaptureConstraints::identify_fixed_integers(Module &M) {
	ExecOnce &EO = getAnalysis<ExecOnce>();
	
	fixed_integers.clear();
	// Global variables. 
	for (Module::global_iterator gi = M.global_begin();
			gi != M.global_end(); ++gi) {
		if (isa<IntegerType>(gi->getType()) || isa<PointerType>(gi->getType())) {
			fixed_integers.insert(gi);
			if (gi->hasInitializer())
				extract_from_consts(gi->getInitializer());
		}
	}
	
	// Instructions and their constant operands. 
	forallinst(M, ii) {
		if (EO.not_executed(ii))
			continue;
		if (!EO.executed_once(ii))
			continue;
		if (isa<IntegerType>(ii->getType()) || isa<PointerType>(ii->getType())) {
			fixed_integers.insert(ii);
		}
		// No matter reachable or not, capture its constant operands. 
		for (unsigned i = 0; i < ii->getNumOperands(); ++i) {
			if (Constant *c = dyn_cast<Constant>(ii->getOperand(i)))
				extract_from_consts(c);
		}
	}
	
	// Function parameters. 
	forallfunc(M, f) {
		if (EO.not_executed(f))
			continue;
		if (!EO.executed_once(f))
			continue;
		for (Function::arg_iterator ai = f->arg_begin();
				ai != f->arg_end(); ++ai) {
			if (isa<IntegerType>(ai->getType()) || isa<PointerType>(ai->getType()))
				fixed_integers.insert(ai);
		}
	}
}
开发者ID:wujingyue,项目名称:slicer,代码行数:43,代码来源:top-level.cpp

示例10: while

/// cloneFunctionBody - Create a new function based on F and
/// insert it into module. Remove first argument. Use STy as
/// the return type for new function.
Function *SRETPromotion::cloneFunctionBody(Function *F, 
                                           const StructType *STy) {

  const FunctionType *FTy = F->getFunctionType();
  std::vector<const Type*> Params;

  // Attributes - Keep track of the parameter attributes for the arguments.
  SmallVector<AttributeWithIndex, 8> AttributesVec;
  const AttrListPtr &PAL = F->getAttributes();

  // Add any return attributes.
  if (Attributes attrs = PAL.getRetAttributes())
    AttributesVec.push_back(AttributeWithIndex::get(0, attrs));

  // Skip first argument.
  Function::arg_iterator I = F->arg_begin(), E = F->arg_end();
  ++I;
  // 0th parameter attribute is reserved for return type.
  // 1th parameter attribute is for first 1st sret argument.
  unsigned ParamIndex = 2; 
  while (I != E) {
    Params.push_back(I->getType());
    if (Attributes Attrs = PAL.getParamAttributes(ParamIndex))
      AttributesVec.push_back(AttributeWithIndex::get(ParamIndex - 1, Attrs));
    ++I;
    ++ParamIndex;
  }

  // Add any fn attributes.
  if (Attributes attrs = PAL.getFnAttributes())
    AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));


  FunctionType *NFTy = FunctionType::get(STy, Params, FTy->isVarArg());
  Function *NF = Function::Create(NFTy, F->getLinkage());
  NF->takeName(F);
  NF->copyAttributesFrom(F);
  NF->setAttributes(AttrListPtr::get(AttributesVec.begin(), AttributesVec.end()));
  F->getParent()->getFunctionList().insert(F, NF);
  NF->getBasicBlockList().splice(NF->begin(), F->getBasicBlockList());

  // Replace arguments
  I = F->arg_begin();
  E = F->arg_end();
  Function::arg_iterator NI = NF->arg_begin();
  ++I;
  while (I != E) {
    I->replaceAllUsesWith(NI);
    NI->takeName(I);
    ++I;
    ++NI;
  }

  return NF;
}
开发者ID:dgohman,项目名称:llvm-mirror,代码行数:58,代码来源:StructRetPromotion.cpp

示例11: lowerIncomingArguments

/// lowerIncomingArguments - To avoid having to handle incoming arguments
/// specially, we lower each arg to a copy instruction in the entry block. This
/// ensures that the argument value itself cannot be live out of the entry
/// block.
void SjLjEHPass::lowerIncomingArguments(Function &F) {
  BasicBlock::iterator AfterAllocaInsPt = F.begin()->begin();
  while (isa<AllocaInst>(AfterAllocaInsPt) &&
         isa<ConstantInt>(cast<AllocaInst>(AfterAllocaInsPt)->getArraySize()))
    ++AfterAllocaInsPt;

  for (Function::arg_iterator
         AI = F.arg_begin(), AE = F.arg_end(); AI != AE; ++AI) {
    Type *Ty = AI->getType();

    // Aggregate types can't be cast, but are legal argument types, so we have
    // to handle them differently. We use an extract/insert pair as a
    // lightweight method to achieve the same goal.
    if (isa<StructType>(Ty) || isa<ArrayType>(Ty) || isa<VectorType>(Ty)) {
      Instruction *EI = ExtractValueInst::Create(AI, 0, "", AfterAllocaInsPt);
      Instruction *NI = InsertValueInst::Create(AI, EI, 0);
      NI->insertAfter(EI);
      AI->replaceAllUsesWith(NI);

      // Set the operand of the instructions back to the AllocaInst.
      EI->setOperand(0, AI);
      NI->setOperand(0, AI);
    } else {
      // This is always a no-op cast because we're casting AI to AI->getType()
      // so src and destination types are identical. BitCast is the only
      // possibility.
      CastInst *NC =
        new BitCastInst(AI, AI->getType(), AI->getName() + ".tmp",
                        AfterAllocaInsPt);
      AI->replaceAllUsesWith(NC);

      // Set the operand of the cast instruction back to the AllocaInst.
      // Normally it's forbidden to replace a CastInst's operand because it
      // could cause the opcode to reflect an illegal conversion. However, we're
      // replacing it here with the same value it was constructed with.  We do
      // this because the above replaceAllUsesWith() clobbered the operand, but
      // we want this one to remain.
      NC->setOperand(0, AI);
    }
  }
}
开发者ID:PhongNgo,项目名称:llvm,代码行数:45,代码来源:SjLjEHPrepare.cpp

示例12: lowerIncomingArguments

/// lowerIncomingArguments - To avoid having to handle incoming arguments
/// specially, we lower each arg to a copy instruction in the entry block. This
/// ensures that the argument value itself cannot be live out of the entry
/// block.
void SjLjEHPrepare::lowerIncomingArguments(Function &F) {
  BasicBlock::iterator AfterAllocaInsPt = F.begin()->begin();
  while (isa<AllocaInst>(AfterAllocaInsPt) &&
         isa<ConstantInt>(cast<AllocaInst>(AfterAllocaInsPt)->getArraySize()))
    ++AfterAllocaInsPt;

  for (Function::arg_iterator AI = F.arg_begin(), AE = F.arg_end(); AI != AE;
       ++AI) {
    Type *Ty = AI->getType();

    if (isa<StructType>(Ty) || isa<ArrayType>(Ty)) {
      // Aggregate types can't be cast, but are legal argument types,
      // so we have to handle them differently.  We use
      // select i8 true, %arg, undef to achieve the same goal
      Value *TrueValue = ConstantInt::getTrue(F.getContext());
      Value *UndefValue = UndefValue::get(Ty);
      Instruction *SI = SelectInst::Create(TrueValue, AI, UndefValue,
                                           AI->getName() + ".tmp",
                                           AfterAllocaInsPt);
      AI->replaceAllUsesWith(SI);

      SI->setOperand(1, AI);
    } else {
      // This is always a no-op cast because we're casting AI to AI->getType()
      // so src and destination types are identical. BitCast is the only
      // possibility.
      CastInst *NC = new BitCastInst(AI, AI->getType(), AI->getName() + ".tmp",
                                     AfterAllocaInsPt);
      AI->replaceAllUsesWith(NC);

      // Set the operand of the cast instruction back to the AllocaInst.
      // Normally it's forbidden to replace a CastInst's operand because it
      // could cause the opcode to reflect an illegal conversion. However, we're
      // replacing it here with the same value it was constructed with.  We do
      // this because the above replaceAllUsesWith() clobbered the operand, but
      // we want this one to remain.
      NC->setOperand(0, AI);
    }
  }
}
开发者ID:edward-jones,项目名称:llvm-or1k,代码行数:44,代码来源:SjLjEHPrepare.cpp

示例13: dupFuncArgu

/////////////////////////
//dupFuncArgu()        //
/////////////////////////
void InsDuplica::dupFuncArgu(Function &F) {
   BasicBlock *firstBB = F.begin();
   Instruction *firstI = firstBB->begin();
   for (Function::arg_iterator AI = F.arg_begin(), E = F.arg_end();
         AI != E; ++AI) {
      arguSet.insert(AI);

      //if argument is used only once or all on the same block,
      //do not dup it.
      if (AI->hasOneUse()) {
         valueMap[AI] = AI;
      } else {
         //make copy of cast
         Type *arguType = AI->getType();
         //FIXME unknow signed or not
         CastInst* newCast = CastInst::CreateIntegerCast(AI, arguType, 1, AI->getName()+"_dup", firstI);
         //CastInst *newCast = new CastInst(AI, arguType, AI->getName()+"_dup", firstI);
         valueMap[AI] = newCast;
      }
   }
}
开发者ID:wzzhang-HIT,项目名称:IFDup,代码行数:24,代码来源:InsDuplica.cpp

示例14: instrumentPointerParameters

void MemoryInstrumenter::instrumentPointerParameters(Function *F) {
    assert(F && !F->isDeclaration());

    DataLayout &TD = getAnalysis<DataLayout>();

    Instruction *Entry = F->begin()->getFirstInsertionPt();
    for (Function::arg_iterator AI = F->arg_begin(); AI != F->arg_end(); ++AI) {
        if (PointerType *ArgType = dyn_cast<PointerType>(AI->getType())) {
            // If an argument is marked as byval, add an implicit allocation.
            // FIXME: still broken. We need allocate one extra byte for it. We'd
            // better do it in the backend.
            if (AI->hasByValAttr()) {
                uint64_t TypeSize = TD.getTypeStoreSize(ArgType->getElementType());
                instrumentMemoryAllocation(AI,
                                           ConstantInt::get(LongType, TypeSize),
                                           NULL,
                                           Entry);
            }
            instrumentPointer(AI, NULL, Entry);
        }
    }
}
开发者ID:lzto,项目名称:TxRace,代码行数:22,代码来源:MemoryInstrumenter.cpp

示例15: if

// Create a wrapper function with type Ty that calls F (which may have a
// different type). Attempt to support common bitcasted function idioms:
//  - Call with more arguments than needed: arguments are dropped
//  - Call with fewer arguments than needed: arguments are filled in with undef
//  - Return value is not needed: drop it
//  - Return value needed but not present: supply an undef
//  
// For now, return nullptr without creating a wrapper if the wrapper cannot
// be generated due to incompatible types.
static Function *CreateWrapper(Function *F, FunctionType *Ty) {
  Module *M = F->getParent();

  Function *Wrapper =
      Function::Create(Ty, Function::PrivateLinkage, "bitcast", M);
  BasicBlock *BB = BasicBlock::Create(M->getContext(), "body", Wrapper);

  // Determine what arguments to pass.
  SmallVector<Value *, 4> Args;
  Function::arg_iterator AI = Wrapper->arg_begin();
  FunctionType::param_iterator PI = F->getFunctionType()->param_begin();
  FunctionType::param_iterator PE = F->getFunctionType()->param_end();
  for (; AI != Wrapper->arg_end() && PI != PE; ++AI, ++PI) {
    if (AI->getType() != *PI) {
      Wrapper->eraseFromParent();
      return nullptr;
    }
    Args.push_back(&*AI);
  }
  for (; PI != PE; ++PI)
    Args.push_back(UndefValue::get(*PI));

  CallInst *Call = CallInst::Create(F, Args, "", BB);

  // Determine what value to return.
  if (Ty->getReturnType()->isVoidTy())
    ReturnInst::Create(M->getContext(), BB);
  else if (F->getFunctionType()->getReturnType()->isVoidTy())
    ReturnInst::Create(M->getContext(), UndefValue::get(Ty->getReturnType()),
                       BB);
  else if (F->getFunctionType()->getReturnType() == Ty->getReturnType())
    ReturnInst::Create(M->getContext(), Call, BB);
  else {
    Wrapper->eraseFromParent();
    return nullptr;
  }

  return Wrapper;
}
开发者ID:,项目名称:,代码行数:48,代码来源:


注:本文中的function::arg_iterator::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。