Debug build : Check ObjectFile before reading.

Check LLVM ObjectFile state before access to avoid llvm assertion failure.

Expected<T> must be checked before access or destruction.
Expected<T> value was in success state. (Note: Expected<T> values in success mode must still be checked prior to being destroyed).
This commit is contained in:
Marin Baron 2019-10-20 21:42:59 +02:00 committed by Ivan
parent b844cd81e8
commit 90aaaceba0

View File

@ -832,7 +832,16 @@ void jit_compiler::add(std::unique_ptr<llvm::Module> module)
void jit_compiler::add(const std::string& path)
{
m_engine->addObjectFile(std::move(llvm::object::ObjectFile::createObjectFile(*ObjectCache::load(path)).get()));
auto cache = ObjectCache::load(path);
if (auto object_file = llvm::object::ObjectFile::createObjectFile(*cache))
{
m_engine->addObjectFile( std::move(*object_file) );
}
else
{
LOG_ERROR(GENERAL, "ObjectCache: Adding failed: %s", path);
}
}
void jit_compiler::fin()