本文整理汇总了C++中IntrusiveRefCntPtr::getModuleHash方法的典型用法代码示例。如果您正苦于以下问题:C++ IntrusiveRefCntPtr::getModuleHash方法的具体用法?C++ IntrusiveRefCntPtr::getModuleHash怎么用?C++ IntrusiveRefCntPtr::getModuleHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IntrusiveRefCntPtr
的用法示例。
在下文中一共展示了IntrusiveRefCntPtr::getModuleHash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compileModule
/// \brief Compile a module file for the given module, using the options
/// provided by the importing compiler instance.
static void compileModule(CompilerInstance &ImportingInstance,
SourceLocation ImportLoc,
Module *Module,
StringRef ModuleFileName) {
llvm::LockFileManager Locked(ModuleFileName);
switch (Locked) {
case llvm::LockFileManager::LFS_Error:
return;
case llvm::LockFileManager::LFS_Owned:
// We're responsible for building the module ourselves. Do so below.
break;
case llvm::LockFileManager::LFS_Shared:
// Someone else is responsible for building the module. Wait for them to
// finish.
Locked.waitForUnlock();
return;
}
ModuleMap &ModMap
= ImportingInstance.getPreprocessor().getHeaderSearchInfo().getModuleMap();
// Construct a compiler invocation for creating this module.
IntrusiveRefCntPtr<CompilerInvocation> Invocation
(new CompilerInvocation(ImportingInstance.getInvocation()));
PreprocessorOptions &PPOpts = Invocation->getPreprocessorOpts();
// For any options that aren't intended to affect how a module is built,
// reset them to their default values.
Invocation->getLangOpts()->resetNonModularOptions();
PPOpts.resetNonModularOptions();
// Note the name of the module we're building.
Invocation->getLangOpts()->CurrentModule = Module->getTopLevelModuleName();
// Make sure that the failed-module structure has been allocated in
// the importing instance, and propagate the pointer to the newly-created
// instance.
PreprocessorOptions &ImportingPPOpts
= ImportingInstance.getInvocation().getPreprocessorOpts();
if (!ImportingPPOpts.FailedModules)
ImportingPPOpts.FailedModules = new PreprocessorOptions::FailedModulesSet;
PPOpts.FailedModules = ImportingPPOpts.FailedModules;
// If there is a module map file, build the module using the module map.
// Set up the inputs/outputs so that we build the module from its umbrella
// header.
FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
FrontendOpts.OutputFile = ModuleFileName.str();
FrontendOpts.DisableFree = false;
FrontendOpts.Inputs.clear();
InputKind IK = getSourceInputKindFromOptions(*Invocation->getLangOpts());
// Get or create the module map that we'll use to build this module.
SmallString<128> TempModuleMapFileName;
if (const FileEntry *ModuleMapFile
= ModMap.getContainingModuleMapFile(Module)) {
// Use the module map where this module resides.
FrontendOpts.Inputs.push_back(FrontendInputFile(ModuleMapFile->getName(),
IK));
} else {
// Create a temporary module map file.
TempModuleMapFileName = Module->Name;
TempModuleMapFileName += "-%%%%%%%%.map";
int FD;
if (llvm::sys::fs::unique_file(TempModuleMapFileName.str(), FD,
TempModuleMapFileName,
/*makeAbsolute=*/true)
!= llvm::errc::success) {
ImportingInstance.getDiagnostics().Report(diag::err_module_map_temp_file)
<< TempModuleMapFileName;
return;
}
// Print the module map to this file.
llvm::raw_fd_ostream OS(FD, /*shouldClose=*/true);
Module->print(OS);
FrontendOpts.Inputs.push_back(
FrontendInputFile(TempModuleMapFileName.str().str(), IK));
}
// Don't free the remapped file buffers; they are owned by our caller.
PPOpts.RetainRemappedFileBuffers = true;
Invocation->getDiagnosticOpts().VerifyDiagnostics = 0;
assert(ImportingInstance.getInvocation().getModuleHash() ==
Invocation->getModuleHash() && "Module hash mismatch!");
// Construct a compiler instance that will be used to actually create the
// module.
CompilerInstance Instance;
Instance.setInvocation(&*Invocation);
Instance.createDiagnostics(/*argc=*/0, /*argv=*/0,
&ImportingInstance.getDiagnosticClient(),
/*ShouldOwnClient=*/true,
/*ShouldCloneClient=*/true);
//.........这里部分代码省略.........