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
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index f0544eb..bba99fd 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -62,6 +62,7 @@
class TypedefDecl;
class TemplateDecl;
class TemplateParameterList;
+ class TemplateArg;
class ObjCInterfaceDecl;
class ObjCCompatibleAliasDecl;
class ObjCProtocolDecl;
@@ -258,6 +259,9 @@
return OwningExprResult(*this, R.get());
}
OwningStmtResult Owned(Stmt* S) { return OwningStmtResult(*this, S); }
+ OwningTemplateArgResult Owned(TemplateArg *Arg) {
+ return OwningTemplateArgResult(*this, Arg);
+ }
virtual void ActOnEndOfTranslationUnit();
@@ -1478,8 +1482,9 @@
//===--------------------------------------------------------------------===//
// C++ Templates [C++ 14]
//
- virtual DeclTy *isTemplateName(IdentifierInfo &II, Scope *S,
- const CXXScopeSpec *SS = 0);
+ virtual TemplateNameKind isTemplateName(IdentifierInfo &II, Scope *S,
+ DeclTy *&TemplateDecl,
+ const CXXScopeSpec *SS = 0);
bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
TemplateDecl *AdjustDeclIfTemplate(DeclTy *&Decl);
@@ -1506,6 +1511,10 @@
DeclTy **Params, unsigned NumParams,
SourceLocation RAngleLoc);
+ virtual OwningTemplateArgResult ActOnTypeTemplateArgument(TypeTy *Type);
+
+ virtual OwningTemplateArgResult ActOnExprTemplateArgument(ExprArg Value);
+
virtual DeclTy *
ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
@@ -1513,6 +1522,13 @@
AttributeList *Attr,
MultiTemplateParamsArg TemplateParameterLists);
+ virtual TypeTy *
+ ActOnClassTemplateSpecialization(DeclTy *Template,
+ SourceLocation LAngleLoc,
+ MultiTemplateArgsArg TemplateArgs,
+ SourceLocation RAngleLoc,
+ const CXXScopeSpec *SS = 0);
+
bool TemplateParameterListsAreEqual(TemplateParameterList *New,
TemplateParameterList *Old,
bool Complain,