bug 122:
authorReid Spencer <rspencer@reidspencer.com>
Sat, 17 Jul 2004 23:28:28 +0000 (23:28 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sat, 17 Jul 2004 23:28:28 +0000 (23:28 +0000)
- derive from Constant
- declare needed overrides from Constant class

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14920 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/GlobalValue.h

index 03fef35e61d34e68f6a9ec50389e11b9794011f0..f72c4740ce39f5228cf9ff5fa8a3587669d6856e 100644 (file)
 #ifndef LLVM_GLOBALVALUE_H
 #define LLVM_GLOBALVALUE_H
 
-#include "llvm/User.h"
+#include "llvm/Constant.h"
 
 namespace llvm {
 
 class PointerType;
 class Module;
 
-class GlobalValue : public User {
+class GlobalValue : public Constant {
   GlobalValue(const GlobalValue &);             // do not implement
 public:
   enum LinkageTypes {
@@ -37,12 +37,19 @@ public:
 protected:
   GlobalValue(const Type *Ty, ValueTy vty, LinkageTypes linkage,
              const std::string &name = "")
-    : User(Ty, vty, name), Linkage(linkage), Parent(0) {}
+    : Constant(Ty, vty, name), Linkage(linkage), Parent(0) { }
 
   LinkageTypes Linkage;   // The linkage of this global
   Module *Parent;
 public:
-  ~GlobalValue() {}
+  virtual ~GlobalValue();
+
+  /// If the usage is empty (except transitively dead constants), then this
+  /// global value can can be safely deleted since the destructor wll 
+  /// delete the dead constants as well.
+  /// @brief Determine if theusage of this global value is empty except 
+  /// for transitively dead constants.
+  bool use_empty_except_constants();
 
   /// getType - Global values are always pointers.
   inline const PointerType *getType() const {
@@ -57,6 +64,13 @@ public:
   void setLinkage(LinkageTypes LT) { Linkage = LT; }
   LinkageTypes getLinkage() const { return Linkage; }
 
+  /// Override from Constant class. No GlobalValue's have null values so
+  /// this always returns false.
+  virtual bool isNullValue() const { return false; }
+
+  /// Override from Constant class.
+  virtual void destroyConstant();
+
   /// isExternal - Return true if the primary definition of this global value is
   /// outside of the current translation unit...
   virtual bool isExternal() const = 0;