From: Michael Platings Date: Thu, 7 Mar 2019 11:55:26 +0000 (+0000) Subject: Fix & re-enable test that intermittently failed in debug mode. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81cf489ba884fb01efbb22f4bbb7662122259243;p=llvm Fix & re-enable test that intermittently failed in debug mode. The Value class and derivates will have uninitialized member variables if not created via operator new. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355590 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp index 4d967d29097..34ebd59bc3d 100644 --- a/unittests/IR/ConstantsTest.cpp +++ b/unittests/IR/ConstantsTest.cpp @@ -556,20 +556,21 @@ TEST(ConstantsTest, DontFoldFunctionPtrIfNoModule) { ASSERT_FALSE(foldFuncPtrAndConstToNull(Context, nullptr, 2, 4)); } -TEST(ConstantsTest, DISABLED_FoldGlobalVariablePtr) { +TEST(ConstantsTest, FoldGlobalVariablePtr) { LLVMContext Context; IntegerType *IntType(Type::getInt32Ty(Context)); - GlobalVariable Global(IntType, true, GlobalValue::ExternalLinkage); + std::unique_ptr Global( + new GlobalVariable(IntType, true, GlobalValue::ExternalLinkage)); - Global.setAlignment(4); + Global->setAlignment(4); ConstantInt *TheConstant(ConstantInt::get(IntType, 2)); Constant *TheConstantExpr( - ConstantExpr::getPtrToInt(&Global, IntType)); + ConstantExpr::getPtrToInt(Global.get(), IntType)); ASSERT_TRUE(ConstantExpr::get( \ Instruction::And, TheConstantExpr, TheConstant)->isNullValue());