本文整理汇总了C++中clang::Preprocessor::LookupFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Preprocessor::LookupFile方法的具体用法?C++ Preprocessor::LookupFile怎么用?C++ Preprocessor::LookupFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clang::Preprocessor
的用法示例。
在下文中一共展示了Preprocessor::LookupFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertIntoAutoloadingState
void InsertIntoAutoloadingState (Decl* decl, std::string annotation) {
assert(annotation != "" && "Empty annotation!");
assert(m_PP);
const FileEntry* FE = 0;
SourceLocation fileNameLoc;
bool isAngled = false;
const DirectoryLookup* LookupFrom = 0;
const DirectoryLookup* CurDir = 0;
FE = m_PP->LookupFile(fileNameLoc, annotation, isAngled, LookupFrom,
CurDir, /*SearchPath*/0, /*RelativePath*/ 0,
/*suggestedModule*/0, /*SkipCache*/false,
/*OpenFile*/ false, /*CacheFail*/ false);
assert(FE && "Must have a valid FileEntry");
if (m_Map->find(FE) == m_Map->end())
(*m_Map)[FE] = std::vector<Decl*>();
(*m_Map)[FE].push_back(decl);
}
示例2: InsertIntoAutoloadingState
void InsertIntoAutoloadingState(Decl* decl, Annotations_t FileNames) {
assert(m_PP);
auto addFile = [this,decl](llvm::StringRef FileName, bool warn) {
if (FileName.empty()) return (const FileEntry*)nullptr;
const FileEntry* FE = 0;
SourceLocation fileNameLoc;
// Remember this file wth full path, not "./File.h" (ROOT-8863).
bool isAngled = true;
const DirectoryLookup* FromDir = 0;
const FileEntry* FromFile = 0;
const DirectoryLookup* CurDir = 0;
bool needCacheUpdate = false;
if (FileName.equals(m_PrevFileName.first))
FE = m_PrevFE.first;
else if (FileName.equals(m_PrevFileName.second))
FE = m_PrevFE.second;
else {
FE = m_PP->LookupFile(fileNameLoc, FileName, isAngled,
FromDir, FromFile, CurDir, /*SearchPath*/0,
/*RelativePath*/ 0, /*suggestedModule*/0,
/*IsMapped*/0, /*SkipCache*/ false,
/*OpenFile*/ false, /*CacheFail*/ true);
needCacheUpdate = true;
}
if (FE) {
auto& Vec = (*m_Map)[FE];
Vec.push_back(decl);
if (needCacheUpdate) return FE;
else return (const FileEntry*)nullptr;
} else if (warn) {
// If the top level header is expected to be findable at run-time,
// the direct header might not because the include path might be
// different enough and only the top-header is guaranteed to be seen
// by the user as an interface header to be available on the
// run-time include path.
cling::errs()
<< "Error in cling::AutoloadingVisitor::InsertIntoAutoloadingState:\n"
" Missing FileEntry for " << FileName << "\n";
if (NamedDecl* ND = dyn_cast<NamedDecl>(decl)) {
cling::errs() << " requested to autoload type ";
ND->getNameForDiagnostic(cling::errs(),
ND->getASTContext().getPrintingPolicy(),
true /*qualified*/);
cling::errs() << "\n";
}
return (const FileEntry*)nullptr;
} else {
// Case of the direct header that is not a top level header, no
// warning in this case (to likely to be a false positive).
return (const FileEntry*)nullptr;
}
};
const FileEntry* cacheUpdate;
if ( (cacheUpdate = addFile(FileNames.first,true)) ) {
m_PrevFE.first = cacheUpdate;
m_PrevFileName.first = FileNames.first;
}
if ( (cacheUpdate = addFile(FileNames.second,false)) ) {
m_PrevFE.second = cacheUpdate;
m_PrevFileName.second = FileNames.second;
}
}