summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Constants.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-07-23 15:22:26 +0000
committerChris Lattner <sabre@nondot.org>2003-07-23 15:22:26 +0000
commit6077c3195f74b27b75ed3e9df3af7a13798b437f (patch)
tree48a5a2e54b7d1a5762d782e838db817d8a2e78ca /llvm/lib/VMCore/Constants.cpp
parent79f22fe02fe354c50fc4d6a1c08a894fdd847dba (diff)
downloadbcm5719-llvm-6077c3195f74b27b75ed3e9df3af7a13798b437f.tar.gz
bcm5719-llvm-6077c3195f74b27b75ed3e9df3af7a13798b437f.zip
Simplify code by using ConstantInt::getRawValue instead of checking to see
whether the constant is signed or unsigned, then casting llvm-svn: 7252
Diffstat (limited to 'llvm/lib/VMCore/Constants.cpp')
-rw-r--r--llvm/lib/VMCore/Constants.cpp13
1 files changed, 5 insertions, 8 deletions
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;
}
OpenPOWER on IntegriCloud