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/Parse/AstGuard.h b/lib/Parse/AstGuard.h
index 602fea5..1ff6a4e 100644
--- a/lib/Parse/AstGuard.h
+++ b/lib/Parse/AstGuard.h
@@ -56,7 +56,7 @@
 #if !defined(DISABLE_SMART_POINTERS)
       Owns = false;
 #endif
-      return &(*this)[0];
+      return this->data();
     }
 
 #if !defined(DISABLE_SMART_POINTERS)
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index db24d21..4c2a77e 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -377,7 +377,7 @@
              "Unexpected number of commas!");
       Actions.AddCXXDirectInitializerToDecl(ThisDecl, LParenLoc,
                                             move_arg(Exprs),
-                                            &CommaLocs[0], RParenLoc);
+                                            CommaLocs.data(), RParenLoc);
     }
   } else {
     Actions.ActOnUninitializedDecl(ThisDecl);
@@ -438,7 +438,7 @@
     ParseDeclarator(D);
   }
   
-  return Actions.FinalizeDeclaratorGroup(CurScope, &DeclsInGroup[0],
+  return Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(),
                                          DeclsInGroup.size());
 }
 
@@ -1387,7 +1387,7 @@
     AttrList = ParseAttributes();
 
   Actions.ActOnFields(CurScope,
-                      RecordLoc,TagDecl,&FieldDecls[0],FieldDecls.size(),
+                      RecordLoc, TagDecl, FieldDecls.data(), FieldDecls.size(),
                       LBraceLoc, RBraceLoc,
                       AttrList);
   StructScope.Exit();
@@ -1537,7 +1537,7 @@
   SourceLocation RBraceLoc = MatchRHSPunctuation(tok::r_brace, LBraceLoc);
 
   Actions.ActOnEnumBody(StartLoc, LBraceLoc, RBraceLoc, EnumDecl,
-                        &EnumConstantDecls[0], EnumConstantDecls.size());
+                        EnumConstantDecls.data(), EnumConstantDecls.size());
   
   Action::AttrTy *AttrList = 0;
   // If attributes exist after the identifier list, parse them.
@@ -2462,7 +2462,7 @@
   // Remember that we parsed a function type, and remember the attributes.
   D.AddTypeInfo(DeclaratorChunk::getFunction(/*proto*/true, IsVariadic,
                                              EllipsisLoc,
-                                             &ParamInfo[0], ParamInfo.size(),
+                                             ParamInfo.data(), ParamInfo.size(),
                                              DS.getTypeQualifiers(),
                                              hasExceptionSpec,
                                              hasAnyExceptionSpec,
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index 963c5ad..b900e25 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -652,7 +652,7 @@
   }
 
   // Attach the base specifiers
-  Actions.ActOnBaseSpecifiers(ClassDecl, &BaseInfo[0], BaseInfo.size());
+  Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo.data(), BaseInfo.size());
 }
 
 /// ParseBaseSpecifier - Parse a C++ base-specifier. A base-specifier is
@@ -970,7 +970,7 @@
 
   if (Tok.is(tok::semi)) {
     ConsumeToken();
-    Actions.FinalizeDeclaratorGroup(CurScope, &DeclsInGroup[0],
+    Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(),
                                     DeclsInGroup.size());
     return;
   }
@@ -1137,7 +1137,7 @@
   } while (true);
 
   Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc, 
-                               &MemInitializers[0], MemInitializers.size());
+                               MemInitializers.data(), MemInitializers.size());
 }
 
 /// ParseMemInitializer - Parse a C++ member initializer, which is
@@ -1183,7 +1183,8 @@
 
   return Actions.ActOnMemInitializer(ConstructorDecl, CurScope, II, IdLoc,
                                      LParenLoc, ArgExprs.take(),
-                                     ArgExprs.size(), &CommaLocs[0], RParenLoc);
+                                     ArgExprs.size(), CommaLocs.data(),
+                                     RParenLoc);
 }
 
 /// ParseExceptionSpecification - Parse a C++ exception-specification
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 55fc0cd..527fd46 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -876,7 +876,7 @@
         assert((ArgExprs.size() == 0 || ArgExprs.size()-1 == CommaLocs.size())&&
                "Unexpected number of commas!");
         LHS = Actions.ActOnCallExpr(CurScope, move(LHS), Loc,
-                                    move_arg(ArgExprs), &CommaLocs[0],
+                                    move_arg(ArgExprs), CommaLocs.data(),
                                     Tok.getLocation());
       }
       
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index 4becfc8..d2d9a87 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -467,7 +467,7 @@
          "Unexpected number of commas!");
   return Actions.ActOnCXXTypeConstructExpr(DS.getSourceRange(), TypeRep,
                                            LParenLoc, move_arg(Exprs),
-                                           &CommaLocs[0], RParenLoc);
+                                           CommaLocs.data(), RParenLoc);
 }
 
 /// ParseCXXCondition - if/switch/while/for condition expression.
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index e1d0bb6..571c610 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -158,10 +158,13 @@
     if (attrList) // categories don't support attributes.
       Diag(Tok, diag::err_objc_no_attributes_on_category);
     
-    DeclPtrTy CategoryType = Actions.ActOnStartCategoryInterface(atLoc, 
-                                     nameId, nameLoc, categoryId, categoryLoc,
-                                     &ProtocolRefs[0], ProtocolRefs.size(),
-                                     EndProtoLoc);
+    DeclPtrTy CategoryType =
+      Actions.ActOnStartCategoryInterface(atLoc, 
+                                          nameId, nameLoc,
+                                          categoryId, categoryLoc,
+                                          ProtocolRefs.data(),
+                                          ProtocolRefs.size(),
+                                          EndProtoLoc);
     
     ParseObjCInterfaceDeclList(CategoryType, tok::objc_not_keyword);
     return CategoryType;
@@ -189,7 +192,7 @@
   DeclPtrTy ClsType = 
     Actions.ActOnStartClassInterface(atLoc, nameId, nameLoc, 
                                      superClassId, superClassLoc,
-                                     &ProtocolRefs[0], ProtocolRefs.size(),
+                                     ProtocolRefs.data(), ProtocolRefs.size(),
                                      EndProtoLoc, attrList);
             
   if (Tok.is(tok::l_brace))
@@ -358,9 +361,9 @@
   // Insert collected methods declarations into the @interface object.
   // This passes in an invalid SourceLocation for AtEndLoc when EOF is hit.
   Actions.ActOnAtEnd(AtEndLoc, interfaceDecl,
-                     &allMethods[0], allMethods.size(), 
-                     &allProperties[0], allProperties.size(),
-                     &allTUVariables[0], allTUVariables.size());
+                     allMethods.data(), allMethods.size(), 
+                     allProperties.data(), allProperties.size(),
+                     allTUVariables.data(), allTUVariables.size());
 }
 
 ///   Parse property attribute declarations.
@@ -905,7 +908,7 @@
   // Call ActOnFields() even if we don't have any decls. This is useful
   // for code rewriting tools that need to be aware of the empty list.
   Actions.ActOnFields(CurScope, atLoc, interfaceDecl,
-                      &AllIvarDecls[0], AllIvarDecls.size(),
+                      AllIvarDecls.data(), AllIvarDecls.size(),
                       LBraceLoc, RBraceLoc, 0);
   return;
 }
@@ -986,7 +989,8 @@
   
   DeclPtrTy ProtoType =
     Actions.ActOnStartProtocolInterface(AtLoc, protocolName, nameLoc,
-                                        &ProtocolRefs[0], ProtocolRefs.size(),
+                                        ProtocolRefs.data(),
+                                        ProtocolRefs.size(),
                                         EndProtoLoc, attrList);
   ParseObjCInterfaceDeclList(ProtoType, tok::objc_protocol);
   return ProtoType;
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 1bcfed7..8422352 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -1210,7 +1210,7 @@
   }
 
   return Actions.ActOnAsmStmt(AsmLoc, isSimple, isVolatile,
-                              NumOutputs, NumInputs, &Names[0],
+                              NumOutputs, NumInputs, Names.data(),
                               move_arg(Constraints), move_arg(Exprs),
                               move(AsmString), move_arg(Clobbers),
                               RParenLoc);
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index 490f276..f23f8c0 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -106,7 +106,7 @@
     ParamLists.push_back(
       Actions.ActOnTemplateParameterList(ParamLists.size(), ExportLoc, 
                                          TemplateLoc, LAngleLoc, 
-                                         &TemplateParams[0],
+                                         TemplateParams.data(),
                                          TemplateParams.size(), RAngleLoc));
   } while (Tok.is(tok::kw_export) || Tok.is(tok::kw_template));
 
@@ -633,8 +633,8 @@
                                                   TemplateArgLocations,
                                                   RAngleLoc);
 
-  ASTTemplateArgsPtr TemplateArgsPtr(Actions, &TemplateArgs[0],
-                                     &TemplateArgIsType[0],
+  ASTTemplateArgsPtr TemplateArgsPtr(Actions, TemplateArgs.data(),
+                                     TemplateArgIsType.data(),
                                      TemplateArgs.size());
 
   if (Invalid) // FIXME: How to recover from a broken template-id?