From 1fd7096407d5e598ed3366a1141548e71273f1c5 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Tue, 28 Jul 2009 18:32:17 +0000 Subject: Change ConstantArray to 2.5 API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77347 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Constants.h | 14 +++++++++++++- include/llvm/LLVMContext.h | 21 +-------------------- include/llvm/Support/IRBuilder.h | 2 +- 3 files changed, 15 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index af7187d..442472a 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -327,10 +327,22 @@ class ConstantArray : public Constant { friend struct ConstantCreator >; ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT - friend class LLVMContextImpl; protected: ConstantArray(const ArrayType *T, const std::vector &Val); public: + // ConstantArray accessors + static Constant* get(const ArrayType* T, const std::vector& V); + static Constant* get(const ArrayType* T, Constant* const* Vals, + unsigned NumVals); + + /// This method constructs a ConstantArray and initializes it with a text + /// string. The default behavior (AddNull==true) causes a null terminator to + /// be placed at the end of the array. This effectively increases the length + /// of the array by one (you've been warned). However, in some situations + /// this is not desired so if AddNull==false then the string is copied without + /// null termination. + static Constant* get(const StringRef &Initializer, bool AddNull = true); + /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 8465e4d..03de906 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -58,6 +58,7 @@ class LLVMContext { friend class ConstantInt; friend class ConstantFP; friend class ConstantStruct; + friend class ConstantArray; public: LLVMContext(); ~LLVMContext(); @@ -82,21 +83,6 @@ public: // ConstantAggregateZero accessors ConstantAggregateZero* getConstantAggregateZero(const Type* Ty); - - // ConstantArray accessors - Constant* getConstantArray(const ArrayType* T, - const std::vector& V); - Constant* getConstantArray(const ArrayType* T, Constant* const* Vals, - unsigned NumVals); - - /// This method constructs a ConstantArray and initializes it with a text - /// string. The default behavior (AddNull==true) causes a null terminator to - /// be placed at the end of the array. This effectively increases the length - /// of the array by one (you've been warned). However, in some situations - /// this is not desired so if AddNull==false then the string is copied without - /// null termination. - Constant* getConstantArray(const StringRef &Initializer, - bool AddNull = true); // ConstantExpr accessors Constant* getConstantExpr(unsigned Opcode, Constant* C1, Constant* C2); @@ -225,12 +211,7 @@ public: void erase(MDString *M); void erase(MDNode *M); void erase(ConstantAggregateZero *Z); - void erase(ConstantArray *Z); void erase(ConstantVector *V); - - // RAUW helpers - Constant *replaceUsesOfWithOnConstant(ConstantArray *CA, - Value *From, Value *To, Use *U); }; /// FOR BACKWARDS COMPATIBILITY - Returns a global context. diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index d22bc3d..12439d4 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -413,7 +413,7 @@ public: return CreateConstGEP2_32(Ptr, 0, Idx, Name); } Value *CreateGlobalString(const char *Str = "", const char *Name = "") { - Constant *StrConstant = Context.getConstantArray(Str, true); + Constant *StrConstant = ConstantArray::get(Str, true); Module &M = *BB->getParent()->getParent(); GlobalVariable *gv = new GlobalVariable(M, StrConstant->getType(), -- cgit v1.1