}
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());
}
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);
}
};
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.
// 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);
}
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;
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);
}
}
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);
// 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();
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");
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);
}
// \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;
}
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) {
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) {
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++]);
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) {
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;
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;
// 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);
}
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);
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
#if !defined(DISABLE_SMART_POINTERS)
Owns = false;
#endif
- return &(*this)[0];
+ return this->data();
}
#if !defined(DISABLE_SMART_POINTERS)
"Unexpected number of commas!");
Actions.AddCXXDirectInitializerToDecl(ThisDecl, LParenLoc,
move_arg(Exprs),
- &CommaLocs[0], RParenLoc);
+ CommaLocs.data(), RParenLoc);
}
} else {
Actions.ActOnUninitializedDecl(ThisDecl);
ParseDeclarator(D);
}
- return Actions.FinalizeDeclaratorGroup(CurScope, &DeclsInGroup[0],
+ return Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(),
DeclsInGroup.size());
}
AttrList = ParseAttributes();
Actions.ActOnFields(CurScope,
- RecordLoc,TagDecl,&FieldDecls[0],FieldDecls.size(),
+ RecordLoc, TagDecl, FieldDecls.data(), FieldDecls.size(),
LBraceLoc, RBraceLoc,
AttrList);
StructScope.Exit();
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.
// 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,
}
// 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
if (Tok.is(tok::semi)) {
ConsumeToken();
- Actions.FinalizeDeclaratorGroup(CurScope, &DeclsInGroup[0],
+ Actions.FinalizeDeclaratorGroup(CurScope, DeclsInGroup.data(),
DeclsInGroup.size());
return;
}
} while (true);
Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc,
- &MemInitializers[0], MemInitializers.size());
+ MemInitializers.data(), MemInitializers.size());
}
/// ParseMemInitializer - Parse a C++ member initializer, which is
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
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());
}
"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.
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;
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))
// 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.
// 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;
}
DeclPtrTy ProtoType =
Actions.ActOnStartProtocolInterface(AtLoc, protocolName, nameLoc,
- &ProtocolRefs[0], ProtocolRefs.size(),
+ ProtocolRefs.data(),
+ ProtocolRefs.size(),
EndProtoLoc, attrList);
ParseObjCInterfaceDeclList(ProtoType, tok::objc_protocol);
return ProtoType;
}
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);
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));
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?
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);
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);
Params.push_back(Param);
}
- New->setParams(Context, &Params[0], Params.size());
+ New->setParams(Context, Params.data(), Params.size());
}
return MergeCompatibleFunctionDecls(New, Old);
"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());
}
}
return DeclGroupPtrTy::make(DeclGroupRef::Create(Context,
- &Decls[0], Decls.size()));
+ Decls.data(), Decls.size()));
}
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);
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;
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);
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
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);
}
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)
translateTemplateArguments(TemplateArgsIn, TemplateArgLocs, TemplateArgs);
QualType Result = CheckTemplateIdType(Template, TemplateLoc, LAngleLoc,
- &TemplateArgs[0], TemplateArgs.size(),
+ TemplateArgs.data(),
+ TemplateArgs.size(),
RAngleLoc);
TemplateArgsIn.release();
}
if (!Invalid &&
- AttachBaseSpecifiers(Instantiation, &InstantiatedBases[0],
+ AttachBaseSpecifiers(Instantiation, InstantiatedBases.data(),
InstantiatedBases.size()))
Invalid = true;
// 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.
// 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();
// 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();
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());
}
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;