diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 36 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 10 |
4 files changed, 29 insertions, 31 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 5abacca732c..3f85de5d2c1 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index e8a6c503888..87dfe103630 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/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/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 3a67997ea48..85728619880 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/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/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 9fbbe2cf1d5..aaeedc10420 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/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> |