From 6077c3195f74b27b75ed3e9df3af7a13798b437f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 23 Jul 2003 15:22:26 +0000 Subject: Simplify code by using ConstantInt::getRawValue instead of checking to see whether the constant is signed or unsigned, then casting llvm-svn: 7252 --- llvm/lib/Target/X86/Printer.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'llvm/lib/Target/X86/Printer.cpp') diff --git a/llvm/lib/Target/X86/Printer.cpp b/llvm/lib/Target/X86/Printer.cpp index c2f2bb8f794..08dbb6c7a5c 100644 --- a/llvm/lib/Target/X86/Printer.cpp +++ b/llvm/lib/Target/X86/Printer.cpp @@ -293,9 +293,7 @@ static std::string getAsCString(const ConstantArray *CVA) { const Type *ETy = cast(CVA->getType())->getElementType(); Result = "\""; for (unsigned i = 0; i < CVA->getNumOperands(); ++i) { - unsigned char C = (ETy == Type::SByteTy) ? - (unsigned char)cast(CVA->getOperand(i))->getValue() : - (unsigned char)cast(CVA->getOperand(i))->getValue(); + unsigned char C = cast(CVA->getOperand(i))->getRawValue(); if (C == '"') { Result += "\\\""; @@ -943,19 +941,14 @@ bool Printer::doInitialization(Module &M) return false; // success } -static const Function *isConstantFunctionPointerRef (const Constant *C) { - const ConstantPointerRef *R = dyn_cast(C); - if (R) { - const Function *F = dyn_cast(R->getValue()); - if (F) { +static const Function *isConstantFunctionPointerRef(const Constant *C) { + if (const ConstantPointerRef *R = dyn_cast(C)) + if (const Function *F = dyn_cast(R->getValue())) return F; - } - } - return NULL; + return 0; } -bool Printer::doFinalization(Module &M) -{ +bool Printer::doFinalization(Module &M) { // Print out module-level global variables here. for (Module::const_giterator I = M.gbegin(), E = M.gend(); I != E; ++I) { std::string name(getValueName(I)); @@ -989,5 +982,3 @@ bool Printer::doFinalization(Module &M) MangledGlobals.clear(); return false; // success } - - -- cgit v1.2.3