diff options
author | Jay Foad <jay.foad@gmail.com> | 2011-01-11 15:07:38 +0000 |
---|---|---|
committer | Jay Foad <jay.foad@gmail.com> | 2011-01-11 15:07:38 +0000 |
commit | 67c619ba3eae68dcdb3f9340d82b33173aa0c256 (patch) | |
tree | 3c0745fca275d5e4e31f1da2a5a84553fe69bd4a /lib/VMCore | |
parent | 65fdded3197461232d8428af7ddd0107e4a9f946 (diff) | |
download | external_llvm-67c619ba3eae68dcdb3f9340d82b33173aa0c256.zip external_llvm-67c619ba3eae68dcdb3f9340d82b33173aa0c256.tar.gz external_llvm-67c619ba3eae68dcdb3f9340d82b33173aa0c256.tar.bz2 |
FixedNumOperandTraits and VariadicOperandTraits assumed that, given a
"this" pointer for any subclass of User, you could static_cast it to
User* and then reinterpret_cast that to Use* to get the end of the
operand list. This isn't a safe assumption in general, because the
static_cast might adjust the "this" pointer. Fixed by having these
OperandTraits classes take an extra template parameter, which is the
subclass of User. This is groundwork for PR889.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/ConstantsContext.h | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/VMCore/ConstantsContext.h b/lib/VMCore/ConstantsContext.h index 1c04c3e..ffc673f 100644 --- a/lib/VMCore/ConstantsContext.h +++ b/lib/VMCore/ConstantsContext.h @@ -239,54 +239,64 @@ struct CompareConstantExpr : public ConstantExpr { }; template <> -struct OperandTraits<UnaryConstantExpr> : public FixedNumOperandTraits<1> { +struct OperandTraits<UnaryConstantExpr> : + public FixedNumOperandTraits<UnaryConstantExpr, 1> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryConstantExpr, Value) template <> -struct OperandTraits<BinaryConstantExpr> : public FixedNumOperandTraits<2> { +struct OperandTraits<BinaryConstantExpr> : + public FixedNumOperandTraits<BinaryConstantExpr, 2> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryConstantExpr, Value) template <> -struct OperandTraits<SelectConstantExpr> : public FixedNumOperandTraits<3> { +struct OperandTraits<SelectConstantExpr> : + public FixedNumOperandTraits<SelectConstantExpr, 3> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectConstantExpr, Value) template <> -struct OperandTraits<ExtractElementConstantExpr> : public FixedNumOperandTraits<2> { +struct OperandTraits<ExtractElementConstantExpr> : + public FixedNumOperandTraits<ExtractElementConstantExpr, 2> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementConstantExpr, Value) template <> -struct OperandTraits<InsertElementConstantExpr> : public FixedNumOperandTraits<3> { +struct OperandTraits<InsertElementConstantExpr> : + public FixedNumOperandTraits<InsertElementConstantExpr, 3> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementConstantExpr, Value) template <> -struct OperandTraits<ShuffleVectorConstantExpr> : public FixedNumOperandTraits<3> { +struct OperandTraits<ShuffleVectorConstantExpr> : + public FixedNumOperandTraits<ShuffleVectorConstantExpr, 3> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value) template <> -struct OperandTraits<ExtractValueConstantExpr> : public FixedNumOperandTraits<1> { +struct OperandTraits<ExtractValueConstantExpr> : + public FixedNumOperandTraits<ExtractValueConstantExpr, 1> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueConstantExpr, Value) template <> -struct OperandTraits<InsertValueConstantExpr> : public FixedNumOperandTraits<2> { +struct OperandTraits<InsertValueConstantExpr> : + public FixedNumOperandTraits<InsertValueConstantExpr, 2> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueConstantExpr, Value) template <> -struct OperandTraits<GetElementPtrConstantExpr> : public VariadicOperandTraits<1> { +struct OperandTraits<GetElementPtrConstantExpr> : + public VariadicOperandTraits<GetElementPtrConstantExpr, 1> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrConstantExpr, Value) template <> -struct OperandTraits<CompareConstantExpr> : public FixedNumOperandTraits<2> { +struct OperandTraits<CompareConstantExpr> : + public FixedNumOperandTraits<CompareConstantExpr, 2> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CompareConstantExpr, Value) |