diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-29 02:14:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-29 02:14:09 +0000 |
commit | cafe9bba32aeed16e8e3db28b4cd4ff13160438f (patch) | |
tree | bfb7c4d1f2a2bf144d5525b22380806b86325c00 /include/llvm/Constants.h | |
parent | 3990b121cf4a0b280ed3e54cf13870cbf4259e78 (diff) | |
download | llvm-cafe9bba32aeed16e8e3db28b4cd4ff13160438f.tar.gz llvm-cafe9bba32aeed16e8e3db28b4cd4ff13160438f.tar.bz2 llvm-cafe9bba32aeed16e8e3db28b4cd4ff13160438f.tar.xz |
add a layer of accessors around the Value::SubClassData member, and use
a convention (shadowing the setter with private forwarding function) to
prevent subclasses from accidentally using it.
This exposed some bogosity in ConstantExprs, which was propaging the
opcode of the constant expr into the NUW/NSW/Exact field in the
getWithOperands/getWithOperandReplaced methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constants.h')
-rw-r--r-- | include/llvm/Constants.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 79c1eaab8b..f34f9cbf58 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -605,7 +605,7 @@ protected: ConstantExpr(const Type *ty, unsigned Opcode, Use *Ops, unsigned NumOps) : Constant(ty, ConstantExprVal, Ops, NumOps) { // Operation type (an Instruction opcode) is stored as the SubclassData. - SubclassData = Opcode; + setValueSubclassData(Opcode); } // These private methods are used by the type resolution code to create @@ -814,7 +814,7 @@ public: virtual bool isNullValue() const { return false; } /// getOpcode - Return the opcode at the root of this constant expression - unsigned getOpcode() const { return SubclassData; } + unsigned getOpcode() const { return getSubclassDataFromValue(); } /// getPredicate - Return the ICMP or FCMP predicate value. Assert if this is /// not an ICMP or FCMP constant expression. @@ -847,6 +847,13 @@ public: static inline bool classof(const Value *V) { return V->getValueID() == ConstantExprVal; } + +private: + // Shadow Value::setValueSubclassData with a private forwarding method so that + // subclasses cannot accidentally use it. + void setValueSubclassData(unsigned short D) { + Value::setValueSubclassData(D); + } }; template <> |