From: Dmitri Gribenko Date: Sat, 27 Apr 2013 20:23:52 +0000 (+0000) Subject: ArrayRef'ize Sema::ActOnEnumBody. No functionality change. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ff2b421f352fe0a0769c0a2a75af922c147b878;p=clang ArrayRef'ize Sema::ActOnEnumBody. No functionality change. Patch by Robert Wilhelm. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180682 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 629d775a1b..b1b7df2344 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1681,7 +1681,7 @@ public: SourceLocation EqualLoc, Expr *Val); void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, SourceLocation RBraceLoc, Decl *EnumDecl, - Decl **Elements, unsigned NumElements, + ArrayRef Elements, Scope *S, AttributeList *Attr); DeclContext *getContainingDC(DeclContext *DC); diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 957e2eb164..d786ce23d0 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3753,8 +3753,8 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, Decl *EnumDecl) { MaybeParseGNUAttributes(attrs); Actions.ActOnEnumBody(StartLoc, T.getOpenLocation(), T.getCloseLocation(), - EnumDecl, EnumConstantDecls.data(), - EnumConstantDecls.size(), getCurScope(), + EnumDecl, EnumConstantDecls, + getCurScope(), attrs.getList()); EnumScope.Exit(); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 3d4f97fbd2..9a3499dc39 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -11559,8 +11559,8 @@ struct DenseMapInfoDupKey { // 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 Elements, + EnumDecl *Enum, QualType EnumType) { if (S.Diags.getDiagnosticLevel(diag::warn_duplicate_enum_values, Enum->getLocation()) == @@ -11586,7 +11586,7 @@ static void CheckForDuplicateEnumValues(Sema &S, Decl **Elements, // 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(Elements[i]); // Null EnumConstantDecl means a previous diagnostic has been emitted for @@ -11607,7 +11607,7 @@ static void CheckForDuplicateEnumValues(Sema &S, Decl **Elements, } // 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(Elements[i]); if (!ValidDuplicateEnum(ECD, Enum)) continue; @@ -11671,7 +11671,7 @@ static void CheckForDuplicateEnumValues(Sema &S, Decl **Elements, void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, SourceLocation RBraceLoc, Decl *EnumDeclX, - Decl **Elements, unsigned NumElements, + ArrayRef Elements, Scope *S, AttributeList *Attr) { EnumDecl *Enum = cast(EnumDeclX); QualType EnumType = Context.getTypeDeclType(Enum); @@ -11680,7 +11680,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, 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(Elements[i]); if (!ECD) continue; @@ -11707,7 +11707,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, // 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(Elements[i]); if (!ECD) continue; // Already issued a diagnostic. @@ -11824,7 +11824,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, // 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(Elements[i]); if (!ECD) continue; // Already issued a diagnostic. @@ -11892,7 +11892,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, 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()) diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index f78f4b5462..e1b8ca2e95 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -801,7 +801,7 @@ void TemplateDeclInstantiator::InstantiateEnumDefinition( // FIXME: Fixup LBraceLoc SemaRef.ActOnEnumBody(Enum->getLocation(), SourceLocation(), Enum->getRBraceLoc(), Enum, - Enumerators.data(), Enumerators.size(), + Enumerators, 0, 0); }