]> granicus.if.org Git - clang/commitdiff
Use v.data() instead of &v[0] when SmallVector v might be empty.
authorJay Foad <jay.foad@gmail.com>
Thu, 21 May 2009 09:52:38 +0000 (09:52 +0000)
committerJay Foad <jay.foad@gmail.com>
Thu, 21 May 2009 09:52:38 +0000 (09:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72210 91177308-0d34-0410-b5e6-96231b3b80d8

30 files changed:
include/clang/Basic/IdentifierTable.h
lib/AST/ASTContext.cpp
lib/AST/Builtins.cpp
lib/CodeGen/CGBuiltin.cpp
lib/CodeGen/CGCall.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGStmt.cpp
lib/Frontend/PCHReader.cpp
lib/Frontend/PCHReaderDecl.cpp
lib/Frontend/PCHReaderStmt.cpp
lib/Frontend/PrintPreprocessedOutput.cpp
lib/Lex/PPDirectives.cpp
lib/Lex/PPMacroExpansion.cpp
lib/Parse/AstGuard.h
lib/Parse/ParseDecl.cpp
lib/Parse/ParseDeclCXX.cpp
lib/Parse/ParseExpr.cpp
lib/Parse/ParseExprCXX.cpp
lib/Parse/ParseObjc.cpp
lib/Parse/ParseStmt.cpp
lib/Parse/ParseTemplate.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclObjC.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaStmt.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateInstantiate.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
lib/Sema/SemaType.cpp

index 69b7bafbae751eb74cd01cc3d2495bec4f8ae875..57cd311631446489480fd481529d9f3337240a03 100644 (file)
@@ -339,7 +339,7 @@ public:
   }
   IdentifierInfo &get(const std::string &Name) {
     // Don't use c_str() here: no need to be null terminated.
-    const char *NameBytes = &Name[0];
+    const char *NameBytes = Name.data();
     return get(NameBytes, NameBytes+Name.size());
   }
 
@@ -470,8 +470,9 @@ public:
     SelectorName = "set";
     SelectorName.append(Name->getName(), Name->getName()+Name->getLength());
     SelectorName[3] = toupper(SelectorName[3]);
-    IdentifierInfo *SetterName = 
-      &Idents.get(&SelectorName[0], &SelectorName[SelectorName.size()]);
+    IdentifierInfo *SetterName =
+      &Idents.get(SelectorName.data(),
+                  SelectorName.data() + SelectorName.size());
     return SelTable.getUnarySelector(SetterName);
   }
 };
index 329d6c478d56f2140d16e6fa87b8f38dd7de35a5..ccbea263aa5182a5b586c8c9b1f1f1aa135be769 100644 (file)
@@ -1361,7 +1361,7 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray,
       CanonicalArgs.push_back(getCanonicalType(ArgArray[i]));
     
     Canonical = getFunctionType(getCanonicalType(ResultTy),
-                                &CanonicalArgs[0], NumArgs,
+                                CanonicalArgs.data(), NumArgs,
                                 isVariadic, TypeQuals);
     
     // Get the new insert position for the node we care about.
index ca75c5d51a81dbb5e2abf0a319adf7f1de3f4dca..8368febe5a0551b9dfdfff2485af7b882fdfd5d0 100644 (file)
@@ -285,6 +285,6 @@ QualType Builtin::Context::GetBuiltinType(unsigned id, ASTContext &Context,
   // handle untyped/variadic arguments "T c99Style();" or "T cppStyle(...);".
   if (ArgTypes.size() == 0 && TypeStr[0] == '.')
     return Context.getFunctionNoProtoType(ResType);
-  return Context.getFunctionType(ResType, &ArgTypes[0], ArgTypes.size(),
+  return Context.getFunctionType(ResType, ArgTypes.data(), ArgTypes.size(),
                                  TypeStr[0] == '.', 0);
 }
index b316d45004f13dbad9fff33d6e375d3e6af81e44..6692b6cd9f998e2f698cb4e1b18fec077114d39d 100644 (file)
@@ -547,7 +547,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
       Args.push_back(ArgValue);
     }
     
-    Value *V = Builder.CreateCall(F, &Args[0], &Args[0] + Args.size());
+    Value *V = Builder.CreateCall(F, Args.data(), Args.data() + Args.size());
     QualType BuiltinRetType = E->getType();
     
     const llvm::Type *RetTy = llvm::Type::VoidTy;
index d444baec8e3e64834e2f52a6f47c806f933fe5c3..718a51512a2fc6c6fa898e43a8b0e4f9cef0373b 100644 (file)
@@ -2091,11 +2091,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
   
   llvm::CallSite CS;
   if (!InvokeDest || (Attrs.getFnAttributes() & llvm::Attribute::NoUnwind)) {
-    CS = Builder.CreateCall(Callee, &Args[0], &Args[0]+Args.size());
+    CS = Builder.CreateCall(Callee, Args.data(), Args.data()+Args.size());
   } else {
     llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
     CS = Builder.CreateInvoke(Callee, Cont, InvokeDest, 
-                              &Args[0], &Args[0]+Args.size());
+                              Args.data(), Args.data()+Args.size());
     EmitBlock(Cont);
   }
 
index 382b18664806f3d9de9a3650b8ad365bee6f668d..b005d0543e5020fa0e0a3a82f613af008eae3e5d 100644 (file)
@@ -609,7 +609,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
   }
   
   llvm::DIArray Elements =
-    DebugFactory.GetOrCreateArray(&EltTys[0], EltTys.size());
+    DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size());
 
   // Bit size, align and offset of the type.
   uint64_t Size = M->getContext().getTypeSize(Ty);
@@ -645,7 +645,7 @@ llvm::DIType CGDebugInfo::CreateType(const EnumType *Ty,
   
   // Return a CompositeType for the enum itself.
   llvm::DIArray EltArray =
-    DebugFactory.GetOrCreateArray(&Enumerators[0], Enumerators.size());
+    DebugFactory.GetOrCreateArray(Enumerators.data(), Enumerators.size());
 
   std::string EnumName = Decl->getNameAsString();
   SourceLocation DefLoc = Decl->getLocation();
index 7f73c8886c2ecd6cfb2e6094d5fb9c89386ed97a..da586b1d74c917dccc67b3d9112e2fef91bf2dfd 100644 (file)
@@ -801,7 +801,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
   for (unsigned i = 0, e = S.getNumInputs(); i != e; i++) {
     TargetInfo::ConstraintInfo Info(S.getInputConstraint(i),
                                     S.getInputName(i));
-    bool result = Target.validateInputConstraint(&OutputConstraintInfos[0],
+    bool result = Target.validateInputConstraint(OutputConstraintInfos.data(),
                                                  S.getNumOutputs(),
                                                  Info); result=result;
     assert(result && "Failed to parse input constraint");
index 25415bb368eaa7b7876a2e645f87b757dc901fd3..4da4538f3e522ed800f6b80d3a07a63cdb78be9f 100644 (file)
@@ -1670,7 +1670,7 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
       ParamTypes.push_back(GetType(Record[Idx++]));
     bool isVariadic = Record[Idx++];
     unsigned Quals = Record[Idx++];
-    return Context->getFunctionType(ResultType, &ParamTypes[0], NumParams,
+    return Context->getFunctionType(ResultType, ParamTypes.data(), NumParams,
                                     isVariadic, Quals);
   }
 
@@ -2151,7 +2151,7 @@ llvm::APFloat PCHReader::ReadAPFloat(const RecordData &Record, unsigned &Idx) {
 // \brief Read a string
 std::string PCHReader::ReadString(const RecordData &Record, unsigned &Idx) {
   unsigned Len = Record[Idx++];
-  std::string Result(&Record[Idx], &Record[Idx] + Len);
+  std::string Result(Record.data() + Idx, Record.data() + Idx + Len);
   Idx += Len;
   return Result;
 }
index 870392b07b28e5d59e82212298ad43bcda389db9..64c8e6f7c6d18661024dc404f00fb22faffca20e 100644 (file)
@@ -161,7 +161,7 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   Params.reserve(NumParams);
   for (unsigned I = 0; I != NumParams; ++I)
     Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
-  FD->setParams(*Reader.getContext(), &Params[0], NumParams);
+  FD->setParams(*Reader.getContext(), Params.data(), NumParams);
 }
 
 void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
@@ -185,7 +185,7 @@ void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
   Params.reserve(NumParams);
   for (unsigned I = 0; I != NumParams; ++I)
     Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
-  MD->setMethodParams(*Reader.getContext(), &Params[0], NumParams);
+  MD->setMethodParams(*Reader.getContext(), Params.data(), NumParams);
 }
 
 void PCHDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) {
@@ -203,13 +203,13 @@ void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
   Protocols.reserve(NumProtocols);
   for (unsigned I = 0; I != NumProtocols; ++I)
     Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
-  ID->setProtocolList(&Protocols[0], NumProtocols, *Reader.getContext());
+  ID->setProtocolList(Protocols.data(), NumProtocols, *Reader.getContext());
   unsigned NumIvars = Record[Idx++];
   llvm::SmallVector<ObjCIvarDecl *, 16> IVars;
   IVars.reserve(NumIvars);
   for (unsigned I = 0; I != NumIvars; ++I)
     IVars.push_back(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
-  ID->setIVarList(&IVars[0], NumIvars, *Reader.getContext());
+  ID->setIVarList(IVars.data(), NumIvars, *Reader.getContext());
   ID->setCategoryList(
                cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++])));
   ID->setForwardDecl(Record[Idx++]);
@@ -233,7 +233,7 @@ void PCHDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) {
   ProtoRefs.reserve(NumProtoRefs);
   for (unsigned I = 0; I != NumProtoRefs; ++I)
     ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
-  PD->setProtocolList(&ProtoRefs[0], NumProtoRefs, *Reader.getContext());
+  PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, *Reader.getContext());
 }
 
 void PCHDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) {
index d4ff6adda02b3173f2073b5154e55cbbf0ce11f8..03c5d25a7bf2a83ff0e47cbb0117df70aeca628f 100644 (file)
@@ -129,7 +129,7 @@ unsigned PCHStmtReader::VisitCompoundStmt(CompoundStmt *S) {
   VisitStmt(S);
   unsigned NumStmts = Record[Idx++];
   S->setStmts(*Reader.getContext(), 
-              &StmtStack[StmtStack.size() - NumStmts], NumStmts);
+              StmtStack.data() + StmtStack.size() - NumStmts, NumStmts);
   S->setLBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
   S->setRBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
   return NumStmts;
@@ -303,13 +303,13 @@ unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) {
     Exprs.push_back(StmtStack[StackIdx++]);
   }
   S->setOutputsAndInputs(NumOutputs, NumInputs,
-                         &Names[0], &Constraints[0], &Exprs[0]);
+                         Names.data(), Constraints.data(), Exprs.data());
 
   // Constraints
   llvm::SmallVector<StringLiteral*, 16> Clobbers;
   for (unsigned I = 0; I != NumClobbers; ++I)
     Clobbers.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
-  S->setClobbers(&Clobbers[0], NumClobbers);
+  S->setClobbers(Clobbers.data(), NumClobbers);
 
   assert(StackIdx == StmtStack.size() && "Error deserializing AsmStmt");
   return NumOutputs*2 + NumInputs*2 + NumClobbers + 1;
index d88e57d85dfd22818a32d7af63103fba5d56b401..e79453c28c8ca30b564b44d8c0e5675825458b5e 100644 (file)
@@ -68,7 +68,7 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
     // Make sure we have enough space in the spelling buffer.
     if (I->getLength() < SpellingBuffer.size())
       SpellingBuffer.resize(I->getLength());
-    const char *Buffer = &SpellingBuffer[0];
+    const char *Buffer = SpellingBuffer.data();
     unsigned SpellingLen = PP.getSpelling(*I, Buffer);
     OS.write(Buffer, SpellingLen);
   }
index ca8693bf61f49c129d97c5b83817c450f98c35d0..331424bdc8e730a562bfc1848dd63a4551a106b2 100644 (file)
@@ -1049,8 +1049,8 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
     FilenameBuffer.push_back('<');
     if (ConcatenateIncludeName(FilenameBuffer, *this))
       return;   // Found <eom> but no ">"?  Diagnostic already emitted.
-    FilenameStart = &FilenameBuffer[0];
-    FilenameEnd = &FilenameBuffer[FilenameBuffer.size()];
+    FilenameStart = FilenameBuffer.data();
+    FilenameEnd = FilenameStart + FilenameBuffer.size();
     break;
   default:
     Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
index 18dcfb25e7d32926b39e1e9ec4419346feac2e10..55222c944a2b8b0dd6aa8885bf6d889538726b51 100644 (file)
@@ -439,7 +439,8 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
     return 0;
   }
   
-  return MacroArgs::create(MI, &ArgTokens[0], ArgTokens.size(),isVarargsElided);
+  return MacroArgs::create(MI, ArgTokens.data(), ArgTokens.size(),
+                           isVarargsElided);
 }
 
 /// ComputeDATE_TIME - Compute the current time, enter it into the specified
index 602fea51dc1039ef8eca33e0379fc3956f4cd318..1ff6a4e35aee312256234cb798bdfc00eeb1a721 100644 (file)
@@ -56,7 +56,7 @@ namespace clang
 #if !defined(DISABLE_SMART_POINTERS)
       Owns = false;
 #endif
-      return &(*this)[0];
+      return this->data();
     }
 
 #if !defined(DISABLE_SMART_POINTERS)
index db24d21c322782f328beb3a3f4b5e288ca494a71..4c2a77e7d056eff2fe958610241a5aa6b77d4db8 100644 (file)
@@ -377,7 +377,7 @@ Parser::DeclPtrTy Parser::ParseDeclarationAfterDeclarator(Declarator &D) {
              "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 @@ ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) {
     ParseDeclarator(D);
   }
   
-  return Actions.FinalizeDeclaratorGroup(CurScope, &DeclsInGroup[0],
+  return Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(),
                                          DeclsInGroup.size());
 }
 
@@ -1387,7 +1387,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
     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 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, DeclPtrTy EnumDecl) {
   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 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
   // 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,
index 963c5adf0054c624e334be9ca27b126f8cffb30c..b900e25c69ac755e86ad323108218cf02bff651a 100644 (file)
@@ -652,7 +652,7 @@ void Parser::ParseBaseClause(DeclPtrTy ClassDecl) {
   }
 
   // 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 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS) {
 
   if (Tok.is(tok::semi)) {
     ConsumeToken();
-    Actions.FinalizeDeclaratorGroup(CurScope, &DeclsInGroup[0],
+    Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(),
                                     DeclsInGroup.size());
     return;
   }
@@ -1137,7 +1137,7 @@ void Parser::ParseConstructorInitializer(DeclPtrTy ConstructorDecl) {
   } 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 @@ Parser::MemInitResult Parser::ParseMemInitializer(DeclPtrTy ConstructorDecl) {
 
   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
index 55fc0cdd6c665dab551af33b09942faa9f819502..527fd4695cc5b8376c85930c93bcac776be1f761 100644 (file)
@@ -876,7 +876,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
         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());
       }
       
index 4becfc83c9cb81323a493d778266de65a1035e04..d2d9a87f491ce6d94f5124a7e838d7e88896d5f4 100644 (file)
@@ -467,7 +467,7 @@ Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
          "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.
index e1d0bb6e13431cae63c068cf0bab144023d958a5..571c6108364c973af71ede0032e203f7a6860078 100644 (file)
@@ -158,10 +158,13 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
     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 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
   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 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
   // 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 @@ void Parser::ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
   // 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 @@ Parser::DeclPtrTy Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
   
   DeclPtrTy ProtoType =
     Actions.ActOnStartProtocolInterface(AtLoc, protocolName, nameLoc,
-                                        &ProtocolRefs[0], ProtocolRefs.size(),
+                                        ProtocolRefs.data(),
+                                        ProtocolRefs.size(),
                                         EndProtoLoc, attrList);
   ParseObjCInterfaceDeclList(ProtoType, tok::objc_protocol);
   return ProtoType;
index 1bcfed7e20471c076aefb8e49aa0f2ee58b2ad53..842235264e9f3a12f24b2b584008b363f23154ba 100644 (file)
@@ -1210,7 +1210,7 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
   }
 
   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);
index 490f2769e12a6a01ddb6454c179ccda0ece060f8..f23f8c0c831d2594fcf4555399fa51637d2ecb23 100644 (file)
@@ -106,7 +106,7 @@ Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context,
     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 @@ void Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,
                                                   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?
index ceb5822433935a350d46ea147ad99c73b0f20725..22bdc7999bbf1cb5df8161a217b64625c3778f9e 100644 (file)
@@ -456,7 +456,7 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
     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 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
       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 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
         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 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
            "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 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, DeclPtrTy *Group,
     }
   }
   return DeclGroupPtrTy::make(DeclGroupRef::Create(Context,
-                                                   &Decls[0], Decls.size()));
+                                                   Decls.data(), Decls.size()));
 }
 
 
@@ -4084,7 +4084,8 @@ void Sema::ActOnFields(Scope* S,
   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);
index 13655ba0920c8e60bc1d4d9ad9300f56206b4faa..35faa4a5eafc44c23c608b122a89db65e3ff9da4 100644 (file)
@@ -1651,7 +1651,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
     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;
index d72d56f1d6908a2538705fcb00d89cf17d0fb97a..e819b1c10fa9cddb41565f0af9042d0816925ffd 100644 (file)
@@ -5144,7 +5144,7 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
       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 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
   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
index 17113f68bd466f265b82e18b9ae9c0c61befc08a..f3ad2a1b326287f1adc73d8d051baeb9ff472d91 100644 (file)
@@ -1687,8 +1687,9 @@ Sema::OwningExprResult Sema::ActOnDesignatedInitializer(Designation &Desig,
   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);
 }
index ebaa99fa989f91b66dbd7da96cd275b0f1da430b..1a1362e6699f03275cb383e9e33e689bb4f9dddf 100644 (file)
@@ -1000,7 +1000,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
     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)
index 47388ace3415f918b03c33df27a8d518e59bb7be..c533789458fdab17c250ec31aaec0adedbb1555f 100644 (file)
@@ -879,7 +879,8 @@ Sema::ActOnTemplateIdType(TemplateTy TemplateD, SourceLocation TemplateLoc,
   translateTemplateArguments(TemplateArgsIn, TemplateArgLocs, TemplateArgs);
 
   QualType Result = CheckTemplateIdType(Template, TemplateLoc, LAngleLoc,
-                                        &TemplateArgs[0], TemplateArgs.size(),
+                                        TemplateArgs.data(),
+                                        TemplateArgs.size(),
                                         RAngleLoc);
   TemplateArgsIn.release();
 
index 08019aaea43a893c464ac602773c452737f7b195..a5b09117885af9af560e7d8af5f5d863fce4b220 100644 (file)
@@ -686,7 +686,7 @@ Sema::InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
   }
 
   if (!Invalid &&
-      AttachBaseSpecifiers(Instantiation, &InstantiatedBases[0],
+      AttachBaseSpecifiers(Instantiation, InstantiatedBases.data(),
                            InstantiatedBases.size()))
     Invalid = true;
 
@@ -770,7 +770,7 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
 
   // 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.
index 385112b7d77f940599c68c4d8d3dfd25d0cb1d23..b9a9ae8c50ac6395a3c697b18c1bef9fca448051 100644 (file)
@@ -301,7 +301,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) {
   // 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 @@ Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
   // 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 @@ TemplateDeclInstantiator::InstantiateFunctionType(FunctionDecl *D,
   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());
 }
index 4889a56513c97fa32905c3044f9e2f4612193efc..e10a912ccfc0f550cb82661601b7646e1c1102de 100644 (file)
@@ -795,7 +795,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip) {
           
           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;