本文整理汇总了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';
}
}
}
示例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);
}