X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FGlobalVariable.h;h=633e8b4dc335af68b2d1188b50c68fb21ad007ee;hb=90c579de5a383cee278acc3f7e7b9d0a656e6a35;hp=28eaa624e9d2b2e710cce9d0f0568748712b5696;hpb=e9b11b431308f4766b73cda93e38ec930c912122;p=oota-llvm.git diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h index 28eaa624e9d..633e8b4dc33 100644 --- a/include/llvm/GlobalVariable.h +++ b/include/llvm/GlobalVariable.h @@ -23,12 +23,12 @@ #include "llvm/GlobalValue.h" #include "llvm/OperandTraits.h" #include "llvm/ADT/ilist_node.h" +#include "llvm/ADT/Twine.h" namespace llvm { class Module; class Constant; -class LLVMContext; template class SymbolTableListTraits; @@ -50,15 +50,14 @@ public: } /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. - GlobalVariable(LLVMContext &Context, const Type *Ty, bool isConstant, - LinkageTypes Linkage, - Constant *Initializer = 0, const std::string &Name = "", + GlobalVariable(const Type *Ty, bool isConstant, LinkageTypes Linkage, + Constant *Initializer = 0, const Twine &Name = "", bool ThreadLocal = false, unsigned AddressSpace = 0); /// GlobalVariable ctor - This creates a global and inserts it before the /// specified other global. GlobalVariable(Module &M, const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer, - const std::string &Name, + const Twine &Name, GlobalVariable *InsertBefore = 0, bool ThreadLocal = false, unsigned AddressSpace = 0); @@ -101,18 +100,10 @@ public: assert(hasInitializer() && "GV doesn't have initializer!"); return static_cast(Op<0>().get()); } - inline void setInitializer(Constant *CPV) { - if (CPV == 0) { - if (hasInitializer()) { - Op<0>().set(0); - NumOperands = 0; - } - } else { - if (!hasInitializer()) - NumOperands = 1; - Op<0>().set(CPV); - } - } + /// setInitializer - Sets the initializer for this global variable, removing + /// any existing initializer if InitVal==NULL. If this GV has type T*, the + /// initializer must have type T. + void setInitializer(Constant *InitVal); /// If the value is a global constant, its value is immutable throughout the /// runtime execution of the program. Assigning a value into the constant @@ -151,7 +142,7 @@ public: }; template <> -struct OperandTraits : OptionalOperandTraits<> { +struct OperandTraits : public OptionalOperandTraits<> { }; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalVariable, Value)