diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-09 18:46:07 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-09 18:46:07 +0000 |
commit | 55f6b14230c94272efbbcdd89a92224c8db9f225 (patch) | |
tree | 988ae940f14f93aac610fbc36d89766e539eab6c /lib/Parse/Parser.cpp | |
parent | 00e68e2cc5ce37cb95beb801cae73c0d1e9dda37 (diff) |
Start processing template-ids as types when the template-name refers
to a class template. For example, the template-id 'vector<int>' now
has a nice, sugary type in the type system. What we can do now:
- Parse template-ids like 'vector<int>' (where 'vector' names a
class template) and form proper types for them in the type system.
- Parse icky template-ids like 'A<5>' and 'A<(5 > 0)>' properly,
using (sadly) a bool in the parser to tell it whether '>' should
be treated as an operator or not.
This is a baby-step, with major problems and limitations:
- There are currently two ways that we handle template arguments
(whether they are types or expressions). These will be merged, and,
most likely, TemplateArg will disappear.
- We don't have any notion of the declaration of class template
specializations or of template instantiations, so all template-ids
are fancy names for 'int' :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64153 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/Parser.cpp')
-rw-r--r-- | lib/Parse/Parser.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index f28767a0fd..7b09d2105c 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -20,7 +20,8 @@ using namespace clang; Parser::Parser(Preprocessor &pp, Action &actions) - : PP(pp), Actions(actions), Diags(PP.getDiagnostics()) { + : PP(pp), Actions(actions), Diags(PP.getDiagnostics()), + GreaterThanIsOperator(true) { Tok.setKind(tok::eof); CurScope = 0; NumCachedScopes = 0; @@ -785,10 +786,15 @@ bool Parser::TryAnnotateTypeOrScopeToken() { } // If this is a template-id, annotate the template-id token. - if (NextToken().is(tok::less)) - if (DeclTy *Template = - Actions.isTemplateName(*Tok.getIdentifierInfo(), CurScope, &SS)) - AnnotateTemplateIdToken(Template, &SS); + if (NextToken().is(tok::less)) { + DeclTy *Template; + if (TemplateNameKind TNK + = Actions.isTemplateName(*Tok.getIdentifierInfo(), + CurScope, Template, &SS)) { + AnnotateTemplateIdToken(Template, TNK, &SS); + return true; + } + } // We either have an identifier that is not a type name or we have // just created a template-id that might be a type name. Both |