From: Benjamin Kramer Date: Thu, 3 Aug 2017 15:59:37 +0000 (+0000) Subject: Fix use after free in unit test. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61e4e61f04ce9ab0a37e54d481ceabd087899dc4;p=llvm Fix use after free in unit test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309952 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/Analysis/ScalarEvolutionTest.cpp b/unittests/Analysis/ScalarEvolutionTest.cpp index d4540834239..3d412f43d27 100644 --- a/unittests/Analysis/ScalarEvolutionTest.cpp +++ b/unittests/Analysis/ScalarEvolutionTest.cpp @@ -1000,9 +1000,9 @@ TEST_F(ScalarEvolutionsTest, SCEVExitLimitForgetLoop) { 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, SCEVExitLimitForgetValue) { 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); }