本文整理汇总了C++中ModuleDecl::arePrivateImportsEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleDecl::arePrivateImportsEnabled方法的具体用法?C++ ModuleDecl::arePrivateImportsEnabled怎么用?C++ ModuleDecl::arePrivateImportsEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleDecl
的用法示例。
在下文中一共展示了ModuleDecl::arePrivateImportsEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addImport
void NameBinder::addImport(
SmallVectorImpl<SourceFile::ImportedModuleDesc> &imports, ImportDecl *ID) {
if (ID->getModulePath().front().first == SF.getParentModule()->getName() &&
ID->getModulePath().size() == 1 && !shouldImportSelfImportClang(ID, SF)) {
// If the imported module name is the same as the current module,
// produce a diagnostic.
StringRef filename = llvm::sys::path::filename(SF.getFilename());
if (filename.empty())
Context.Diags.diagnose(ID, diag::sema_import_current_module,
ID->getModulePath().front().first);
else
Context.Diags.diagnose(ID, diag::sema_import_current_module_with_file,
filename, ID->getModulePath().front().first);
ID->setModule(SF.getParentModule());
return;
}
ModuleDecl *M = getModule(ID->getModulePath());
if (!M) {
SmallString<64> modulePathStr;
interleave(ID->getModulePath(),
[&](ImportDecl::AccessPathElement elem) {
modulePathStr += elem.first.str();
},
[&] { modulePathStr += "."; });
auto diagKind = diag::sema_no_import;
if (SF.Kind == SourceFileKind::REPL || Context.LangOpts.DebuggerSupport)
diagKind = diag::sema_no_import_repl;
diagnose(ID->getLoc(), diagKind, modulePathStr);
if (Context.SearchPathOpts.SDKPath.empty() &&
llvm::Triple(llvm::sys::getProcessTriple()).isMacOSX()) {
diagnose(SourceLoc(), diag::sema_no_import_no_sdk);
diagnose(SourceLoc(), diag::sema_no_import_no_sdk_xcrun);
}
return;
}
ID->setModule(M);
ModuleDecl *topLevelModule;
if (ID->getModulePath().size() == 1) {
topLevelModule = M;
} else {
// If we imported a submodule, import the top-level module as well.
Identifier topLevelName = ID->getModulePath().front().first;
topLevelModule = Context.getLoadedModule(topLevelName);
if (!topLevelModule) {
// Clang can sometimes import top-level modules as if they were
// submodules.
assert(!M->getFiles().empty() &&
isa<ClangModuleUnit>(M->getFiles().front()));
topLevelModule = M;
}
}
auto *testableAttr = ID->getAttrs().getAttribute<TestableAttr>();
if (testableAttr && !topLevelModule->isTestingEnabled() &&
Context.LangOpts.EnableTestableAttrRequiresTestableModule) {
diagnose(ID->getModulePath().front().second, diag::module_not_testable,
topLevelModule->getName());
testableAttr->setInvalid();
}
auto *privateImportAttr = ID->getAttrs().getAttribute<PrivateImportAttr>();
StringRef privateImportFileName;
if (privateImportAttr) {
if (!topLevelModule->arePrivateImportsEnabled()) {
diagnose(ID->getModulePath().front().second,
diag::module_not_compiled_for_private_import,
topLevelModule->getName());
privateImportAttr->setInvalid();
} else {
privateImportFileName = privateImportAttr->getSourceFile();
}
}
ImportOptions options;
if (ID->isExported())
options |= SourceFile::ImportFlags::Exported;
if (testableAttr)
options |= SourceFile::ImportFlags::Testable;
if (privateImportAttr)
options |= SourceFile::ImportFlags::PrivateImport;
auto *implementationOnlyAttr =
ID->getAttrs().getAttribute<ImplementationOnlyAttr>();
if (implementationOnlyAttr) {
if (options.contains(SourceFile::ImportFlags::Exported)) {
diagnose(ID, diag::import_implementation_cannot_be_exported,
topLevelModule->getName())
.fixItRemove(implementationOnlyAttr->getRangeWithAt());
} else {
options |= SourceFile::ImportFlags::ImplementationOnly;
}
}
imports.push_back(SourceFile::ImportedModuleDesc(
{ID->getDeclPath(), M}, options, privateImportFileName));
//.........这里部分代码省略.........