As Chris pointed out, this doesn't actually need an LLVMContext to operate.
authorOwen Anderson <resistor@mac.com>
Mon, 13 Jul 2009 21:27:19 +0000 (21:27 +0000)
committerOwen Anderson <resistor@mac.com>
Mon, 13 Jul 2009 21:27:19 +0000 (21:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75508 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h
lib/CodeGen/MachOWriter.cpp
lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
lib/Target/Mips/MipsISelLowering.cpp
lib/Target/TargetAsmInfo.cpp
lib/VMCore/Constants.cpp
tools/lto/LTOModule.cpp

index ac0b0fb3148c50f1b5346e0d4008af1e4bdd9dad..b727de31ae6db70e464f1e29cfe492d24d875627 100644 (file)
@@ -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.
index 35f71075cc7b6f172da809f39493b9b7571450e2..7542d9ed102cbec6ba55dfdcf52dd3317d2ce323 100644 (file)
@@ -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<ConstantArray>(C);
-  if (CVA && CVA->isCString(*Context))
+  if (CVA && CVA->isCString())
     return getSection("__TEXT", "__cstring", 
                       MachOSection::S_CSTRING_LITERALS);
 
index 89e9426f241d15c425a9cc15552c12a24c255d72..17c7640e36be52f68a34b680162c347335d837b3 100644 (file)
@@ -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:
index 3727918eac07806252f6150d5d1b6a3c4af4d11b..f3fa17938b36bbe1bce57438826171f0406f8b5f 100644 (file)
@@ -227,7 +227,7 @@ bool MipsTargetLowering::IsGlobalInSmallSection(GlobalValue *GV)
   if (GVA->hasInitializer() && GV->hasLocalLinkage()) {
     Constant *C = GVA->getInitializer();
     const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
-    if (CVA && CVA->isCString(GV->getParent()->getContext())) 
+    if (CVA && CVA->isCString()) 
       return false;
   }
 
index 3df09bc60a5db984787770bdd08938ff682c80c3..08ae2cf13e472beb88505d97d3bf83e49cfb02e0 100644 (file)
@@ -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<ConstantArray>(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;
index a1b4c93268d58bd26130038b810f7f02497283ac..184ae9d21ed55612684275cf017e1ca8ea4bdec4 100644 (file)
@@ -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<ConstantInt>(getOperand(i)))
       return false;
-    if (getOperand(i) == Zero)
+    if (getOperand(i)->isNullValue())
       return false;
   }
   return true;
index 591547fb222b6a5c1168636657d8b04f693544d5..c4980d6bf79bee615978cc390921ae007875ba9f 100644 (file)
@@ -189,7 +189,7 @@ bool LTOModule::objcClassNameFromExpression(Constant* c, std::string& name)
         if (GlobalVariable* gvn = dyn_cast<GlobalVariable>(op)) {
             Constant* cn = gvn->getInitializer(); 
             if (ConstantArray* ca = dyn_cast<ConstantArray>(cn)) {
-                if ( ca->isCString(getGlobalContext()) ) {
+                if ( ca->isCString() ) {
                     name = ".objc_class_name_" + ca->getAsString();
                     return true;
                 }