Home | History | Annotate | Download | only in Parse

Lines Matching full:template

1 //===--- ParseTemplate.cpp - Template Parsing -----------------------------===//
25 /// \brief Parse a template declaration, explicit instantiation, or
45 /// \brief Parse a template declaration or an explicit specialization.
47 /// Template declarations include one or more template parameter lists
48 /// and either the function or class template declaration. Explicit
49 /// specializations contain one or more 'template < >' prefixes
52 /// of the template headers together and let semantic analysis sort
55 /// template-declaration: [C++ temp]
56 /// 'export'[opt] 'template' '<' template-parameter-list '>' declaration
59 /// 'template' '<' '>' declaration
66 "Token does not start a template declaration.");
68 // Enter template-parameter scope.
76 // Parse multiple levels of template headers within this template
79 // template<typename T>
80 // template<typename U>
84 // single data structure containing all of the template parameter
87 // template<typename T>
89 // template<typename U> class B;
93 // both template parameter lists. In the second case, the action for
94 // defining A<T>::B receives just the inner template parameter list
95 // (and retrieves the outer template parameter list from its
107 // Consume the 'template', which should be here.
114 // Parse the '<' template-parameter-list '>'
151 // Parse the actual template declaration.
160 /// \brief Parse a single declaration that declares a template,
161 /// template specialization, or explicit instantiation of a template.
179 "Template information required");
190 // We are parsing a member template.
204 // the template parameters.
267 // If the declarator-id is not a template-id, issue a diagnostic and
268 // recover by ignoring the 'template' keyword.
316 /// ParseTemplateParameters - Parses a template-parameter-list enclosed in
317 /// angle brackets. Depth is the depth of this template-parameter-list, which
318 /// is the number of template headers directly enclosing this template header.
319 /// TemplateParams is the current list of template parameters we're building.
320 /// The template parameter we parse will be added to this list. LAngleLoc and
322 /// that enclose this template parameter list.
329 // Get the template parameter list.
331 Diag(Tok.getLocation(), diag::err_expected_less_after) << "template";
335 // Try to parse the template parameter list.
341 // No diagnostic required here: a template-parameter-list can only be
342 // followed by a declaration or, for a template template parameter, the
345 // template<template<typename>> struct S;
356 /// ParseTemplateParameterList - Parse a template parameter list. If
361 /// template-parameter-list: [C++ temp]
362 /// template-parameter
363 /// template-parameter-list ',' template-parameter
372 // If we failed to parse a template parameter, skip until we find
378 // Did we find a comma or the end of the template parameter list?
382 // Don't consume this... that's done by template parser.
385 // Somebody probably forgot to close the template. Skip ahead and
397 /// \brief Determine whether the parser is at the start of a template
437 // template-parameter. typename followed by an unqualified-id
438 // names a template type parameter. typename followed by a
460 /// ParseTemplateParameter - Parse a template-parameter (C++ [temp.param]).
462 /// template-parameter: [C++ temp.param]
471 /// 'template' '<' template-parameter-list '>'
473 /// 'template' '<' template-parameter-list '>' 'class' identifier[opt]
483 // NOTE: This will pick up errors in the closure of the template parameter
484 // list (e.g., template < ; Check here to implement >> style closures.
488 /// ParseTypeParameter - Parse a template type parameter (C++ [temp.param]).
489 /// Other kinds of template parameters are parsed in
514 // Grab the template parameter name (if given)
522 // Unnamed template parameter. Don't have to do anything here, just
548 /// ParseTemplateTemplateParameter - Handle the parsing of template
549 /// template parameters.
552 /// 'template' '<' template-parameter-list '>' type-parameter-key
554 /// 'template' '<' template-parameter-list '>' type-parameter-key
561 assert(Tok.is(tok::kw_template) && "Expected 'template' keyword");
563 // Handle the template <...> part.
619 // Unnamed template parameter. Don't have to do anything here, just
640 // we introduce the template parameter into the local scope.
660 /// template parameters (e.g., in "template<int Size> class array;").
662 /// template-parameter:
688 // we introduce the template parameter into the local scope.
693 // When parsing a default template-argument for a non-type
694 // template-parameter, the first non-nested > is taken as the
695 // end of the template-parameter-list rather than a greater-than
734 /// \brief Parses a '>' at the end of a template list.
745 /// type parameter or type argument list, rather than a C++ template parameter
787 // This template-id is terminated by a token which starts with a '>'. Outside
860 /// \brief Parses a template-id that after the template name has
863 /// This routine takes care of parsing the enclosed template argument
864 /// list ('<' template-parameter-list [opt] '>') and placing the
867 /// \param Template the template declaration produced by isTemplateName
869 /// \param TemplateNameLoc the source location of the template name
872 /// template name.
875 /// token that forms the template-id. Otherwise, we will leave the
879 Parser::ParseTemplateIdAfterTemplateName(TemplateTy Template,
886 assert(Tok.is(tok::less) && "Must have already parsed the template-name");
891 // Parse the optional template-argument-list.
912 /// \brief Replace the tokens that form a simple-template-id with an
913 /// annotation token containing the complete template-id.
915 /// The first token in the stream must be the name of a template that
917 /// simple-template-id and replace the tokens with a single annotation
918 /// token with one of two different kinds: if the template-id names a
921 /// (\p SS). Otherwise, the annotation token is a template-id
925 /// \param Template the declaration of the template named by the first
928 /// \param TNK the kind of template that \p Template
932 /// this template name.
934 /// \param TemplateKWLoc if valid, specifies that this template-id
935 /// annotation was preceded by the 'template' keyword and gives the
937 /// template-id was not preceded by a 'template' keyword.
940 /// simple-template-id that refers to a class template, template
941 /// template parameter, or other template that produces a type will be
943 /// simple-template-id is always replaced with a template-id
949 bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,
954 assert(getLangOpts().CPlusPlus && "Can only annotate template-ids in C++");
955 assert(Template && Tok.is(tok::less) &&
956 "Parser isn't at the beginning of a template-id");
958 // Consume the template-name.
961 // Parse the enclosed template argument list.
964 bool Invalid = ParseTemplateIdAfterTemplateName(Template,
971 // If we failed to parse the template ID but skipped ahead to a >, we're not
983 Template, TemplateNameLoc,
986 // If we failed to parse the template ID but skipped ahead to a >, we're not
1001 // Build a template-id annotation token that can be processed
1016 TemplateId->Template = Template;
1039 /// \brief Replaces a template-id annotation token with a type
1042 /// If there was a failure when forming the type from the template-id,
1046 assert(Tok.is(tok::annot_template_id) && "Requires template-id tokens");
1059 TemplateId->Template,
1071 // Replace the template-id annotation token, and possible the scope-specifier
1076 /// \brief Determine whether the given token can end a template argument.
1081 /// \brief Parse a C++ template template argument.
1087 // C++0x [temp.arg.template]p1:
1088 // A template-argument for a template template-parameter shall be the name
1089 // of a class template or an alias template, expressed as id-expression.
1091 // We parse an id-expression that refers to a class template or alias
1092 // template. The grammar we parse is:
1094 // nested-name-specifier[opt] template[opt] identifier ...[opt]
1096 // followed by a token that terminates a template argument, such as ',',
1105 // Parse the optional 'template' keyword following the
1110 // We appear to have a dependent template name.
1117 // If the next token signals the end of a template argument,
1118 // then we have a dependent template name that could be a template
1119 // template argument.
1120 TemplateTy Template;
1126 Template))
1127 Result = ParsedTemplateArgument(SS, Template, Name.StartLocation);
1130 // We may have a (non-dependent) template name.
1131 TemplateTy Template;
1145 Template,
1148 // We have an id-expression that refers to a class template or
1149 // (C++0x) alias template.
1150 Result = ParsedTemplateArgument(SS, Template, Name.StartLocation);
1162 /// ParseTemplateArgument - Parse a C++ template argument (C++ [temp.names]).
1164 /// template-argument: [C++ 14.2]
1170 // In a template-argument, an ambiguity between a type-id and an
1172 // the corresponding template-parameter.
1187 // Try to parse a template template argument.
1198 // Revert this tentative parse to parse a non-type template argument.
1202 // Parse a non-type template argument.
1213 /// template argument list (starting with the '<') and never as a '<'
1230 // An empty template argument list.
1238 // If we have a '>' or a ',' then this is a template argument list.
1242 /// ParseTemplateArgumentList - Parse a C++ template-argument-list
1245 /// template-argument-list: [C++ 14.2]
1246 /// template-argument
1247 /// template-argument-list ',' template-argument
1250 // Template argument lists are constant-evaluation contexts.
1265 // Save this template argument.
1275 /// \brief Parse a C++ explicit template instantiation
1279 /// 'extern' [opt] 'template' declaration
1313 /// \brief Late parse a C++ function template in Microsoft mode.
1320 // Track template parameter depth.
1337 // Reenter template scopes from outermost to innermost.
1388 "current template being instantiated!");
1403 /// \brief Lex a delayed template function for late parsing.