fix PR6589
authorGabor Greif <ggreif@gmail.com>
Tue, 16 Mar 2010 10:59:48 +0000 (10:59 +0000)
committerGabor Greif <ggreif@gmail.com>
Tue, 16 Mar 2010 10:59:48 +0000 (10:59 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98624 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instructions.h
include/llvm/OperandTraits.h
unittests/VMCore/InstructionsTest.cpp

index f07291cc62c42490c455e0d0988bc0c7f333ca1e..80b7ca4f82df35eb3e85be2b52d326be2c07560b 100644 (file)
@@ -1984,7 +1984,7 @@ public:
 };
 
 template <>
-struct OperandTraits<ReturnInst> : public OptionalOperandTraits<> {
+struct OperandTraits<ReturnInst> : public VariadicOperandTraits<> {
 };
 
 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value)
index 7c879c88f13ba05f85738ed3aa2b4c03a9cc7e60..b614ccbc3777a31e9c2c922e05ad88bc1789ea34 100644 (file)
@@ -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 <unsigned ARITY = 1>
 struct OptionalOperandTraits : public FixedNumOperandTraits<ARITY> {
   static unsigned operands(const User *U) {
index 3823afc4429ea9bc6f50873171719881bfb15eba..15f894039f1f2d7744f9c3f31cdc539134e394be 100644 (file)
 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