Skip to content

Commit

Permalink
eliminate the "string" form of ConstantArray::get, using
Browse files Browse the repository at this point in the history
ConstantDataArray::getString instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149365 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Jan 31, 2012
1 parent f98743a commit 6a89228
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 23 deletions.
11 changes: 0 additions & 11 deletions include/llvm/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,17 +352,6 @@ class ConstantArray : public Constant {
// ConstantArray accessors
static Constant *get(ArrayType *T, ArrayRef<Constant*> V);

/// 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.

// FIXME Remove this.
static Constant *get(LLVMContext &Context, StringRef Initializer,
bool AddNull = true);

/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);

Expand Down
3 changes: 2 additions & 1 deletion lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,8 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
}
case lltok::kw_c: // c "foo"
Lex.Lex();
ID.ConstantVal = ConstantArray::get(Context, Lex.getStrVal(), false);
ID.ConstantVal = ConstantDataArray::getString(Context, Lex.getStrVal(),
false);
if (ParseToken(lltok::StringConstant, "expected string")) return true;
ID.Kind = ValID::t_Constant;
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const char *AddressSanitizer::getPassName() const {

// Create a constant for Str so that we can pass it to the run-time lib.
static GlobalVariable *createPrivateGlobalForString(Module &M, StringRef Str) {
Constant *StrConst = ConstantArray::get(M.getContext(), Str);
Constant *StrConst = ConstantDataArray::getString(M.getContext(), Str);
return new GlobalVariable(M, StrConst->getType(), true,
GlobalValue::PrivateLinkage, StrConst, "");
}
Expand Down
6 changes: 0 additions & 6 deletions lib/VMCore/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,6 @@ Constant *ConstantArray::get(ArrayType *Ty, ArrayRef<Constant*> V) {
return pImpl->ArrayConstants.getOrCreate(Ty, V);
}

// FIXME: Remove this method.
Constant *ConstantArray::get(LLVMContext &Context, StringRef Str,
bool AddNull) {
return ConstantDataArray::getString(Context, Str, AddNull);
}

/// getTypeForElements - Return an anonymous struct type to use for a constant
/// with the specified set of elements. The list must not be empty.
StructType *ConstantStruct::getTypeForElements(LLVMContext &Context,
Expand Down
4 changes: 2 additions & 2 deletions lib/VMCore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,8 @@ LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
LLVMBool DontNullTerminate) {
/* Inverted the sense of AddNull because ', 0)' is a
better mnemonic for null termination than ', 1)'. */
return wrap(ConstantArray::get(*unwrap(C), StringRef(Str, Length),
DontNullTerminate == 0));
return wrap(ConstantDataArray::getString(*unwrap(C), StringRef(Str, Length),
DontNullTerminate == 0));
}
LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
LLVMValueRef *ConstantVals,
Expand Down
2 changes: 1 addition & 1 deletion lib/VMCore/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace llvm;
/// specified. If Name is specified, it is the name of the global variable
/// created.
Value *IRBuilderBase::CreateGlobalString(StringRef Str, const Twine &Name) {
Constant *StrConstant = ConstantArray::get(Context, Str, true);
Constant *StrConstant = ConstantDataArray::getString(Context, Str);
Module &M = *BB->getParent()->getParent();
GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
true, GlobalValue::PrivateLinkage,
Expand Down
3 changes: 2 additions & 1 deletion tools/bugpoint/Miscompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// Don't forward functions which are external in the test module too.
if (TestFn && !TestFn->isDeclaration()) {
// 1. Add a string constant with its name to the global file
Constant *InitArray = ConstantArray::get(F->getContext(), F->getName());
Constant *InitArray =
ConstantDataArray::getString(F->getContext(), F->getName());
GlobalVariable *funcName =
new GlobalVariable(*Safe, InitArray->getType(), true /*isConstant*/,
GlobalValue::InternalLinkage, InitArray,
Expand Down

0 comments on commit 6a89228

Please sign in to comment.