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);
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 13655ba..35faa4a 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1651,7 +1651,7 @@
     Params.push_back(Param);
   }
 
-  ObjCMethod->setMethodParams(Context, &Params[0], Sel.getNumArgs());
+  ObjCMethod->setMethodParams(Context, Params.data(), Sel.getNumArgs());
   ObjCMethod->setObjCDeclQualifier(
     CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier()));
   const ObjCMethodDecl *PrevMethod = 0;
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index d72d56f..e819b1c 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -5144,7 +5144,7 @@
       CurBlock->Params.push_back(FTI.ArgInfo[i].Param.getAs<ParmVarDecl>());
     CurBlock->isVariadic = FTI.isVariadic;
   }
-  CurBlock->TheDecl->setParams(Context, &CurBlock->Params[0], 
+  CurBlock->TheDecl->setParams(Context, CurBlock->Params.data(),
                                CurBlock->Params.size());
   CurBlock->TheDecl->setIsVariadic(CurBlock->isVariadic);
   ProcessDeclAttributes(CurBlock->TheDecl, ParamInfo);
@@ -5215,7 +5215,7 @@
   if (!BSI->hasPrototype)
     BlockTy = Context.getFunctionNoProtoType(RetTy);
   else
-    BlockTy = Context.getFunctionType(RetTy, &ArgTypes[0], ArgTypes.size(),
+    BlockTy = Context.getFunctionType(RetTy, ArgTypes.data(), ArgTypes.size(),
                                       BSI->isVariadic, 0);
 
   // FIXME: Check that return/parameter types are complete/non-abstract
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 17113f6..f3ad2a1 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -1687,8 +1687,9 @@
   Desig.ClearExprs(*this);
 
   DesignatedInitExpr *DIE
-    = DesignatedInitExpr::Create(Context, &Designators[0], Designators.size(),
-                                 &InitExpressions[0], InitExpressions.size(),
+    = DesignatedInitExpr::Create(Context,
+                                 Designators.data(), Designators.size(),
+                                 InitExpressions.data(), InitExpressions.size(),
                                  Loc, GNUSyntax, Init.takeAs<Expr>());
   return Owned(DIE);
 }
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index ebaa99f..1a1362e 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -1000,7 +1000,7 @@
     TargetInfo::ConstraintInfo Info(Literal->getStrData(), 
                                     Literal->getByteLength(),
                                     Names[i]);
-    if (!Context.Target.validateInputConstraint(&OutputConstraintInfos[0],
+    if (!Context.Target.validateInputConstraint(OutputConstraintInfos.data(),
                                                 NumOutputs, Info)) {
       return StmtError(Diag(Literal->getLocStart(),
                             diag::err_asm_invalid_input_constraint)
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 47388ac..c533789 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -879,7 +879,8 @@
   translateTemplateArguments(TemplateArgsIn, TemplateArgLocs, TemplateArgs);
 
   QualType Result = CheckTemplateIdType(Template, TemplateLoc, LAngleLoc,
-                                        &TemplateArgs[0], TemplateArgs.size(),
+                                        TemplateArgs.data(),
+                                        TemplateArgs.size(),
                                         RAngleLoc);
   TemplateArgsIn.release();
 
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 08019aa..a5b0911 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -686,7 +686,7 @@
   }
 
   if (!Invalid &&
-      AttachBaseSpecifiers(Instantiation, &InstantiatedBases[0],
+      AttachBaseSpecifiers(Instantiation, InstantiatedBases.data(),
                            InstantiatedBases.size()))
     Invalid = true;
 
@@ -770,7 +770,7 @@
 
   // Finish checking fields.
   ActOnFields(0, Instantiation->getLocation(), DeclPtrTy::make(Instantiation),
-              &Fields[0], Fields.size(), SourceLocation(), SourceLocation(),
+              Fields.data(), Fields.size(), SourceLocation(), SourceLocation(),
               0);
 
   // Add any implicitly-declared members that we might need.
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 385112b..b9a9ae8 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -301,7 +301,7 @@
   // Attach the parameters
   for (unsigned P = 0; P < Params.size(); ++P)
     Params[P]->setOwningFunction(Method);
-  Method->setParams(SemaRef.Context, &Params[0], Params.size());
+  Method->setParams(SemaRef.Context, Params.data(), Params.size());
 
   if (InitMethodInstantiation(Method, D))
     Method->setInvalidDecl();
@@ -348,7 +348,7 @@
   // Attach the parameters
   for (unsigned P = 0; P < Params.size(); ++P)
     Params[P]->setOwningFunction(Constructor);
-  Constructor->setParams(SemaRef.Context, &Params[0], Params.size());
+  Constructor->setParams(SemaRef.Context, Params.data(), Params.size());
 
   if (InitMethodInstantiation(Constructor, D))
     Constructor->setInvalidDecl();
@@ -538,7 +538,7 @@
   if (ResultType.isNull())
     return QualType();
 
-  return SemaRef.BuildFunctionType(ResultType, &ParamTys[0], ParamTys.size(),
+  return SemaRef.BuildFunctionType(ResultType, ParamTys.data(), ParamTys.size(),
                                    Proto->isVariadic(), Proto->getTypeQuals(),
                                    D->getLocation(), D->getDeclName());
 }
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 4889a56..e10a912 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -795,7 +795,7 @@
           
           ArgTys.push_back(ArgTy);
         }
-        T = Context.getFunctionType(T, &ArgTys[0], ArgTys.size(),
+        T = Context.getFunctionType(T, ArgTys.data(), ArgTys.size(),
                                     FTI.isVariadic, FTI.TypeQuals);
       }
       break;