aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Constant.h
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-07-17 23:26:12 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-07-17 23:26:12 +0000
commite2643aa9dff62595b30b32ca0f0aadfd2182de1e (patch)
tree7653ad3ad5b90ea78502b97d70c78480f00a9b28 /include/llvm/Constant.h
parentd25e6cd12857dc0e18a15957119d9db98f9311f8 (diff)
downloadexternal_llvm-e2643aa9dff62595b30b32ca0f0aadfd2182de1e.zip
external_llvm-e2643aa9dff62595b30b32ca0f0aadfd2182de1e.tar.gz
external_llvm-e2643aa9dff62595b30b32ca0f0aadfd2182de1e.tar.bz2
Extend constructor so that it can support GlobalValue's (with names).
Make GlobalValue a "classof" Constant Fix the classof(Value*) to include GlobalValue's git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Constant.h')
-rw-r--r--include/llvm/Constant.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h
index 529603a..7b53fb1 100644
--- a/include/llvm/Constant.h
+++ b/include/llvm/Constant.h
@@ -20,7 +20,9 @@ namespace llvm {
class Constant : public User {
protected:
- inline Constant(const Type *Ty) : User(Ty, Value::ConstantVal) {}
+ inline Constant(const Type *Ty, ValueTy vty = Value::ConstantVal,
+ const std::string& Name = "" )
+ : User(Ty, vty, Name) {}
~Constant() {}
void destroyConstantImpl();
@@ -50,20 +52,16 @@ public:
/// available cached constants. Implementations should call
/// destroyConstantImpl as the last thing they do, to destroy all users and
/// delete this.
- ///
- /// Note that this call is only valid on non-primitive constants: You cannot
- /// destroy an integer constant for example. This API is used to delete
- /// constants that have ConstantPointerRef's embeded in them when the module
- /// is deleted, and it is used by GlobalDCE to remove ConstantPointerRefs that
- /// are unneeded, allowing globals to be DCE'd.
- ///
virtual void destroyConstant() { assert(0 && "Not reached!"); }
//// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Constant *) { return true; }
+ static inline bool classof(const GlobalValue *) { return true; }
static inline bool classof(const Value *V) {
- return V->getValueType() == Value::ConstantVal;
+ return V->getValueType() == Value::ConstantVal ||
+ V->getValueType() == Value::FunctionVal ||
+ V->getValueType() == Value::GlobalVariableVal;
}
/// replaceUsesOfWithOnConstant - This method is a special form of