diff --git a/llvm/include/llvm/Constants.h b/llvm/include/llvm/Constants.h index ac0b0fb3148c..b727de31ae6d 100644 --- a/llvm/include/llvm/Constants.h +++ b/llvm/include/llvm/Constants.h @@ -375,7 +375,7 @@ public: /// isString) and it ends in a null byte \0 and does not contains any other /// @endverbatim /// null bytes except its terminator. - bool isCString(LLVMContext &Context) const; + bool isCString() const; /// getAsString - If this array is isString(), then this method converts the /// array to an std::string and returns it. Otherwise, it asserts out. diff --git a/llvm/lib/CodeGen/MachOWriter.cpp b/llvm/lib/CodeGen/MachOWriter.cpp index 35f71075cc7b..7542d9ed102c 100644 --- a/llvm/lib/CodeGen/MachOWriter.cpp +++ b/llvm/lib/CodeGen/MachOWriter.cpp @@ -123,7 +123,7 @@ bool MachOWriter::doFinalization(Module &M) { // getConstSection - Get constant section for Constant 'C' MachOSection *MachOWriter::getConstSection(Constant *C) { const ConstantArray *CVA = dyn_cast(C); - if (CVA && CVA->isCString(*Context)) + if (CVA && CVA->isCString()) return getSection("__TEXT", "__cstring", MachOSection::S_CSTRING_LITERALS); diff --git a/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp index 89e9426f241d..17c7640e36be 100644 --- a/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp @@ -541,7 +541,7 @@ printModuleLevelGV(const GlobalVariable* GVar) { // Fall Through case GlobalValue::PrivateLinkage: case GlobalValue::InternalLinkage: - if (CVA && CVA->isCString(GVar->getParent()->getContext())) + if (CVA && CVA->isCString()) printSizeAndType = false; break; case GlobalValue::GhostLinkage: diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp index 3727918eac07..f3fa17938b36 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp @@ -227,7 +227,7 @@ bool MipsTargetLowering::IsGlobalInSmallSection(GlobalValue *GV) if (GVA->hasInitializer() && GV->hasLocalLinkage()) { Constant *C = GVA->getInitializer(); const ConstantArray *CVA = dyn_cast(C); - if (CVA && CVA->isCString(GV->getParent()->getContext())) + if (CVA && CVA->isCString()) return false; } diff --git a/llvm/lib/Target/TargetAsmInfo.cpp b/llvm/lib/Target/TargetAsmInfo.cpp index 3df09bc60a5d..08ae2cf13e47 100644 --- a/llvm/lib/Target/TargetAsmInfo.cpp +++ b/llvm/lib/Target/TargetAsmInfo.cpp @@ -171,11 +171,11 @@ static bool isSuitableForBSS(const GlobalVariable *GV) { return (C->isNullValue() && !GV->isConstant() && !NoZerosInBSS); } -static bool isConstantString(LLVMContext &Context, const Constant *C) { +static bool isConstantString(const Constant *C) { // First check: is we have constant array of i8 terminated with zero const ConstantArray *CVA = dyn_cast(C); // Check, if initializer is a null-terminated string - if (CVA && CVA->isCString(Context)) + if (CVA && CVA->isCString()) return true; // Another possibility: [1 x i8] zeroinitializer @@ -230,7 +230,7 @@ TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const { } } else { // Check, if initializer is a null-terminated string - if (isConstantString(GV->getParent()->getContext(), C)) + if (isConstantString(C)) return SectionKind::RODataMergeStr; else return SectionKind::RODataMergeConst; diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index a1b4c93268d5..184ae9d21ed5 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -1416,19 +1416,19 @@ bool ConstantArray::isString() const { /// 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(LLVMContext &Context) const { +bool ConstantArray::isCString() const { // Check the element type for i8... if (getType()->getElementType() != Type::Int8Ty) return false; - Constant *Zero = Context.getNullValue(getOperand(0)->getType()); + // Last element must be a null. - if (getOperand(getNumOperands()-1) != Zero) + 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(getOperand(i))) return false; - if (getOperand(i) == Zero) + if (getOperand(i)->isNullValue()) return false; } return true; diff --git a/llvm/tools/lto/LTOModule.cpp b/llvm/tools/lto/LTOModule.cpp index 591547fb222b..c4980d6bf79b 100644 --- a/llvm/tools/lto/LTOModule.cpp +++ b/llvm/tools/lto/LTOModule.cpp @@ -189,7 +189,7 @@ bool LTOModule::objcClassNameFromExpression(Constant* c, std::string& name) if (GlobalVariable* gvn = dyn_cast(op)) { Constant* cn = gvn->getInitializer(); if (ConstantArray* ca = dyn_cast(cn)) { - if ( ca->isCString(getGlobalContext()) ) { + if ( ca->isCString() ) { name = ".objc_class_name_" + ca->getAsString(); return true; }