diff options
author | Jay Foad <jay.foad@gmail.com> | 2009-05-21 09:52:38 +0000 |
---|---|---|
committer | Jay Foad <jay.foad@gmail.com> | 2009-05-21 09:52:38 +0000 |
commit | e3e51c0038bd6ba2add82e2246e97edec0ab2204 (patch) | |
tree | e24fe092d1dd38aa6e28777260f3aef0f9eacf46 /lib | |
parent | 82fe2935bf623f09533412126ad31e62dc3167ab (diff) | |
download | external_llvm-e3e51c0038bd6ba2add82e2246e97edec0ab2204.zip external_llvm-e3e51c0038bd6ba2add82e2246e97edec0ab2204.tar.gz external_llvm-e3e51c0038bd6ba2add82e2246e97edec0ab2204.tar.bz2 |
Use v.data() instead of &v[0] when SmallVector v might be empty.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72210 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/ConstantFolding.cpp | 10 | ||||
-rw-r--r-- | lib/Analysis/DebugInfo.cpp | 2 | ||||
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 18 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/Attributes.cpp | 6 | ||||
-rw-r--r-- | lib/VMCore/ValueSymbolTable.cpp | 12 |
6 files changed, 26 insertions, 24 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 00b5441..e5ab322 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -260,7 +260,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy, } } - return ConstantVector::get(&Result[0], Result.size()); + return ConstantVector::get(Result.data(), Result.size()); } } @@ -306,10 +306,10 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) { if (const CmpInst *CI = dyn_cast<CmpInst>(I)) return ConstantFoldCompareInstOperands(CI->getPredicate(), - &Ops[0], Ops.size(), TD); + Ops.data(), Ops.size(), TD); else return ConstantFoldInstOperands(I->getOpcode(), I->getType(), - &Ops[0], Ops.size(), TD); + Ops.data(), Ops.size(), TD); } /// ConstantFoldConstantExpression - Attempt to fold the constant expression @@ -325,10 +325,10 @@ Constant *llvm::ConstantFoldConstantExpression(ConstantExpr *CE, if (CE->isCompare()) return ConstantFoldCompareInstOperands(CE->getPredicate(), - &Ops[0], Ops.size(), TD); + Ops.data(), Ops.size(), TD); else return ConstantFoldInstOperands(CE->getOpcode(), CE->getType(), - &Ops[0], Ops.size(), TD); + Ops.data(), Ops.size(), TD); } /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 9f6cbc9..6bdb64c 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -442,7 +442,7 @@ DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) { Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr, Elts.size()), - &Elts[0], Elts.size()); + Elts.data(), Elts.size()); // If we already have this array, just return the uniqued version. DIDescriptor &Entry = SimpleConstantCache[Init]; if (!Entry.isNull()) return DIArray(Entry.getGV()); diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 2124397..8db4c71 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1577,7 +1577,7 @@ bool LLParser::ParseValID(ValID &ID) { ParseToken(lltok::rbrace, "expected end of metadata node")) return true; - ID.ConstantVal = MDNode::get(&Elts[0], Elts.size()); + ID.ConstantVal = MDNode::get(Elts.data(), Elts.size()); return false; } @@ -1617,7 +1617,7 @@ bool LLParser::ParseValID(ValID &ID) { ParseToken(lltok::rbrace, "expected end of struct constant")) return true; - ID.ConstantVal = ConstantStruct::get(&Elts[0], Elts.size(), false); + ID.ConstantVal = ConstantStruct::get(Elts.data(), Elts.size(), false); ID.Kind = ValID::t_Constant; return false; } @@ -1636,7 +1636,7 @@ bool LLParser::ParseValID(ValID &ID) { return true; if (isPackedStruct) { - ID.ConstantVal = ConstantStruct::get(&Elts[0], Elts.size(), true); + ID.ConstantVal = ConstantStruct::get(Elts.data(), Elts.size(), true); ID.Kind = ValID::t_Constant; return false; } @@ -1656,7 +1656,7 @@ bool LLParser::ParseValID(ValID &ID) { "vector element #" + utostr(i) + " is not of type '" + Elts[0]->getType()->getDescription()); - ID.ConstantVal = ConstantVector::get(&Elts[0], Elts.size()); + ID.ConstantVal = ConstantVector::get(Elts.data(), Elts.size()); ID.Kind = ValID::t_Constant; return false; } @@ -1690,7 +1690,7 @@ bool LLParser::ParseValID(ValID &ID) { " is not of type '" +Elts[0]->getType()->getDescription()); } - ID.ConstantVal = ConstantArray::get(ATy, &Elts[0], Elts.size()); + ID.ConstantVal = ConstantArray::get(ATy, Elts.data(), Elts.size()); ID.Kind = ValID::t_Constant; return false; } @@ -1761,8 +1761,8 @@ bool LLParser::ParseValID(ValID &ID) { if (!ExtractValueInst::getIndexedType(Val->getType(), Indices.begin(), Indices.end())) return Error(ID.Loc, "invalid indices for extractvalue"); - ID.ConstantVal = ConstantExpr::getExtractValue(Val, - &Indices[0], Indices.size()); + ID.ConstantVal = + ConstantExpr::getExtractValue(Val, Indices.data(), Indices.size()); ID.Kind = ValID::t_Constant; return false; } @@ -1782,8 +1782,8 @@ bool LLParser::ParseValID(ValID &ID) { if (!ExtractValueInst::getIndexedType(Val0->getType(), Indices.begin(), Indices.end())) return Error(ID.Loc, "invalid indices for insertvalue"); - ID.ConstantVal = ConstantExpr::getInsertValue(Val0, Val1, - &Indices[0], Indices.size()); + ID.ConstantVal = + ConstantExpr::getInsertValue(Val0, Val1, Indices.data(), Indices.size()); ID.Kind = ValID::t_Constant; return false; } diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 0c37f52..5c8cf75 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1041,7 +1041,7 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) Ops.push_back(LegalizeOp(Node->getOperand(i))); - Result = DAG.UpdateNodeOperands(Result.getValue(0), &Ops[0], Ops.size()); + Result = DAG.UpdateNodeOperands(Result.getValue(0), Ops.data(), Ops.size()); for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i) AddLegalizedOperand(Op.getValue(i), Result.getValue(i)); diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index 0f3efa7..5a8fad9 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -108,7 +108,7 @@ public: void DropRef() { if (--RefCount == 0) delete this; } void Profile(FoldingSetNodeID &ID) const { - Profile(ID, &Attrs[0], Attrs.size()); + Profile(ID, Attrs.data(), Attrs.size()); } static void Profile(FoldingSetNodeID &ID, const AttributeWithIndex *Attr, unsigned NumAttrs) { @@ -261,7 +261,7 @@ AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const { OldAttrList.begin()+i, OldAttrList.end()); } - return get(&NewAttrList[0], NewAttrList.size()); + return get(NewAttrList.data(), NewAttrList.size()); } AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const { @@ -296,7 +296,7 @@ AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const { NewAttrList.insert(NewAttrList.end(), OldAttrList.begin()+i, OldAttrList.end()); - return get(&NewAttrList[0], NewAttrList.size()); + return get(NewAttrList.data(), NewAttrList.size()); } void AttrListPtr::dump() const { diff --git a/lib/VMCore/ValueSymbolTable.cpp b/lib/VMCore/ValueSymbolTable.cpp index 3a0c54e..eee18a1 100644 --- a/lib/VMCore/ValueSymbolTable.cpp +++ b/lib/VMCore/ValueSymbolTable.cpp @@ -33,7 +33,7 @@ ValueSymbolTable::~ValueSymbolTable() { // lookup a value - Returns null on failure... // Value *ValueSymbolTable::lookup(const std::string &Name) const { - const_iterator VI = vmap.find(&Name[0], &Name[Name.size()]); + const_iterator VI = vmap.find(Name.data(), Name.data() + Name.size()); if (VI != vmap.end()) // We found the symbol return VI->getValue(); return 0; @@ -70,8 +70,9 @@ void ValueSymbolTable::reinsertValue(Value* V) { UniqueName.resize(BaseSize); UniqueName.append_uint_32(++LastUnique); // Try insert the vmap entry with this suffix. - ValueName &NewName = vmap.GetOrCreateValue(&UniqueName[0], - &UniqueName[UniqueName.size()]); + ValueName &NewName = + vmap.GetOrCreateValue(UniqueName.data(), + UniqueName.data() + UniqueName.size()); if (NewName.getValue() == 0) { // Newly inserted name. Success! NewName.setValue(V); @@ -111,8 +112,9 @@ ValueName *ValueSymbolTable::createValueName(const char *NameStart, UniqueName.append_uint_32(++LastUnique); // Try insert the vmap entry with this suffix. - ValueName &NewName = vmap.GetOrCreateValue(&UniqueName[0], - &UniqueName[UniqueName.size()]); + ValueName &NewName = + vmap.GetOrCreateValue(UniqueName.data(), + UniqueName.data() + UniqueName.size()); if (NewName.getValue() == 0) { // Newly inserted name. Success! NewName.setValue(V); |