diff options
-rw-r--r-- | include/clang/Sema/Sema.h | 7 | ||||
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 6 | ||||
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 3 | ||||
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 36 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 10 |
8 files changed, 37 insertions, 43 deletions
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index cdf24fc7df..1d780def42 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1490,15 +1490,14 @@ public: void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc); void FinalizeDeclaration(Decl *D); DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, - Decl **Group, - unsigned NumDecls); - DeclGroupPtrTy BuildDeclaratorGroup(Decl **Group, unsigned NumDecls, + ArrayRef<Decl *> Group); + DeclGroupPtrTy BuildDeclaratorGroup(llvm::MutableArrayRef<Decl *> Group, bool TypeMayContainAuto = true); /// Should be called on all declarations that might have attached /// documentation comments. void ActOnDocumentableDecl(Decl *D); - void ActOnDocumentableDecls(Decl **Group, unsigned NumDecls); + void ActOnDocumentableDecls(ArrayRef<Decl *> Group); void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls); diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 681468ddc7..7559aa9596 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1667,7 +1667,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, Actions.ActOnCXXForRangeDecl(ThisDecl); Actions.FinalizeDeclaration(ThisDecl); D.complete(ThisDecl); - return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, &ThisDecl, 1); + return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, ThisDecl); } SmallVector<Decl *, 8> DeclsInGroup; @@ -1734,9 +1734,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, } } - return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, - DeclsInGroup.data(), - DeclsInGroup.size()); + return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, DeclsInGroup); } /// Parse an optional simple-asm-expr and attributes, and attach them to a diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 070c9a0120..940ecc1109 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -2368,8 +2368,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, return; } - Actions.FinalizeDeclaratorGroup(getCurScope(), DS, DeclsInGroup.data(), - DeclsInGroup.size()); + Actions.FinalizeDeclaratorGroup(getCurScope(), DS, DeclsInGroup); } /// ParseCXXMemberInitializer - Parse the brace-or-equal-initializer or diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index de18432d96..749fec3026 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -817,8 +817,8 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { } DeclSpec DS(AttrFactory); - DeclGroupPtrTy Res = Actions.FinalizeDeclaratorGroup(getCurScope(), DS, - DeclsInGroup.data(), DeclsInGroup.size()); + DeclGroupPtrTy Res = + Actions.FinalizeDeclaratorGroup(getCurScope(), DS, DeclsInGroup); StmtResult R = Actions.ActOnDeclStmt(Res, LabelLoc, Tok.getLocation()); ExpectAndConsumeSemi(diag::err_expected_semi_declaration); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 5abacca732..3f85de5d2c 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -8363,15 +8363,14 @@ Sema::FinalizeDeclaration(Decl *ThisDecl) { } } -Sema::DeclGroupPtrTy -Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, - Decl **Group, unsigned NumDecls) { +Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, + ArrayRef<Decl *> Group) { SmallVector<Decl*, 8> Decls; if (DS.isTypeSpecOwned()) Decls.push_back(DS.getRepAsDecl()); - for (unsigned i = 0; i != NumDecls; ++i) + for (unsigned i = 0, e = Group.size(); i != e; ++i) if (Decl *D = Group[i]) Decls.push_back(D); @@ -8379,14 +8378,13 @@ Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, if (const TagDecl *Tag = dyn_cast_or_null<TagDecl>(DS.getRepAsDecl())) getASTContext().addUnnamedTag(Tag); - return BuildDeclaratorGroup(Decls.data(), Decls.size(), - DS.containsPlaceholderType()); + return BuildDeclaratorGroup(Decls, DS.containsPlaceholderType()); } /// BuildDeclaratorGroup - convert a list of declarations into a declaration /// group, performing any necessary semantic checking. Sema::DeclGroupPtrTy -Sema::BuildDeclaratorGroup(Decl **Group, unsigned NumDecls, +Sema::BuildDeclaratorGroup(llvm::MutableArrayRef<Decl *> Group, bool TypeMayContainAuto) { // C++0x [dcl.spec.auto]p7: // If the type deduced for the template parameter U is not the same in each @@ -8395,11 +8393,11 @@ Sema::BuildDeclaratorGroup(Decl **Group, unsigned NumDecls, // between the deduced type U and the deduced type which 'auto' stands for. // auto a = 0, b = { 1, 2, 3 }; // is legal because the deduced type U is 'int' in both cases. - if (TypeMayContainAuto && NumDecls > 1) { + if (TypeMayContainAuto && Group.size() > 1) { QualType Deduced; CanQualType DeducedCanon; VarDecl *DeducedDecl = 0; - for (unsigned i = 0; i != NumDecls; ++i) { + for (unsigned i = 0, e = Group.size(); i != e; ++i) { if (VarDecl *D = dyn_cast<VarDecl>(Group[i])) { AutoType *AT = D->getType()->getContainedAutoType(); // Don't reissue diagnostics when instantiating a template. @@ -8428,18 +8426,19 @@ Sema::BuildDeclaratorGroup(Decl **Group, unsigned NumDecls, } } - ActOnDocumentableDecls(Group, NumDecls); + ActOnDocumentableDecls(Group); - return DeclGroupPtrTy::make(DeclGroupRef::Create(Context, Group, NumDecls)); + return DeclGroupPtrTy::make( + DeclGroupRef::Create(Context, Group.data(), Group.size())); } void Sema::ActOnDocumentableDecl(Decl *D) { - ActOnDocumentableDecls(&D, 1); + ActOnDocumentableDecls(D); } -void Sema::ActOnDocumentableDecls(Decl **Group, unsigned NumDecls) { +void Sema::ActOnDocumentableDecls(ArrayRef<Decl *> Group) { // Don't parse the comment if Doxygen diagnostics are ignored. - if (NumDecls == 0 || !Group[0]) + if (Group.empty() || !Group[0]) return; if (Diags.getDiagnosticLevel(diag::warn_doc_param_not_found, @@ -8447,9 +8446,9 @@ void Sema::ActOnDocumentableDecls(Decl **Group, unsigned NumDecls) { == DiagnosticsEngine::Ignored) return; - if (NumDecls >= 2) { + if (Group.size() >= 2) { // This is a decl group. Normally it will contain only declarations - // procuded from declarator list. But in case we have any definitions or + // produced from declarator list. But in case we have any definitions or // additional declaration references: // 'typedef struct S {} S;' // 'typedef struct S *S;' @@ -8457,8 +8456,7 @@ void Sema::ActOnDocumentableDecls(Decl **Group, unsigned NumDecls) { // FinalizeDeclaratorGroup adds these as separate declarations. Decl *MaybeTagDecl = Group[0]; if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) { - Group++; - NumDecls--; + Group = Group.slice(1); } } @@ -8473,7 +8471,7 @@ void Sema::ActOnDocumentableDecls(Decl **Group, unsigned NumDecls) { // declaration, but also comments that *follow* the declaration -- thanks to // the lookahead in the lexer: we've consumed the semicolon and looked // ahead through comments. - for (unsigned i = 0; i != NumDecls; ++i) + for (unsigned i = 0, e = Group.size(); i != e; ++i) Context.getCommentForDecl(Group[i], &PP); } } diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index e8a6c50388..87dfe10363 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -833,7 +833,7 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, DeclsInGroup.push_back(PDecl); } - return BuildDeclaratorGroup(DeclsInGroup.data(), DeclsInGroup.size(), false); + return BuildDeclaratorGroup(DeclsInGroup, false); } Decl *Sema:: @@ -1100,7 +1100,7 @@ Sema::ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef<Decl *> Decls) { DeclsInGroup.push_back(ObjCImpDecl); - return BuildDeclaratorGroup(DeclsInGroup.data(), DeclsInGroup.size(), false); + return BuildDeclaratorGroup(DeclsInGroup, false); } void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, @@ -1985,8 +1985,8 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, CheckObjCDeclScope(IDecl); DeclsInGroup.push_back(IDecl); } - - return BuildDeclaratorGroup(DeclsInGroup.data(), DeclsInGroup.size(), false); + + return BuildDeclaratorGroup(DeclsInGroup, false); } static bool tryMatchRecordTypes(ASTContext &Context, diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 3a67997ea4..8572861988 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -1765,7 +1765,8 @@ Sema::ActOnCXXForRangeStmt(SourceLocation ForLoc, // Claim the type doesn't contain auto: we've already done the checking. DeclGroupPtrTy RangeGroup = - BuildDeclaratorGroup((Decl**)&RangeVar, 1, /*TypeMayContainAuto=*/false); + BuildDeclaratorGroup(llvm::MutableArrayRef<Decl *>((Decl **)&RangeVar, 1), + /*TypeMayContainAuto=*/ false); StmtResult RangeDecl = ActOnDeclStmt(RangeGroup, RangeLoc, RangeLoc); if (RangeDecl.isInvalid()) return StmtError(); @@ -2045,7 +2046,8 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation ColonLoc, Decl *BeginEndDecls[] = { BeginVar, EndVar }; // Claim the type doesn't contain auto: we've already done the checking. DeclGroupPtrTy BeginEndGroup = - BuildDeclaratorGroup(BeginEndDecls, 2, /*TypeMayContainAuto=*/false); + BuildDeclaratorGroup(llvm::MutableArrayRef<Decl *>(BeginEndDecls, 2), + /*TypeMayContainAuto=*/ false); BeginEndDecl = ActOnDeclStmt(BeginEndGroup, ColonLoc, ColonLoc); const QualType BeginRefNonRefType = BeginType.getNonReferenceType(); diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 9fbbe2cf1d..aaeedc1042 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -1163,10 +1163,9 @@ public: /// /// By default, performs semantic analysis to build the new statement. /// Subclasses may override this routine to provide different behavior. - StmtResult RebuildDeclStmt(Decl **Decls, unsigned NumDecls, - SourceLocation StartLoc, - SourceLocation EndLoc) { - Sema::DeclGroupPtrTy DG = getSema().BuildDeclaratorGroup(Decls, NumDecls); + StmtResult RebuildDeclStmt(llvm::MutableArrayRef<Decl *> Decls, + SourceLocation StartLoc, SourceLocation EndLoc) { + Sema::DeclGroupPtrTy DG = getSema().BuildDeclaratorGroup(Decls); return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc); } @@ -5603,8 +5602,7 @@ TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) { if (!getDerived().AlwaysRebuild() && !DeclChanged) return SemaRef.Owned(S); - return getDerived().RebuildDeclStmt(Decls.data(), Decls.size(), - S->getStartLoc(), S->getEndLoc()); + return getDerived().RebuildDeclStmt(Decls, S->getStartLoc(), S->getEndLoc()); } template<typename Derived> |