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

Commit 2b9abcd

Browse files
committed
[NFC] Update the template-parameter parsers and analyzers to return NamedDecl (vs Decl)
This patch addresses a FIXME and has the template-parameter processing functions return a more derived common type NamedDecl (as opposed to a type needlessly higher up in the inheritance hierarchy : Decl). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321409 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d87ab96 commit 2b9abcd

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

include/clang/Parse/Parser.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -2748,10 +2748,10 @@ class Parser : public CodeCompletionHandler {
27482748
bool ParseTemplateParameterList(unsigned Depth,
27492749
SmallVectorImpl<NamedDecl*> &TemplateParams);
27502750
bool isStartOfTemplateTypeParameter();
2751-
Decl *ParseTemplateParameter(unsigned Depth, unsigned Position);
2752-
Decl *ParseTypeParameter(unsigned Depth, unsigned Position);
2753-
Decl *ParseTemplateTemplateParameter(unsigned Depth, unsigned Position);
2754-
Decl *ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position);
2751+
NamedDecl *ParseTemplateParameter(unsigned Depth, unsigned Position);
2752+
NamedDecl *ParseTypeParameter(unsigned Depth, unsigned Position);
2753+
NamedDecl *ParseTemplateTemplateParameter(unsigned Depth, unsigned Position);
2754+
NamedDecl *ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position);
27552755
void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
27562756
SourceLocation CorrectLoc,
27572757
bool AlreadyHasEllipsis,

include/clang/Sema/Sema.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -6064,7 +6064,7 @@ class Sema {
60646064
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
60656065
TemplateDecl *AdjustDeclIfTemplate(Decl *&Decl);
60666066

6067-
Decl *ActOnTypeParameter(Scope *S, bool Typename,
6067+
NamedDecl *ActOnTypeParameter(Scope *S, bool Typename,
60686068
SourceLocation EllipsisLoc,
60696069
SourceLocation KeyLoc,
60706070
IdentifierInfo *ParamName,
@@ -6077,12 +6077,12 @@ class Sema {
60776077
SourceLocation Loc);
60786078
QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
60796079

6080-
Decl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
6080+
NamedDecl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
60816081
unsigned Depth,
60826082
unsigned Position,
60836083
SourceLocation EqualLoc,
60846084
Expr *DefaultArg);
6085-
Decl *ActOnTemplateTemplateParameter(Scope *S,
6085+
NamedDecl *ActOnTemplateTemplateParameter(Scope *S,
60866086
SourceLocation TmpLoc,
60876087
TemplateParameterList *Params,
60886088
SourceLocation EllipsisLoc,

lib/Parse/ParseTemplate.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ bool
372372
Parser::ParseTemplateParameterList(unsigned Depth,
373373
SmallVectorImpl<NamedDecl*> &TemplateParams) {
374374
while (1) {
375-
// FIXME: ParseTemplateParameter should probably just return a NamedDecl.
376-
if (Decl *TmpParam
375+
376+
if (NamedDecl *TmpParam
377377
= ParseTemplateParameter(Depth, TemplateParams.size())) {
378378
TemplateParams.push_back(dyn_cast<NamedDecl>(TmpParam));
379379
} else {
@@ -480,7 +480,7 @@ bool Parser::isStartOfTemplateTypeParameter() {
480480
/// 'class' ...[opt] identifier[opt]
481481
/// 'template' '<' template-parameter-list '>' 'class' identifier[opt]
482482
/// = id-expression
483-
Decl *Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) {
483+
NamedDecl *Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) {
484484
if (isStartOfTemplateTypeParameter())
485485
return ParseTypeParameter(Depth, Position);
486486

@@ -502,7 +502,7 @@ Decl *Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) {
502502
/// 'class' identifier[opt] '=' type-id
503503
/// 'typename' ...[opt][C++0x] identifier[opt]
504504
/// 'typename' identifier[opt] '=' type-id
505-
Decl *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) {
505+
NamedDecl *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) {
506506
assert(Tok.isOneOf(tok::kw_class, tok::kw_typename) &&
507507
"A type-parameter starts with 'class' or 'typename'");
508508

@@ -564,7 +564,7 @@ Decl *Parser::ParseTypeParameter(unsigned Depth, unsigned Position) {
564564
/// type-parameter-key:
565565
/// 'class'
566566
/// 'typename' [C++1z]
567-
Decl *
567+
NamedDecl *
568568
Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
569569
assert(Tok.is(tok::kw_template) && "Expected 'template' keyword");
570570

@@ -669,7 +669,7 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
669669
/// template-parameter:
670670
/// ...
671671
/// parameter-declaration
672-
Decl *
672+
NamedDecl *
673673
Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
674674
// Parse the declaration-specifiers (i.e., the type).
675675
// FIXME: The type should probably be restricted in some way... Not all

lib/Sema/SemaTemplate.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S,
792792
/// ParamNameLoc is the location of the parameter name (if any).
793793
/// If the type parameter has a default argument, it will be added
794794
/// later via ActOnTypeParameterDefault.
795-
Decl *Sema::ActOnTypeParameter(Scope *S, bool Typename,
795+
NamedDecl *Sema::ActOnTypeParameter(Scope *S, bool Typename,
796796
SourceLocation EllipsisLoc,
797797
SourceLocation KeyLoc,
798798
IdentifierInfo *ParamName,
@@ -922,7 +922,7 @@ QualType Sema::CheckNonTypeTemplateParameterType(QualType T,
922922
return QualType();
923923
}
924924

925-
Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
925+
NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
926926
unsigned Depth,
927927
unsigned Position,
928928
SourceLocation EqualLoc,
@@ -1053,7 +1053,7 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
10531053
/// ActOnTemplateTemplateParameter - Called when a C++ template template
10541054
/// parameter (e.g. T in template <template \<typename> class T> class array)
10551055
/// has been parsed. S is the current scope.
1056-
Decl *Sema::ActOnTemplateTemplateParameter(Scope* S,
1056+
NamedDecl *Sema::ActOnTemplateTemplateParameter(Scope* S,
10571057
SourceLocation TmpLoc,
10581058
TemplateParameterList *Params,
10591059
SourceLocation EllipsisLoc,

0 commit comments

Comments
 (0)