[clang-fuzzer] CreateAndRunJITFunc - fix use after move static analyzer warning.

We were using the unique_ptr M to determine the triple after it had been moved in the EngineBuilder constructor.
This commit is contained in:
Simon Pilgrim 2020-10-26 11:51:36 +00:00
parent cae4067ec1
commit e4991867fb
1 changed files with 2 additions and 2 deletions

View File

@ -158,6 +158,8 @@ static void CreateAndRunJITFunc(const std::string &IR, CodeGenOpt::Level OLvl) {
ErrorAndExit("Function not found in module");
std::string ErrorMsg;
Triple ModuleTriple(M->getTargetTriple());
EngineBuilder builder(std::move(M));
builder.setMArch(codegen::getMArch());
builder.setMCPU(codegen::getCPUStr());
@ -166,8 +168,6 @@ static void CreateAndRunJITFunc(const std::string &IR, CodeGenOpt::Level OLvl) {
builder.setEngineKind(EngineKind::JIT);
builder.setMCJITMemoryManager(std::make_unique<SectionMemoryManager>());
builder.setOptLevel(OLvl);
Triple ModuleTriple(M->getTargetTriple());
builder.setTargetOptions(
codegen::InitTargetOptionsFromCodeGenFlags(ModuleTriple));