From 122787bcffcedbe2977728c18992e6b97d3216f6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 5 Jun 2002 18:08:26 +0000 Subject: [PATCH] Fix Constness problems git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2761 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index 74b7f73da36..db5b6cd7250 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -458,7 +458,7 @@ private: // Can we treat the specified array as a string? Only if it is an array of // ubytes or non-negative sbytes. // -static bool isStringCompatible(ConstantArray *CPA) { +static bool isStringCompatible(const ConstantArray *CPA) { const Type *ETy = cast(CPA->getType())->getElementType(); if (ETy == Type::UByteTy) return true; if (ETy != Type::SByteTy) return false; @@ -478,7 +478,7 @@ static inline char toOctal(int X) { // getAsCString - Return the specified array as a C compatible string, only if // the predicate isStringCompatible is true. // -static string getAsCString(ConstantArray *CPA) { +static string getAsCString(const ConstantArray *CPA) { assert(isStringCompatible(CPA) && "Array is not string compatible!"); string Result; @@ -517,7 +517,7 @@ static string getAsCString(ConstantArray *CPA) { } inline bool -ArrayTypeIsString(ArrayType* arrayType) +ArrayTypeIsString(const ArrayType* arrayType) { return (arrayType->getElementType() == Type::UByteTy || arrayType->getElementType() == Type::SByteTy); @@ -556,9 +556,9 @@ TypeToDataDirective(const Type* type) inline unsigned int ConstantToSize(const Constant* CV, const TargetMachine& target) { - if (ConstantArray* CPA = dyn_cast(CV)) + if (const ConstantArray* CPA = dyn_cast(CV)) { - ArrayType *aty = cast(CPA->getType()); + const ArrayType *aty = cast(CPA->getType()); if (ArrayTypeIsString(aty)) return 1 + CPA->getNumOperands(); } @@ -596,7 +596,7 @@ TypeToAlignment(const Type* type, const TargetMachine& target) inline unsigned int ConstantToAlignment(const Constant* CV, const TargetMachine& target) { - if (ConstantArray* CPA = dyn_cast(CV)) + if (const ConstantArray* CPA = dyn_cast(CV)) if (ArrayTypeIsString(cast(CPA->getType()))) return SizeToAlignment(1 + CPA->getNumOperands(), target); @@ -641,7 +641,7 @@ SparcModuleAsmPrinter::printSingleConstant(const Constant* CV) WriteAsOperand(toAsm, CV, false, false) << "\n"; } } - else if (ConstantPointer* CPP = dyn_cast(CV)) + else if (const ConstantPointer* CPP = dyn_cast(CV)) { assert(CPP->isNullValue() && "Cannot yet print non-null pointer constants to assembly"); @@ -662,7 +662,7 @@ SparcModuleAsmPrinter::printSingleConstant(const Constant* CV) void SparcModuleAsmPrinter::printConstantValueOnly(const Constant* CV) { - ConstantArray *CPA = dyn_cast(CV); + const ConstantArray *CPA = dyn_cast(CV); if (CPA && isStringCompatible(CPA)) { // print the string alone and return @@ -672,16 +672,16 @@ SparcModuleAsmPrinter::printConstantValueOnly(const Constant* CV) { // Not a string. Print the values in successive locations const std::vector &constValues = CPA->getValues(); for (unsigned i=0; i < constValues.size(); i++) - this->printConstantValueOnly(cast(constValues[i].get())); + printConstantValueOnly(cast(constValues[i].get())); } - else if (ConstantStruct *CPS = dyn_cast(CV)) + else if (const ConstantStruct *CPS = dyn_cast(CV)) { // Print the fields in successive locations const std::vector& constValues = CPS->getValues(); for (unsigned i=0; i < constValues.size(); i++) - this->printConstantValueOnly(cast(constValues[i].get())); + printConstantValueOnly(cast(constValues[i].get())); } else - this->printSingleConstant(CV); + printSingleConstant(CV); } // Print a constant (which may be an aggregate) prefixed by all the @@ -696,7 +696,7 @@ SparcModuleAsmPrinter::printConstant(const Constant* CV, string valID) toAsm << "\t.align\t" << ConstantToAlignment(CV, Target) << "\n"; // Print .size and .type only if it is not a string. - ConstantArray *CPA = dyn_cast(CV); + const ConstantArray *CPA = dyn_cast(CV); if (CPA && isStringCompatible(CPA)) { // print it as a string and return toAsm << valID << ":\n";