Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.166 -> 1.167 --- Log message: Add isCString() - returns true if a ConstantArray is a CString. --- Diffs of the changes: (+13 -0) Constants.cpp | 13 +++++++++++++ 1 files changed, 13 insertions(+) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.166 llvm/lib/VMCore/Constants.cpp:1.167 --- llvm/lib/VMCore/Constants.cpp:1.166 Thu Oct 26 01:15:43 2006 +++ llvm/lib/VMCore/Constants.cpp Thu Oct 26 14:15:05 2006 @@ -1073,6 +1073,19 @@ return true; } +/// isCString - This method returns true if the array is a string (see +/// isString) and it ends in a null byte \0 and does not contains any other +/// null bytes except its terminator. +bool ConstantArray::isCString() const { + if (!isString()) return false; + // This is safe because a ConstantArray cannot be a zero array. + for (unsigned i = 0, e = getNumOperands()-1; i != e; ++i) + if (cast<ConstantInt>(getOperand(i))->getZExtValue() == 0) + return false; + return true; +} + + // getAsString - If the sub-element type of this array is either sbyte or ubyte, // then this method converts the array to an std::string and returns it. // Otherwise, it asserts out. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits