diff options
Diffstat (limited to 'llvm/lib/VMCore')
-rw-r--r-- | llvm/lib/VMCore/AsmWriter.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 13 |
2 files changed, 6 insertions, 11 deletions
diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index 0c62d05d2b3..545349a6f5f 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -274,9 +274,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, if (isString) { Out << "c\""; for (unsigned i = 0; i < CA->getNumOperands(); ++i) { - unsigned char C = (ETy == Type::SByteTy) ? - (unsigned char)cast<ConstantSInt>(CA->getOperand(i))->getValue() : - (unsigned char)cast<ConstantUInt>(CA->getOperand(i))->getValue(); + unsigned char C = cast<ConstantInt>(CA->getOperand(i))->getRawValue(); if (isprint(C) && C != '"' && C != '\\') { Out << C; diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 935c2938c22..7bbbdb32023 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -601,15 +601,12 @@ ConstantArray *ConstantArray::get(const std::string &Str) { // Otherwise, it asserts out. // std::string ConstantArray::getAsString() const { + assert((getType()->getElementType() == Type::UByteTy || + getType()->getElementType() == Type::SByteTy) && "Not a string!"); + std::string Result; - if (getType()->getElementType() == Type::SByteTy) - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - Result += (char)cast<ConstantSInt>(getOperand(i))->getValue(); - else { - assert(getType()->getElementType() == Type::UByteTy && "Not a string!"); - for (unsigned i = 0, e = getNumOperands(); i != e; ++i) - Result += (char)cast<ConstantUInt>(getOperand(i))->getValue(); - } + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) + Result += (char)cast<ConstantInt>(getOperand(i))->getRawValue(); return Result; } |