aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-31 06:05:00 +0000
committerChris Lattner <sabre@nondot.org>2012-01-31 06:05:00 +0000
commit1b2f643753a2974540934ac0f1e3ffd182b0571c (patch)
treec7f571a94ad375ba815a3ee6291123e9f3c00c59 /lib/VMCore
parentca012b8b2341a987f0022adc42424ac8ed26752a (diff)
downloadexternal_llvm-1b2f643753a2974540934ac0f1e3ffd182b0571c.zip
external_llvm-1b2f643753a2974540934ac0f1e3ffd182b0571c.tar.gz
external_llvm-1b2f643753a2974540934ac0f1e3ffd182b0571c.tar.bz2
with recent changes, ConstantArray is never a "string". Remove the associated
methods and constant fold the clients to false. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149362 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/AsmWriter.cpp29
-rw-r--r--lib/VMCore/Constants.cpp63
2 files changed, 10 insertions, 82 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index eb0f661..1dd1254 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -827,30 +827,21 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
}
if (const ConstantArray *CA = dyn_cast<ConstantArray>(CV)) {
- // As a special case, print the array as a string if it is an array of
- // i8 with ConstantInt values.
- //
Type *ETy = CA->getType()->getElementType();
- if (CA->isString()) {
- Out << "c\"";
- PrintEscapedString(CA->getAsString(), Out);
- Out << '"';
- } else { // Cannot output in string format...
- Out << '[';
+ Out << '[';
+ TypePrinter.print(ETy, Out);
+ Out << ' ';
+ WriteAsOperandInternal(Out, CA->getOperand(0),
+ &TypePrinter, Machine,
+ Context);
+ for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
+ Out << ", ";
TypePrinter.print(ETy, Out);
Out << ' ';
- WriteAsOperandInternal(Out, CA->getOperand(0),
- &TypePrinter, Machine,
+ WriteAsOperandInternal(Out, CA->getOperand(i), &TypePrinter, Machine,
Context);
- for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
- Out << ", ";
- TypePrinter.print(ETy, Out);
- Out << ' ';
- WriteAsOperandInternal(Out, CA->getOperand(i), &TypePrinter, Machine,
- Context);
- }
- Out << ']';
}
+ Out << ']';
return;
}
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 39c96c7..409c137 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -1201,69 +1201,6 @@ void ConstantArray::destroyConstant() {
destroyConstantImpl();
}
-/// isString - This method returns true if the array is an array of i8, and
-/// if the elements of the array are all ConstantInt's.
-bool ConstantArray::isString() const {
- // Check the element type for i8...
- if (!getType()->getElementType()->isIntegerTy(8))
- return false;
- // Check the elements to make sure they are all integers, not constant
- // expressions.
- for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
- if (!isa<ConstantInt>(getOperand(i)))
- return false;
- 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 {
- // Check the element type for i8...
- if (!getType()->getElementType()->isIntegerTy(8))
- return false;
-
- // Last element must be a null.
- if (!getOperand(getNumOperands()-1)->isNullValue())
- return false;
- // Other elements must be non-null integers.
- for (unsigned i = 0, e = getNumOperands()-1; i != e; ++i) {
- if (!isa<ConstantInt>(getOperand(i)))
- return false;
- if (getOperand(i)->isNullValue())
- return false;
- }
- return true;
-}
-
-
-/// convertToString - Helper function for getAsString() and getAsCString().
-static std::string convertToString(const User *U, unsigned len) {
- std::string Result;
- Result.reserve(len);
- for (unsigned i = 0; i != len; ++i)
- Result.push_back((char)cast<ConstantInt>(U->getOperand(i))->getZExtValue());
- return Result;
-}
-
-/// getAsString - If this array is isString(), then this method converts the
-/// array to an std::string and returns it. Otherwise, it asserts out.
-///
-std::string ConstantArray::getAsString() const {
- assert(isString() && "Not a string!");
- return convertToString(this, getNumOperands());
-}
-
-
-/// getAsCString - If this array is isCString(), then this method converts the
-/// array (without the trailing null byte) to an std::string and returns it.
-/// Otherwise, it asserts out.
-///
-std::string ConstantArray::getAsCString() const {
- assert(isCString() && "Not a string!");
- return convertToString(this, getNumOperands() - 1);
-}
-
//---- ConstantStruct::get() implementation...
//