[llvm-commits] [llvm] r49483 - /llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h

Gabor Greif ggreif at gmail.com
Thu Apr 10 07:54:43 PDT 2008


Author: ggreif
Date: Thu Apr 10 09:54:43 2008
New Revision: 49483

URL: http://llvm.org/viewvc/llvm-project?rev=49483&view=rev
Log:
introduce GlobalVariable::Create methods

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h

Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h?rev=49483&r1=49482&r2=49483&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h Thu Apr 10 09:54:43 2008
@@ -32,7 +32,6 @@
 
 class GlobalVariable : public GlobalValue {
   friend class SymbolTableListTraits<GlobalVariable, Module>;
-  void *operator new(size_t, unsigned);       // Do not implement
   void operator=(const GlobalVariable &);     // Do not implement
   GlobalVariable(const GlobalVariable &);     // Do not implement
 
@@ -45,23 +44,39 @@
   bool isConstantGlobal : 1;           // Is this a global constant?
   bool isThreadLocalSymbol : 1;        // Is this symbol "Thread Local"?
 
-public:
-  // allocate space for exactly one operand
-  void *operator new(size_t s) {
-    return User::operator new(s, 1); // FIXME: if no initializer, then 0
-  }
-  /// GlobalVariable ctor - If a parent module is specified, the global is
-  /// automatically inserted into the end of the specified modules global list.
+private:
+  /// GlobalVariable ctor - for internal use.
   GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage,
-                 Constant *Initializer = 0, const std::string &Name = "",
-                 Module *Parent = 0, bool ThreadLocal = false, 
-                 unsigned AddressSpace = 0);
-  /// GlobalVariable ctor - This creates a global and inserts it before the
-  /// specified other global.
+                 Constant *Initializer, const std::string &Name,
+                 Module *Parent, bool ThreadLocal, unsigned AddressSpace);
+  /// GlobalVariable ctor - for internal use.
   GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage,
                  Constant *Initializer, const std::string &Name,
-                 GlobalVariable *InsertBefore, bool ThreadLocal = false, 
-                 unsigned AddressSpace = 0);
+                 GlobalVariable *InsertBefore, bool ThreadLocal,
+                 unsigned AddressSpace);
+
+public:
+  /// GlobalVariable creator - If a parent module is specified, the global is
+  /// automatically inserted into the end of the specified modules global list.
+  static GlobalVariable *Create(const Type *Ty, bool isConstant, LinkageTypes Linkage,
+                                Constant *Initializer = 0, const std::string &Name = "",
+                                Module *Parent = 0, bool ThreadLocal = false, 
+                                unsigned AddressSpace = 0) {
+    return new (!!Initializer) GlobalVariable(Ty, isConstant, Linkage,
+                                              Initializer, Name, Parent,
+                                              ThreadLocal, AddressSpace);
+  }
+
+  /// GlobalVariable creator - This creates a global and inserts it before the
+  /// specified other global.
+  static GlobalVariable *Create(const Type *Ty, bool isConstant, LinkageTypes Linkage,
+                                Constant *Initializer, const std::string &Name,
+                                GlobalVariable *InsertBefore, bool ThreadLocal = false, 
+                                unsigned AddressSpace = 0) {
+    return new (!!Initializer) GlobalVariable(Ty, isConstant, Linkage,
+                                              Initializer, Name, InsertBefore,
+                                              ThreadLocal, AddressSpace);
+  }
   
   /// isDeclaration - Is this global variable lacking an initializer?  If so, 
   /// the global variable is defined in some other translation unit, and is thus





More information about the llvm-commits mailing list