mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
[llvm] Add assertions for the smart pointers with the possibility to be null in ModuleLazyLoaderCache::operator()
Split from D91844. The return value of function `ModuleLazyLoaderCache::operator()` in file llvm/tools/llvm-link/llvm-link.cpp. According to the bug report of my static analyzer, the std::function variable `ModuleLazyLoaderCache::createLazyModule` points to function `loadFile`, which may return `nullptr` when error. And the pointer is dereferenced without a check. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D97258
This commit is contained in:
parent
20e98ffdeb
commit
2a15d1e5e9
@ -246,8 +246,10 @@ public:
|
||||
Module &ModuleLazyLoaderCache::operator()(const char *argv0,
|
||||
const std::string &Identifier) {
|
||||
auto &Module = ModuleMap[Identifier];
|
||||
if (!Module)
|
||||
if (!Module) {
|
||||
Module = createLazyModule(argv0, Identifier);
|
||||
assert(Module && "Failed to create lazy module!");
|
||||
}
|
||||
return *Module;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
Loading…
Reference in New Issue
Block a user