From f53f0e7b93bcf0c75f071fd387ab9e6a623e307e Mon Sep 17 00:00:00 2001 From: Faisal Vali Date: Fri, 25 Aug 2017 18:24:20 +0000 Subject: [PATCH] [NFC] Remove a cstyle cast and replace some uses of Decl with NamedDecl during the processing of TemplateParameterLists. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311788 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Parse/Parser.h | 4 ++-- include/clang/Sema/Sema.h | 2 +- lib/Parse/ParseTemplate.cpp | 16 ++++++++-------- lib/Sema/SemaTemplate.cpp | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index fdb5aba207..db7fc05124 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -2724,11 +2724,11 @@ private: AccessSpecifier AS=AS_none, AttributeList *AccessAttrs = nullptr); bool ParseTemplateParameters(unsigned Depth, - SmallVectorImpl &TemplateParams, + SmallVectorImpl &TemplateParams, SourceLocation &LAngleLoc, SourceLocation &RAngleLoc); bool ParseTemplateParameterList(unsigned Depth, - SmallVectorImpl &TemplateParams); + SmallVectorImpl &TemplateParams); bool isStartOfTemplateTypeParameter(); Decl *ParseTemplateParameter(unsigned Depth, unsigned Position); Decl *ParseTypeParameter(unsigned Depth, unsigned Position); diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 267b613ace..70ee299423 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -6052,7 +6052,7 @@ public: SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, - ArrayRef Params, + ArrayRef Params, SourceLocation RAngleLoc, Expr *RequiresClause); diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index fc1722ea6c..da0707f66e 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -112,7 +112,7 @@ Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context, // Parse the '<' template-parameter-list '>' SourceLocation LAngleLoc, RAngleLoc; - SmallVector TemplateParams; + SmallVector TemplateParams; if (ParseTemplateParameters(CurTemplateDepthTracker.getDepth(), TemplateParams, LAngleLoc, RAngleLoc)) { // Skip until the semi-colon or a '}'. @@ -329,10 +329,9 @@ Parser::ParseSingleDeclarationAfterTemplate( /// that enclose this template parameter list. /// /// \returns true if an error occurred, false otherwise. -bool Parser::ParseTemplateParameters(unsigned Depth, - SmallVectorImpl &TemplateParams, - SourceLocation &LAngleLoc, - SourceLocation &RAngleLoc) { +bool Parser::ParseTemplateParameters( + unsigned Depth, SmallVectorImpl &TemplateParams, + SourceLocation &LAngleLoc, SourceLocation &RAngleLoc) { // Get the template parameter list. if (!TryConsumeToken(tok::less, LAngleLoc)) { Diag(Tok.getLocation(), diag::err_expected_less_after) << "template"; @@ -370,11 +369,12 @@ bool Parser::ParseTemplateParameters(unsigned Depth, /// template-parameter-list ',' template-parameter bool Parser::ParseTemplateParameterList(unsigned Depth, - SmallVectorImpl &TemplateParams) { + SmallVectorImpl &TemplateParams) { while (1) { + // FIXME: ParseTemplateParameter should probably just return a NamedDecl. if (Decl *TmpParam = ParseTemplateParameter(Depth, TemplateParams.size())) { - TemplateParams.push_back(TmpParam); + TemplateParams.push_back(dyn_cast(TmpParam)); } else { // If we failed to parse a template parameter, skip until we find // a comma or closing brace. @@ -569,7 +569,7 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) { // Handle the template <...> part. SourceLocation TemplateLoc = ConsumeToken(); - SmallVector TemplateParams; + SmallVector TemplateParams; SourceLocation LAngleLoc, RAngleLoc; { ParseScope TemplateParmScope(this, Scope::TemplateParamScope); diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index e9b3855168..1fcc79403f 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -1080,7 +1080,7 @@ Sema::ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, - ArrayRef Params, + ArrayRef Params, SourceLocation RAngleLoc, Expr *RequiresClause) { if (ExportLoc.isValid()) @@ -1088,7 +1088,7 @@ Sema::ActOnTemplateParameterList(unsigned Depth, return TemplateParameterList::Create( Context, TemplateLoc, LAngleLoc, - llvm::makeArrayRef((NamedDecl *const *)Params.data(), Params.size()), + llvm::makeArrayRef(Params.data(), Params.size()), RAngleLoc, RequiresClause); } -- 2.50.1