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


C++ SourceManager::fileinfo_end方法代码示例

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


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

示例1: printIncludedFiles

 void ClangInternalState::printIncludedFiles(llvm::raw_ostream& Out,
                                             SourceManager& SM) {
   Out << "Legend: [p] parsed; [P] parsed and open; [r] from AST file\n\n";
   for (clang::SourceManager::fileinfo_iterator I = SM.fileinfo_begin(),
          E = SM.fileinfo_end(); I != E; ++I) {
     const clang::FileEntry *FE = I->first;
     // Our error recovery purges the cache of the FileEntry, but keeps
     // the FileEntry's pointer so that if it was used by smb (like the
     // SourceManager) it wouldn't be dangling. In that case we shouldn't
     // print the FileName, because semantically it is not there.
     if (!I->second)
       continue;
     std::string fileName(FE->getName());
     if (!(fileName.compare(0, 5, "/usr/") == 0 &&
           fileName.find("/bits/") != std::string::npos) &&
         fileName.compare("-")) {
       if (I->second->getRawBuffer()) {
         // There is content - a memory buffer or a file.
         // We know it's a file because we started off the FileEntry.
         if (FE->isOpen())
           Out << "[P] ";
         else
           Out << "[p] ";
       } else
         Out << "[r] ";
       Out << fileName << '\n';
     }
   }
 }
开发者ID:CristinaCristescu,项目名称:root,代码行数:29,代码来源:ClangInternalState.cpp

示例2: printIncludedFiles

  void ClangInternalState::printIncludedFiles(llvm::raw_ostream& Out,
                                              const SourceManager& SM) {
    // FileInfos are stored as a mapping, and invalidating the cache
    // can change iteration order.
    std::vector<std::string> ParsedOpen, Parsed, AST;
    for (clang::SourceManager::fileinfo_iterator I = SM.fileinfo_begin(),
           E = SM.fileinfo_end(); I != E; ++I) {
      const clang::FileEntry *FE = I->first;
      // Our error recovery purges the cache of the FileEntry, but keeps
      // the FileEntry's pointer so that if it was used by smb (like the
      // SourceManager) it wouldn't be dangling. In that case we shouldn't
      // print the FileName, because semantically it is not there.
      if (!I->second)
        continue;

      std::string fileName(FE->getName());
      // We create a virtual file for each input line in the format input_line_N
      if (fileName.size() > 11 && fileName.find("input_line_") == 0 &&
          std::find_if(fileName.begin() + 11, fileName.end(), [](char c) {
            return !std::isdigit(c);
          }) == fileName.end()) {
        continue;
      }
      if (!(fileName.compare(0, 5, "/usr/") == 0 &&
            fileName.find("/bits/") != std::string::npos) &&
          fileName.compare("-")) {
        if (I->second->getRawBuffer()) {
          // There is content - a memory buffer or a file.
          // We know it's a file because we started off the FileEntry.
          if (FE->isOpen())
            ParsedOpen.emplace_back(std::move(fileName));
          else
            Parsed.emplace_back(std::move(fileName));
        } else
         AST.emplace_back(std::move(fileName));
      }
    }
    auto DumpFiles = [&Out](const char* What, std::vector<std::string>& Files) {
      if (Files.empty())
        return;
      Out << What << ":\n";
      std::sort(Files.begin(), Files.end());
      for (auto&& FileName : Files)
        Out << " " << FileName << '\n';
    };
    DumpFiles("Parsed and open", ParsedOpen);
    DumpFiles("Parsed", Parsed);
    DumpFiles("From AST file", AST);
  }
开发者ID:marsupial,项目名称:cling,代码行数:49,代码来源:ClangInternalState.cpp


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