void Sema::ActOnFields(Scope* S,
SourceLocation RecLoc, Decl *EnclosingDecl,
- Decl **Fields, unsigned NumFields,
+ llvm::ArrayRef<Decl *> Fields,
SourceLocation LBrac, SourceLocation RBrac,
AttributeList *Attr) {
assert(EnclosingDecl && "missing record or interface decl");
RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl);
bool ARCErrReported = false;
- for (unsigned i = 0; i != NumFields; ++i) {
- FieldDecl *FD = cast<FieldDecl>(Fields[i]);
+ for (llvm::ArrayRef<Decl *>::iterator i = Fields.begin(), end = Fields.end();
+ i != end; ++i) {
+ FieldDecl *FD = cast<FieldDecl>(*i);
// Get the type for the field.
const Type *FDTy = FD->getType().getTypePtr();
EnclosingDecl->setInvalidDecl();
continue;
} else if (FDTy->isIncompleteArrayType() && Record &&
- ((i == NumFields - 1 && !Record->isUnion()) ||
+ ((i + 1 == Fields.end() && !Record->isUnion()) ||
((getLangOptions().MicrosoftExt ||
getLangOptions().CPlusPlus) &&
- (i == NumFields - 1 || Record->isUnion())))) {
+ (i + 1 == Fields.end() || Record->isUnion())))) {
// Flexible array member.
// Microsoft and g++ is more permissive regarding flexible array.
// It will accept flexible array in union and also
if (Record->isUnion())
Diag(FD->getLocation(), diag::ext_flexible_array_union_ms)
<< FD->getDeclName();
- else if (NumFields == 1)
+ else if (Fields.size() == 1)
Diag(FD->getLocation(), diag::ext_flexible_array_empty_aggregate_ms)
<< FD->getDeclName() << Record->getTagKind();
} else if (getLangOptions().CPlusPlus) {
if (Record->isUnion())
Diag(FD->getLocation(), diag::ext_flexible_array_union_gnu)
<< FD->getDeclName();
- else if (NumFields == 1)
+ else if (Fields.size() == 1)
Diag(FD->getLocation(), diag::ext_flexible_array_empty_aggregate_gnu)
<< FD->getDeclName() << Record->getTagKind();
} else if (NumNamedMembers < 1) {
// If this is a struct/class and this is not the last element, reject
// it. Note that GCC supports variable sized arrays in the middle of
// structures.
- if (i != NumFields-1)
+ if (i + 1 != Fields.end())
Diag(FD->getLocation(), diag::ext_variable_sized_type_in_struct)
<< FD->getDeclName() << FD->getType();
else {
AdjustDeclIfTemplate(TagDecl);
- ActOnFields(S, RLoc, TagDecl,
+ ActOnFields(S, RLoc, TagDecl, llvm::makeArrayRef(
// strict aliasing violation!
reinterpret_cast<Decl**>(FieldCollector->getCurFields()),
- FieldCollector->getCurNumFields(), LBrac, RBrac, AttrList);
+ FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
CheckCompletedCXXClass(
dyn_cast_or_null<CXXRecordDecl>(TagDecl));
}
// Finish checking fields.
- ActOnFields(0, Instantiation->getLocation(), Instantiation,
- Fields.data(), Fields.size(), SourceLocation(), SourceLocation(),
- 0);
+ ActOnFields(0, Instantiation->getLocation(), Instantiation, Fields,
+ SourceLocation(), SourceLocation(), 0);
CheckCompletedCXXClass(Instantiation);
// Attach any in-class member initializers now the class is complete.