llvm.org GIT mirror llvm / ff7782b
Remove DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS, folding its functionality into DEFINE_TRANSPARENT_OPERAND_ACCESSORS. A side-effect of this is that the operand accessors for Constants will tolerate NULL operands, fixing PR10663. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138230 91177308-0d34-0410-b5e6-96231b3b80d8 Jay Foad 8 years ago
3 changed file(s) with 8 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
389389 public VariadicOperandTraits {
390390 };
391391
392 DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantArray, Constant)
392 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantArray, Constant)
393393
394394 //===----------------------------------------------------------------------===//
395395 // ConstantStruct - Constant Struct Declarations
449449 public VariadicOperandTraits {
450450 };
451451
452 DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantStruct, Constant)
452 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantStruct, Constant)
453453
454454
455455 //===----------------------------------------------------------------------===//
500500 public VariadicOperandTraits {
501501 };
502502
503 DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantVector, Constant)
503 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantVector, Constant)
504504
505505 //===----------------------------------------------------------------------===//
506506 /// ConstantPointerNull - a constant pointer value that points to null
574574 public FixedNumOperandTraits {
575575 };
576576
577 DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(BlockAddress, Value)
577 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BlockAddress, Value)
578578
579579
580580 //===----------------------------------------------------------------------===//
883883 public VariadicOperandTraits {
884884 };
885885
886 DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantExpr, Constant)
886 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantExpr, Constant)
887887
888888 //===----------------------------------------------------------------------===//
889889 /// UndefValue - 'undef' values are things that do not have specified contents.
8686 public FixedNumOperandTraits {
8787 };
8888
89 DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(GlobalAlias, Constant)
89 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Constant)
9090
9191 } // End llvm namespace
9292
135135 VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \
136136 assert(i_nocapture < OperandTraits::operands(this) \
137137 && "getOperand() out of range!"); \
138 return static_cast( \
139 OperandTraits::op_begin(const_cast(this))[i_nocapture]); \
140 } \
141 void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \
142 assert(i_nocapture < OperandTraits::operands(this) \
143 && "setOperand() out of range!"); \
144 OperandTraits::op_begin(this)[i_nocapture] = Val_nocapture; \
145 } \
146 unsigned CLASS::getNumOperands() const { \
147 return OperandTraits::operands(this); \
148 } \
149 template Use &CLASS::Op() { \
150 return this->OpFrom(this); \
151 } \
152 template const Use &CLASS::Op() const { \
153 return this->OpFrom(this); \
154 }
155
156
157 /// Macro for generating out-of-class operand accessor
158 /// definitions with casted result
159 #define DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(CLASS, VALUECLASS) \
160 CLASS::op_iterator CLASS::op_begin() { \
161 return OperandTraits::op_begin(this); \
162 } \
163 CLASS::const_op_iterator CLASS::op_begin() const { \
164 return OperandTraits::op_begin(const_cast(this)); \
165 } \
166 CLASS::op_iterator CLASS::op_end() { \
167 return OperandTraits::op_end(this); \
168 } \
169 CLASS::const_op_iterator CLASS::op_end() const { \
170 return OperandTraits::op_end(const_cast(this)); \
171 } \
172 VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \
173 assert(i_nocapture < OperandTraits::operands(this) \
174 && "getOperand() out of range!"); \
175 return cast( \
176 OperandTraits::op_begin(const_cast(this))[i_nocapture]); \
138 return cast_or_null( \
139 OperandTraits::op_begin(const_cast(this))[i_nocapture].get()); \
177140 } \
178141 void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \
179142 assert(i_nocapture < OperandTraits::operands(this) \