Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.152 -> 1.153 --- Log message: Provide a simpler interface for getting a ConstantArray from a character string. Instead of specifying the length, just specify whether the user wants a terminating null or not. The default is "true" to retain the same behavior as previously provided by this function. --- Diffs of the changes: (+4 -8) Constants.cpp | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.152 llvm/lib/VMCore/Constants.cpp:1.153 --- llvm/lib/VMCore/Constants.cpp:1.152 Tue May 30 03:23:18 2006 +++ llvm/lib/VMCore/Constants.cpp Tue May 30 13:15:07 2006 @@ -930,21 +930,17 @@ /// Otherwise, the length parameter specifies how much of the string to use /// and it won't be null terminated. /// -Constant *ConstantArray::get(const std::string &Str, unsigned length) { - assert(length <= Str.length() && "Invalid length for string"); +Constant *ConstantArray::get(const std::string &Str, bool AddNull) { std::vector<Constant*> ElementVals; - - unsigned copy_len = (length == 0 ? Str.length() : length); - for (unsigned i = 0; i < copy_len; ++i) + for (unsigned i = 0; i < Str.length(); ++i) ElementVals.push_back(ConstantSInt::get(Type::SByteTy, Str[i])); // Add a null terminator to the string... - if (length == 0) { + if (AddNull) { ElementVals.push_back(ConstantSInt::get(Type::SByteTy, 0)); - copy_len++; } - ArrayType *ATy = ArrayType::get(Type::SByteTy, copy_len); + ArrayType *ATy = ArrayType::get(Type::SByteTy, ElementVals.size()); return ConstantArray::get(ATy, ElementVals); } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits