コード例 #1
0
ファイル: SimpleInliner.cpp プロジェクト: annulen/creduce
void SimpleInliner::doAnalysis(void)
{
  getValidFunctionDecls();

  for (SmallVector<CallExpr *, 10>::iterator CI = AllCallExprs.begin(),
       CE = AllCallExprs.end(); CI != CE; ++CI) {

    FunctionDecl *CalleeDecl = (*CI)->getDirectCallee(); 
    TransAssert(CalleeDecl && "Bad CalleeDecl!");
    FunctionDecl *CanonicalDecl = CalleeDecl->getCanonicalDecl();
    if (!ValidFunctionDecls.count(CanonicalDecl))
      continue;

    if (!hasValidArgExprs(*CI))
      continue;

    ValidInstanceNum++;
    if (TransformationCounter == ValidInstanceNum) {
      // It's possible the direct callee is not a definition
      if (!CalleeDecl->isThisDeclarationADefinition()) {
        CalleeDecl = CalleeDecl->getFirstDeclaration();
        for(FunctionDecl::redecl_iterator RI = CalleeDecl->redecls_begin(),
            RE = CalleeDecl->redecls_end(); RI != RE; ++RI) {
          if ((*RI)->isThisDeclarationADefinition()) {
            CalleeDecl = (*RI);
            break;
          }
        }
      }
      TransAssert(CalleeDecl->isThisDeclarationADefinition() && 
                  "Bad CalleeDecl!");
      CurrentFD = CalleeDecl;
      TheCaller = CalleeToCallerMap[(*CI)];
      TransAssert(TheCaller && "NULL TheCaller!");
      TheCallExpr = (*CI);
    }
  }
}
コード例 #2
0
void SimpleInliner::doAnalysis(void)
{
#ifdef DEBUGCL
  std::cerr << "SimpleInliner::doAnalysis" << std::endl;
  std::cerr << "Size of AllCallExprs = " << AllCallExprs.size() << std::endl;
#endif
  getValidFunctionDecls();

  for (SmallVector<CallExpr *, 10>::iterator CI = AllCallExprs.begin(),
       CE = AllCallExprs.end(); CI != CE; ++CI) {

    FunctionDecl *CalleeDecl = (*CI)->getDirectCallee(); 
    TransAssert(CalleeDecl && "Bad CalleeDecl!");
    FunctionDecl *CanonicalDecl = CalleeDecl->getCanonicalDecl();
#ifdef DEBUGCL
    std::cerr << "CanonicalDecl = " << CanonicalDecl->getName().str()
      << std::endl;
#endif
    if (!ValidFunctionDecls.count(CanonicalDecl)) {
#ifdef DEBUGCL
      std::cerr << "!ValidFunctionDecls.count" << std::endl;
#endif
      continue;
    }

    if (!hasValidArgExprs(*CI)) {
#ifdef DEBUGCL
      std::cerr << "!hasValidArgExprs" << std::endl;
#endif
      continue;
    }

    ValidInstanceNum++;
#ifdef DEBUGCL
    std::cerr << "TransformationCounter = " << TransformationCounter
      << " and ValidInstanceNum = " << ValidInstanceNum << std::endl;
#endif
    if (TransformationCounter == ValidInstanceNum) {
#ifdef DEBUGCL
      std::cerr << "TransformationCounter == ValidInstanceNum" << std::endl;
#endif
      // It's possible the direct callee is not a definition
      if (!CalleeDecl->isThisDeclarationADefinition()) {
        CalleeDecl = CalleeDecl->getFirstDeclaration();
        for(FunctionDecl::redecl_iterator RI = CalleeDecl->redecls_begin(),
            RE = CalleeDecl->redecls_end(); RI != RE; ++RI) {
          if ((*RI)->isThisDeclarationADefinition()) {
            CalleeDecl = (*RI);
            break;
          }
        }
      }
      TransAssert(CalleeDecl->isThisDeclarationADefinition() && 
                  "Bad CalleeDecl!");
      CurrentFD = CalleeDecl;
      TheCaller = CalleeToCallerMap[(*CI)];
      TransAssert(TheCaller && "NULL TheCaller!");
#ifdef DEBUGCL
      std::cerr << "Assigning TheCallExpr" << std::endl;
#endif
      TheCallExpr = (*CI);
    }
  }
}