From f073ba6af8ae7fa2cb319c45c34d9ab42c1e6ab2 Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Tue, 16 Mar 2010 10:59:48 +0000 Subject: [PATCH] fix PR6589 adjusted unittest I have added some doxygen to OptionalOperandTraits, so hopefully there will be no confusion in the future. Incidentally OptionalOperandTraits is not used any more (IIUC), but the obvious client would be BranchInstr, and I plan to rearrange it that way. llvm-svn: 98624 --- include/llvm/Instructions.h | 2 +- include/llvm/OperandTraits.h | 7 +++++-- unittests/VMCore/InstructionsTest.cpp | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index f07291cc62c..80b7ca4f82d 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1984,7 +1984,7 @@ public: }; template <> -struct OperandTraits : public OptionalOperandTraits<> { +struct OperandTraits : public VariadicOperandTraits<> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value) diff --git a/include/llvm/OperandTraits.h b/include/llvm/OperandTraits.h index 7c879c88f13..b614ccbc377 100644 --- a/include/llvm/OperandTraits.h +++ b/include/llvm/OperandTraits.h @@ -20,7 +20,7 @@ namespace llvm { //===----------------------------------------------------------------------===// -// FixedNumOperands Trait Class +// FixedNumOperand Trait Class //===----------------------------------------------------------------------===// /// FixedNumOperandTraits - determine the allocation regime of the Use array @@ -51,9 +51,12 @@ struct FixedNumOperandTraits { }; //===----------------------------------------------------------------------===// -// OptionalOperands Trait Class +// OptionalOperand Trait Class //===----------------------------------------------------------------------===// +/// OptionalOperandTraits - when the number of operands may change at runtime. +/// Naturally it may only decrease, because the allocations may not change. + template struct OptionalOperandTraits : public FixedNumOperandTraits { static unsigned operands(const User *U) { diff --git a/unittests/VMCore/InstructionsTest.cpp b/unittests/VMCore/InstructionsTest.cpp index 3823afc4429..15f894039f1 100644 --- a/unittests/VMCore/InstructionsTest.cpp +++ b/unittests/VMCore/InstructionsTest.cpp @@ -14,12 +14,12 @@ namespace llvm { namespace { -TEST(InstructionsTest, ReturnInst_0) { +TEST(InstructionsTest, ReturnInst) { LLVMContext &C(getGlobalContext()); - // reproduction recipe for PR6589 + // test for PR6589 const ReturnInst* r0 = ReturnInst::Create(C); - EXPECT_NE(r0->op_begin(), r0->op_end()); + EXPECT_EQ(r0->op_begin(), r0->op_end()); } } // end anonymous namespace