// Emits a warning when an element is implicitly set a value that
// a previous element has already been set to.
-static void CheckForDuplicateEnumValues(Sema &S, Decl **Elements,
- unsigned NumElements, EnumDecl *Enum,
+static void CheckForDuplicateEnumValues(Sema &S, ArrayRef<Decl *> Elements,
+ EnumDecl *Enum,
QualType EnumType) {
if (S.Diags.getDiagnosticLevel(diag::warn_duplicate_enum_values,
Enum->getLocation()) ==
// Populate the EnumMap with all values represented by enum constants without
// an initialier.
- for (unsigned i = 0; i < NumElements; ++i) {
+ for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elements[i]);
// Null EnumConstantDecl means a previous diagnostic has been emitted for
}
// Create vectors for any values that has duplicates.
- for (unsigned i = 0; i < NumElements; ++i) {
+ for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
EnumConstantDecl *ECD = cast<EnumConstantDecl>(Elements[i]);
if (!ValidDuplicateEnum(ECD, Enum))
continue;
void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
SourceLocation RBraceLoc, Decl *EnumDeclX,
- Decl **Elements, unsigned NumElements,
+ ArrayRef<Decl *> Elements,
Scope *S, AttributeList *Attr) {
EnumDecl *Enum = cast<EnumDecl>(EnumDeclX);
QualType EnumType = Context.getTypeDeclType(Enum);
ProcessDeclAttributeList(S, Enum, Attr);
if (Enum->isDependentType()) {
- for (unsigned i = 0; i != NumElements; ++i) {
+ for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
EnumConstantDecl *ECD =
cast_or_null<EnumConstantDecl>(Elements[i]);
if (!ECD) continue;
// Keep track of whether all elements have type int.
bool AllElementsInt = true;
- for (unsigned i = 0; i != NumElements; ++i) {
+ for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
EnumConstantDecl *ECD =
cast_or_null<EnumConstantDecl>(Elements[i]);
if (!ECD) continue; // Already issued a diagnostic.
// Loop over all of the enumerator constants, changing their types to match
// the type of the enum if needed.
- for (unsigned i = 0; i != NumElements; ++i) {
+ for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elements[i]);
if (!ECD) continue; // Already issued a diagnostic.
if (InFunctionDeclarator)
DeclsInPrototypeScope.push_back(Enum);
- CheckForDuplicateEnumValues(*this, Elements, NumElements, Enum, EnumType);
+ CheckForDuplicateEnumValues(*this, Elements, Enum, EnumType);
// Now that the enum type is defined, ensure it's not been underaligned.
if (Enum->hasAttrs())