Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit f53f0e7

Browse files
committed
[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
1 parent 66e6308 commit f53f0e7

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

include/clang/Parse/Parser.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2724,11 +2724,11 @@ class Parser : public CodeCompletionHandler {
27242724
AccessSpecifier AS=AS_none,
27252725
AttributeList *AccessAttrs = nullptr);
27262726
bool ParseTemplateParameters(unsigned Depth,
2727-
SmallVectorImpl<Decl*> &TemplateParams,
2727+
SmallVectorImpl<NamedDecl *> &TemplateParams,
27282728
SourceLocation &LAngleLoc,
27292729
SourceLocation &RAngleLoc);
27302730
bool ParseTemplateParameterList(unsigned Depth,
2731-
SmallVectorImpl<Decl*> &TemplateParams);
2731+
SmallVectorImpl<NamedDecl*> &TemplateParams);
27322732
bool isStartOfTemplateTypeParameter();
27332733
Decl *ParseTemplateParameter(unsigned Depth, unsigned Position);
27342734
Decl *ParseTypeParameter(unsigned Depth, unsigned Position);

include/clang/Sema/Sema.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6052,7 +6052,7 @@ class Sema {
60526052
SourceLocation ExportLoc,
60536053
SourceLocation TemplateLoc,
60546054
SourceLocation LAngleLoc,
6055-
ArrayRef<Decl *> Params,
6055+
ArrayRef<NamedDecl *> Params,
60566056
SourceLocation RAngleLoc,
60576057
Expr *RequiresClause);
60586058

lib/Parse/ParseTemplate.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context,
112112

113113
// Parse the '<' template-parameter-list '>'
114114
SourceLocation LAngleLoc, RAngleLoc;
115-
SmallVector<Decl*, 4> TemplateParams;
115+
SmallVector<NamedDecl*, 4> TemplateParams;
116116
if (ParseTemplateParameters(CurTemplateDepthTracker.getDepth(),
117117
TemplateParams, LAngleLoc, RAngleLoc)) {
118118
// Skip until the semi-colon or a '}'.
@@ -329,10 +329,9 @@ Parser::ParseSingleDeclarationAfterTemplate(
329329
/// that enclose this template parameter list.
330330
///
331331
/// \returns true if an error occurred, false otherwise.
332-
bool Parser::ParseTemplateParameters(unsigned Depth,
333-
SmallVectorImpl<Decl*> &TemplateParams,
334-
SourceLocation &LAngleLoc,
335-
SourceLocation &RAngleLoc) {
332+
bool Parser::ParseTemplateParameters(
333+
unsigned Depth, SmallVectorImpl<NamedDecl *> &TemplateParams,
334+
SourceLocation &LAngleLoc, SourceLocation &RAngleLoc) {
336335
// Get the template parameter list.
337336
if (!TryConsumeToken(tok::less, LAngleLoc)) {
338337
Diag(Tok.getLocation(), diag::err_expected_less_after) << "template";
@@ -370,11 +369,12 @@ bool Parser::ParseTemplateParameters(unsigned Depth,
370369
/// template-parameter-list ',' template-parameter
371370
bool
372371
Parser::ParseTemplateParameterList(unsigned Depth,
373-
SmallVectorImpl<Decl*> &TemplateParams) {
372+
SmallVectorImpl<NamedDecl*> &TemplateParams) {
374373
while (1) {
374+
// FIXME: ParseTemplateParameter should probably just return a NamedDecl.
375375
if (Decl *TmpParam
376376
= ParseTemplateParameter(Depth, TemplateParams.size())) {
377-
TemplateParams.push_back(TmpParam);
377+
TemplateParams.push_back(dyn_cast<NamedDecl>(TmpParam));
378378
} else {
379379
// If we failed to parse a template parameter, skip until we find
380380
// a comma or closing brace.
@@ -569,7 +569,7 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
569569

570570
// Handle the template <...> part.
571571
SourceLocation TemplateLoc = ConsumeToken();
572-
SmallVector<Decl*,8> TemplateParams;
572+
SmallVector<NamedDecl*,8> TemplateParams;
573573
SourceLocation LAngleLoc, RAngleLoc;
574574
{
575575
ParseScope TemplateParmScope(this, Scope::TemplateParamScope);

lib/Sema/SemaTemplate.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1080,15 +1080,15 @@ Sema::ActOnTemplateParameterList(unsigned Depth,
10801080
SourceLocation ExportLoc,
10811081
SourceLocation TemplateLoc,
10821082
SourceLocation LAngleLoc,
1083-
ArrayRef<Decl *> Params,
1083+
ArrayRef<NamedDecl *> Params,
10841084
SourceLocation RAngleLoc,
10851085
Expr *RequiresClause) {
10861086
if (ExportLoc.isValid())
10871087
Diag(ExportLoc, diag::warn_template_export_unsupported);
10881088

10891089
return TemplateParameterList::Create(
10901090
Context, TemplateLoc, LAngleLoc,
1091-
llvm::makeArrayRef((NamedDecl *const *)Params.data(), Params.size()),
1091+
llvm::makeArrayRef(Params.data(), Params.size()),
10921092
RAngleLoc, RequiresClause);
10931093
}
10941094

0 commit comments

Comments
 (0)