aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2011-08-22 09:37:03 +0000
committerJay Foad <jay.foad@gmail.com>2011-08-22 09:37:03 +0000
commitff7782bcc9235b1dc4c7fcb0497c52e4717eeffc (patch)
tree99ca705bb9c4fae6122b47bc8c42bbddf35ff932
parent2e608c6b611bbd4269763653178c91860ed847eb (diff)
downloadexternal_llvm-ff7782bcc9235b1dc4c7fcb0497c52e4717eeffc.zip
external_llvm-ff7782bcc9235b1dc4c7fcb0497c52e4717eeffc.tar.gz
external_llvm-ff7782bcc9235b1dc4c7fcb0497c52e4717eeffc.tar.bz2
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
-rw-r--r--include/llvm/Constants.h10
-rw-r--r--include/llvm/GlobalAlias.h2
-rw-r--r--include/llvm/OperandTraits.h41
3 files changed, 8 insertions, 45 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index e011c56..5785b81 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -390,7 +390,7 @@ struct OperandTraits<ConstantArray> :
public VariadicOperandTraits<ConstantArray> {
};
-DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantArray, Constant)
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantArray, Constant)
//===----------------------------------------------------------------------===//
// ConstantStruct - Constant Struct Declarations
@@ -450,7 +450,7 @@ struct OperandTraits<ConstantStruct> :
public VariadicOperandTraits<ConstantStruct> {
};
-DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantStruct, Constant)
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantStruct, Constant)
//===----------------------------------------------------------------------===//
@@ -501,7 +501,7 @@ struct OperandTraits<ConstantVector> :
public VariadicOperandTraits<ConstantVector> {
};
-DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantVector, Constant)
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantVector, Constant)
//===----------------------------------------------------------------------===//
/// ConstantPointerNull - a constant pointer value that points to null
@@ -575,7 +575,7 @@ struct OperandTraits<BlockAddress> :
public FixedNumOperandTraits<BlockAddress, 2> {
};
-DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(BlockAddress, Value)
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BlockAddress, Value)
//===----------------------------------------------------------------------===//
@@ -884,7 +884,7 @@ struct OperandTraits<ConstantExpr> :
public VariadicOperandTraits<ConstantExpr, 1> {
};
-DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantExpr, Constant)
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantExpr, Constant)
//===----------------------------------------------------------------------===//
/// UndefValue - 'undef' values are things that do not have specified contents.
diff --git a/include/llvm/GlobalAlias.h b/include/llvm/GlobalAlias.h
index 5a814bf..164d976 100644
--- a/include/llvm/GlobalAlias.h
+++ b/include/llvm/GlobalAlias.h
@@ -87,7 +87,7 @@ struct OperandTraits<GlobalAlias> :
public FixedNumOperandTraits<GlobalAlias, 1> {
};
-DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(GlobalAlias, Constant)
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Constant)
} // End llvm namespace
diff --git a/include/llvm/OperandTraits.h b/include/llvm/OperandTraits.h
index f0df5fa..3d8dc32 100644
--- a/include/llvm/OperandTraits.h
+++ b/include/llvm/OperandTraits.h
@@ -136,45 +136,8 @@ CLASS::const_op_iterator CLASS::op_end() const { \
VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \
assert(i_nocapture < OperandTraits<CLASS>::operands(this) \
&& "getOperand() out of range!"); \
- return static_cast<VALUECLASS*>( \
- OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this))[i_nocapture]); \
-} \
-void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \
- assert(i_nocapture < OperandTraits<CLASS>::operands(this) \
- && "setOperand() out of range!"); \
- OperandTraits<CLASS>::op_begin(this)[i_nocapture] = Val_nocapture; \
-} \
-unsigned CLASS::getNumOperands() const { \
- return OperandTraits<CLASS>::operands(this); \
-} \
-template <int Idx_nocapture> Use &CLASS::Op() { \
- return this->OpFrom<Idx_nocapture>(this); \
-} \
-template <int Idx_nocapture> const Use &CLASS::Op() const { \
- return this->OpFrom<Idx_nocapture>(this); \
-}
-
-
-/// Macro for generating out-of-class operand accessor
-/// definitions with casted result
-#define DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(CLASS, VALUECLASS) \
-CLASS::op_iterator CLASS::op_begin() { \
- return OperandTraits<CLASS>::op_begin(this); \
-} \
-CLASS::const_op_iterator CLASS::op_begin() const { \
- return OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this)); \
-} \
-CLASS::op_iterator CLASS::op_end() { \
- return OperandTraits<CLASS>::op_end(this); \
-} \
-CLASS::const_op_iterator CLASS::op_end() const { \
- return OperandTraits<CLASS>::op_end(const_cast<CLASS*>(this)); \
-} \
-VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \
- assert(i_nocapture < OperandTraits<CLASS>::operands(this) \
- && "getOperand() out of range!"); \
- return cast<VALUECLASS>( \
- OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this))[i_nocapture]); \
+ return cast_or_null<VALUECLASS>( \
+ OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this))[i_nocapture].get()); \
} \
void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \
assert(i_nocapture < OperandTraits<CLASS>::operands(this) \