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

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 26 05:25:27 PDT 2020


Author: Simon Pilgrim
Date: 2020-10-26T12:24:18Z
New Revision: e4991867fb5ace434640bfacfd28720ad031d33c

URL: https://github.com/llvm/llvm-project/commit/e4991867fb5ace434640bfacfd28720ad031d33c
DIFF: https://github.com/llvm/llvm-project/commit/e4991867fb5ace434640bfacfd28720ad031d33c.diff

LOG: [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.

Added: 
    

Modified: 
    clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp

Removed: 
    


################################################################################
diff  --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
index d57515b1ac13..17ce40b5b1b6 100644
--- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -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));
 


        


More information about the cfe-commits mailing list