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


C++ iterator::hasName方法代码示例

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


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

示例1: DisambiguateGlobalSymbols

/// DisambiguateGlobalSymbols - Give anonymous global values names.
///
static void DisambiguateGlobalSymbols(Module *M) {
  for (Module::global_iterator I = M->global_begin(), E = M->global_end();
       I != E; ++I)
    if (!I->hasName())
      I->setName("anon_global");
  for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
    if (!I->hasName())
      I->setName("anon_fn");
}
开发者ID:mfleming,项目名称:llvm-mirror,代码行数:11,代码来源:Miscompilation.cpp

示例2: if

/// GetAllUndefinedSymbols - calculates the set of undefined symbols that still
/// exist in an LLVM module. This is a bit tricky because there may be two
/// symbols with the same name but different LLVM types that will be resolved to
/// each other but aren't currently (thus we need to treat it as resolved).
///
/// Inputs:
///  M - The module in which to find undefined symbols.
///
/// Outputs:
///  UndefinedSymbols - A set of C++ strings containing the name of all
///                     undefined symbols.
///
static void
GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
  std::set<std::string> DefinedSymbols;
  UndefinedSymbols.clear();

  // If the program doesn't define a main, try pulling one in from a .a file.
  // This is needed for programs where the main function is defined in an
  // archive, such f2c'd programs.
  Function *Main = M->getFunction("main");
  if (Main == 0 || Main->isDeclaration())
    UndefinedSymbols.insert("main");

  for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
    if (I->hasName()) {
      if (I->isDeclaration())
        UndefinedSymbols.insert(I->getName());
      else if (!I->hasLocalLinkage()) {
        assert(!I->hasDLLImportLinkage()
               && "Found dllimported non-external symbol!");
        DefinedSymbols.insert(I->getName());
      }      
    }

  for (Module::global_iterator I = M->global_begin(), E = M->global_end();
       I != E; ++I)
    if (I->hasName()) {
      if (I->isDeclaration())
        UndefinedSymbols.insert(I->getName());
      else if (!I->hasLocalLinkage()) {
        assert(!I->hasDLLImportLinkage()
               && "Found dllimported non-external symbol!");
        DefinedSymbols.insert(I->getName());
      }      
    }

  for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end();
       I != E; ++I)
    if (I->hasName())
      DefinedSymbols.insert(I->getName());

  // Prune out any defined symbols from the undefined symbols set...
  for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
       I != UndefinedSymbols.end(); )
    if (DefinedSymbols.count(*I))
      UndefinedSymbols.erase(I++);  // This symbol really is defined!
    else
      ++I; // Keep this symbol in the undefined symbols list
}
开发者ID:Killfrra,项目名称:llvm-kernel,代码行数:60,代码来源:LinkArchives.cpp

示例3: if

void
AndroidBitcodeLinker::GetAllSymbols(Module *M,
  std::set<std::string> &UndefinedSymbols,
  std::set<std::string> &DefinedSymbols) {

  UndefinedSymbols.clear();
  DefinedSymbols.clear();

  Function *Main = M->getFunction("main");
  if (Main == 0 || Main->isDeclaration())
    UndefinedSymbols.insert("main");

  for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
    if (I->hasName()) {
      if (I->isDeclaration())
        UndefinedSymbols.insert(I->getName());
      else if (!I->hasLocalLinkage()) {
        assert(!I->hasDLLImportStorageClass()
               && "Found dllimported non-external symbol!");
        DefinedSymbols.insert(I->getName());
      }
    }

  for (Module::global_iterator I = M->global_begin(), E = M->global_end();
       I != E; ++I)
    if (I->hasName()) {
      if (I->isDeclaration())
        UndefinedSymbols.insert(I->getName());
      else if (!I->hasLocalLinkage()) {
        assert(!I->hasDLLImportStorageClass()
               && "Found dllimported non-external symbol!");
        DefinedSymbols.insert(I->getName());
      }
    }

  for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end();
       I != E; ++I)
    if (I->hasName())
      DefinedSymbols.insert(I->getName());

  for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
       I != UndefinedSymbols.end(); )
    if (DefinedSymbols.count(*I))
      UndefinedSymbols.erase(I++);
    else
      ++I;
}
开发者ID:crystax,项目名称:android-toolchain-llvm-3-7,代码行数:47,代码来源:AndroidBitcodeLinker.cpp

示例4: DisambiguateGlobalSymbols

/// DisambiguateGlobalSymbols - Mangle symbols to guarantee uniqueness by
/// modifying predominantly internal symbols rather than external ones.
///
static void DisambiguateGlobalSymbols(Module *M) {
  // Try not to cause collisions by minimizing chances of renaming an
  // already-external symbol, so take in external globals and functions as-is.
  // The code should work correctly without disambiguation (assuming the same
  // mangler is used by the two code generators), but having symbols with the
  // same name causes warnings to be emitted by the code generator.
  Mangler Mang(*M);
  // Agree with the CBE on symbol naming
  Mang.markCharUnacceptable('.');
  for (Module::global_iterator I = M->global_begin(), E = M->global_end();
       I != E; ++I) {
    // Don't mangle asm names.
    if (!I->hasName() || I->getName()[0] != 1)
      I->setName(Mang.getMangledName(I));
  }
  for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
    // Don't mangle asm names or intrinsics.
    if ((!I->hasName() || I->getName()[0] != 1) &&
        I->getIntrinsicID() == 0)
      I->setName(Mang.getMangledName(I));
  }
}
开发者ID:Killfrra,项目名称:llvm-kernel,代码行数:25,代码来源:Miscompilation.cpp

示例5: if

/// Based on GetAllUndefinedSymbols() from LLVM3.2
///
/// GetAllUndefinedSymbols - calculates the set of undefined symbols that still
/// exist in an LLVM module. This is a bit tricky because there may be two
/// symbols with the same name but different LLVM types that will be resolved to
/// each other but aren't currently (thus we need to treat it as resolved).
///
/// Inputs:
///  M - The module in which to find undefined symbols.
///
/// Outputs:
///  UndefinedSymbols - A set of C++ strings containing the name of all
///                     undefined symbols.
///
static void
GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
    static const std::string llvmIntrinsicPrefix="llvm.";
    std::set<std::string> DefinedSymbols;
    UndefinedSymbols.clear();
    KLEE_DEBUG_WITH_TYPE("klee_linker",
                         dbgs() << "*** Computing undefined symbols ***\n");

    for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
        if (I->hasName()) {
            if (I->isDeclaration())
                UndefinedSymbols.insert(I->getName());
            else if (!I->hasLocalLinkage()) {
#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
                assert(!I->hasDLLImportLinkage() && "Found dllimported non-external symbol!");
#else
                assert(!I->hasDLLImportStorageClass() && "Found dllimported non-external symbol!");
#endif
                DefinedSymbols.insert(I->getName());
            }
        }

    for (Module::global_iterator I = M->global_begin(), E = M->global_end();
            I != E; ++I)
        if (I->hasName()) {
            if (I->isDeclaration())
                UndefinedSymbols.insert(I->getName());
            else if (!I->hasLocalLinkage()) {
#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
                assert(!I->hasDLLImportLinkage() && "Found dllimported non-external symbol!");
#else
                assert(!I->hasDLLImportStorageClass() && "Found dllimported non-external symbol!");
#endif
                DefinedSymbols.insert(I->getName());
            }
        }

    for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end();
            I != E; ++I)
        if (I->hasName())
            DefinedSymbols.insert(I->getName());


    // Prune out any defined symbols from the undefined symbols set
    // and other symbols we don't want to treat as an undefined symbol
    std::vector<std::string> SymbolsToRemove;
    for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
            I != UndefinedSymbols.end(); ++I )
    {
        if (DefinedSymbols.count(*I))
        {
            SymbolsToRemove.push_back(*I);
            continue;
        }

        // Strip out llvm intrinsics
        if ( (I->size() >= llvmIntrinsicPrefix.size() ) &&
                (I->compare(0, llvmIntrinsicPrefix.size(), llvmIntrinsicPrefix) == 0) )
        {
            KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "LLVM intrinsic " << *I <<
                                 " has will be removed from undefined symbols"<< "\n");
            SymbolsToRemove.push_back(*I);
            continue;
        }

        // Symbol really is undefined
        KLEE_DEBUG_WITH_TYPE("klee_linker",
                             dbgs() << "Symbol " << *I << " is undefined.\n");
    }

    // Remove KLEE intrinsics from set of undefined symbols
    for (SpecialFunctionHandler::const_iterator sf = SpecialFunctionHandler::begin(),
            se = SpecialFunctionHandler::end(); sf != se; ++sf)
    {
        if (UndefinedSymbols.find(sf->name) == UndefinedSymbols.end())
            continue;

        SymbolsToRemove.push_back(sf->name);
        KLEE_DEBUG_WITH_TYPE("klee_linker",
                             dbgs() << "KLEE intrinsic " << sf->name <<
                             " has will be removed from undefined symbols"<< "\n");
    }

    // Now remove the symbols from undefined set.
    for (size_t i = 0, j = SymbolsToRemove.size(); i < j; ++i )
        UndefinedSymbols.erase(SymbolsToRemove[i]);
//.........这里部分代码省略.........
开发者ID:tracer-x,项目名称:klee,代码行数:101,代码来源:ModuleUtil.cpp


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