Use v.data() instead of &v[0] when SmallVector v might be empty.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72210 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index ceb5822..22bdc79 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -456,7 +456,7 @@
for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i)
Params.push_back(ParmVarDecl::Create(Context, New, SourceLocation(), 0,
FT->getArgType(i), VarDecl::None, 0));
- New->setParams(Context, &Params[0], Params.size());
+ New->setParams(Context, Params.data(), Params.size());
}
AddKnownFunctionAttributes(New);
@@ -732,7 +732,7 @@
llvm::SmallVector<QualType, 16> ParamTypes(OldProto->arg_type_begin(),
OldProto->arg_type_end());
NewQType = Context.getFunctionType(NewFuncType->getResultType(),
- &ParamTypes[0], ParamTypes.size(),
+ ParamTypes.data(), ParamTypes.size(),
OldProto->isVariadic(),
OldProto->getTypeQuals());
New->setType(NewQType);
@@ -752,7 +752,7 @@
Params.push_back(Param);
}
- New->setParams(Context, &Params[0], Params.size());
+ New->setParams(Context, Params.data(), Params.size());
}
return MergeCompatibleFunctionDecls(New, Old);
@@ -2243,7 +2243,7 @@
"Should not need args for typedef of non-prototype fn");
}
// Finally, we know we have the right number of parameters, install them.
- NewFD->setParams(Context, &Params[0], Params.size());
+ NewFD->setParams(Context, Params.data(), Params.size());
@@ -2804,7 +2804,7 @@
}
}
return DeclGroupPtrTy::make(DeclGroupRef::Create(Context,
- &Decls[0], Decls.size()));
+ Decls.data(), Decls.size()));
}
@@ -4084,7 +4084,8 @@
if (Record) {
Record->completeDefinition(Context);
} else {
- ObjCIvarDecl **ClsFields = reinterpret_cast<ObjCIvarDecl**>(&RecFields[0]);
+ ObjCIvarDecl **ClsFields =
+ reinterpret_cast<ObjCIvarDecl**>(RecFields.data());
if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(EnclosingDecl)) {
ID->setIVarList(ClsFields, RecFields.size(), Context);
ID->setLocEnd(RBrac);