[llvm] r309952 - Fix use after free in unit test.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 08:59:37 PDT 2017


Author: d0k
Date: Thu Aug  3 08:59:37 2017
New Revision: 309952

URL: http://llvm.org/viewvc/llvm-project?rev=309952&view=rev
Log:
Fix use after free in unit test.

Modified:
    llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp

Modified: llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp?rev=309952&r1=309951&r2=309952&view=diff
==============================================================================
--- llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp (original)
+++ llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp Thu Aug  3 08:59:37 2017
@@ -1000,9 +1000,9 @@ TEST_F(ScalarEvolutionsTest, SCEVExitLim
   Cond->eraseFromParent();
 
   Builder.SetInsertPoint(L);
-  Builder.CreateICmp(ICmpInst::ICMP_SLT, Add, ConstantInt::get(T_int64, 2000),
-                     "new.cond");
-  Builder.CreateCondBr(Cond, L, Post);
+  auto *NewCond = Builder.CreateICmp(
+      ICmpInst::ICMP_SLT, Add, ConstantInt::get(T_int64, 2000), "new.cond");
+  Builder.CreateCondBr(NewCond, L, Post);
   const SCEV *NewEC = SE.getBackedgeTakenCount(Loop);
   EXPECT_NE(EC, NewEC);
 }
@@ -1081,9 +1081,9 @@ TEST_F(ScalarEvolutionsTest, SCEVExitLim
   Load->eraseFromParent();
 
   Builder.SetInsertPoint(L);
-  Builder.CreateICmp(ICmpInst::ICMP_SLT, Add, ConstantInt::get(T_int64, 2000),
-                     "new.cond");
-  Builder.CreateCondBr(Cond, L, Post);
+  auto *NewCond = Builder.CreateICmp(
+      ICmpInst::ICMP_SLT, Add, ConstantInt::get(T_int64, 2000), "new.cond");
+  Builder.CreateCondBr(NewCond, L, Post);
   const SCEV *NewEC = SE.getBackedgeTakenCount(Loop);
   EXPECT_NE(EC, NewEC);
 }




More information about the llvm-commits mailing list