diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-03-30 22:58:21 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-03-30 22:58:21 +0000 |
| commit | dc572a326610eaf0972ece1790f61e5b6404727e (patch) | |
| tree | 0f0b61400e94133bf93faefaff187749159c3a6c /clang/lib/Parse | |
| parent | adccd30533683045338fa4af186245638da0e17a (diff) | |
| download | bcm5719-llvm-dc572a326610eaf0972ece1790f61e5b6404727e.tar.gz bcm5719-llvm-dc572a326610eaf0972ece1790f61e5b6404727e.zip | |
Improve the representation of template names in the AST. This
representation handles the various ways in which one can name a
template, including unqualified references ("vector"), qualified
references ("std::vector"), and dependent template names
("MetaFun::template apply").
One immediate effect of this change is that the representation of
nested-name-specifiers in type names for class template
specializations (e.g., std::vector<int>) is more accurate. Rather than
representing std::vector<int> as
std::(vector<int>)
we represent it as
(std::vector)<int>
which more closely follows the C++ grammar.
Additionally, templates are no longer represented as declarations
(DeclPtrTy) in Parse-Sema interactions. Instead, I've introduced a new
OpaquePtr type (TemplateTy) that holds the representation of a
TemplateName. This will simplify the handling of dependent
template-names, once we get there.
llvm-svn: 68074
Diffstat (limited to 'clang/lib/Parse')
| -rw-r--r-- | clang/lib/Parse/MinimalAction.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseTemplate.cpp | 25 | ||||
| -rw-r--r-- | clang/lib/Parse/Parser.cpp | 2 |
5 files changed, 17 insertions, 16 deletions
diff --git a/clang/lib/Parse/MinimalAction.cpp b/clang/lib/Parse/MinimalAction.cpp index f31aef61d31..e99e96a7dc3 100644 --- a/clang/lib/Parse/MinimalAction.cpp +++ b/clang/lib/Parse/MinimalAction.cpp @@ -135,7 +135,7 @@ bool MinimalAction::isCurrentClassName(const IdentifierInfo &, Scope *, TemplateNameKind MinimalAction::isTemplateName(IdentifierInfo &II, Scope *S, - DeclPtrTy &TemplateDecl, + TemplateTy &TemplateDecl, const CXXScopeSpec *SS) { return TNK_Non_template; } diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 37a460cd41f..fdfc7315a82 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -474,7 +474,7 @@ void Parser::ParseClassSpecifier(DeclSpec &DS, TagOrTempResult = Actions.ActOnClassTemplateSpecialization(CurScope, TagType, TK, StartLoc, SS, - DeclPtrTy::make(TemplateId->Template), + TemplateTy::make(TemplateId->Template), TemplateId->TemplateNameLoc, TemplateId->LAngleLoc, TemplateArgsPtr, diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index dc57ac141c5..4d419bbd875 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -117,7 +117,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS) { // an operator and not as part of a simple-template-id. } - DeclPtrTy Template; + TemplateTy Template; TemplateNameKind TNK = TNK_Non_template; // FIXME: If the nested-name-specifier thus far is dependent, // set TNK = TNK_Dependent_template_name and skip the diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp index b962cbf646d..8eda6948644 100644 --- a/clang/lib/Parse/ParseTemplate.cpp +++ b/clang/lib/Parse/ParseTemplate.cpp @@ -406,7 +406,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) { /// last token in the stream (e.g., so that it can be replaced with an /// annotation token). bool -Parser::ParseTemplateIdAfterTemplateName(DeclPtrTy Template, +Parser::ParseTemplateIdAfterTemplateName(TemplateTy Template, SourceLocation TemplateNameLoc, const CXXScopeSpec *SS, bool ConsumeLastToken, @@ -499,7 +499,7 @@ Parser::ParseTemplateIdAfterTemplateName(DeclPtrTy Template, /// replaced with a type annotation token. Otherwise, the /// simple-template-id is always replaced with a template-id /// annotation token. -void Parser::AnnotateTemplateIdToken(DeclPtrTy Template, TemplateNameKind TNK, +void Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK, const CXXScopeSpec *SS, SourceLocation TemplateKWLoc, bool AllowTypeAnnotation) { @@ -531,12 +531,13 @@ void Parser::AnnotateTemplateIdToken(DeclPtrTy Template, TemplateNameKind TNK, return; // Build the annotation token. + // FIXME: Not just for class templates! if (TNK == TNK_Class_template && AllowTypeAnnotation) { Action::TypeResult Type - = Actions.ActOnClassTemplateId(Template, TemplateNameLoc, - LAngleLoc, TemplateArgsPtr, - &TemplateArgLocations[0], - RAngleLoc, SS); + = Actions.ActOnTemplateIdType(Template, TemplateNameLoc, + LAngleLoc, TemplateArgsPtr, + &TemplateArgLocations[0], + RAngleLoc); if (Type.isInvalid()) // FIXME: better recovery? return; @@ -603,12 +604,12 @@ bool Parser::AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS) { TemplateId->NumArgs); Action::TypeResult Type - = Actions.ActOnClassTemplateId(DeclPtrTy::make(TemplateId->Template), - TemplateId->TemplateNameLoc, - TemplateId->LAngleLoc, - TemplateArgsPtr, - TemplateId->getTemplateArgLocations(), - TemplateId->RAngleLoc, SS); + = Actions.ActOnTemplateIdType(TemplateTy::make(TemplateId->Template), + TemplateId->TemplateNameLoc, + TemplateId->LAngleLoc, + TemplateArgsPtr, + TemplateId->getTemplateArgLocations(), + TemplateId->RAngleLoc); if (Type.isInvalid()) { // FIXME: better recovery? ConsumeToken(); diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index b34c241fd1b..a101aaa7326 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -885,7 +885,7 @@ bool Parser::TryAnnotateTypeOrScopeToken() { // If this is a template-id, annotate with a template-id or type token. if (NextToken().is(tok::less)) { - DeclPtrTy Template; + TemplateTy Template; if (TemplateNameKind TNK = Actions.isTemplateName(*Tok.getIdentifierInfo(), CurScope, Template, &SS)) |

