aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Type.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-04-27 00:57:59 +0000
committerJohn McCall <rjmccall@apple.com>2010-04-27 00:57:59 +0000
commit31f17ecbef57b5679c017c375db330546b7b5145 (patch)
tree284e3662375c4f1d59e72b2390c99e2b0e682eb1 /lib/AST/Type.cpp
parent184d7900e0202ac468710b731e42075129bb6000 (diff)
Make the InjectedClassNameType the canonical type of the current instantiation
of a class template or class template partial specialization. That is to say, in template <class T> class A { ... }; or template <class T> class B<const T*> { ... }; make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType when written inside the appropriate context. This allows us to track the current instantiation appropriately even inside AST routines. It also allows us to compute a DeclContext for a type much more efficiently, at some extra cost every time we write a template specialization (which can be optimized, but I've left it simple in this patch). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r--lib/AST/Type.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index d21890daf7..52ee60b984 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -1004,12 +1004,13 @@ anyDependentTemplateArguments(const TemplateArgument *Args, unsigned N) {
TemplateSpecializationType::
TemplateSpecializationType(ASTContext &Context, TemplateName T,
+ bool IsCurrentInstantiation,
const TemplateArgument *Args,
unsigned NumArgs, QualType Canon)
: Type(TemplateSpecialization,
Canon.isNull()? QualType(this, 0) : Canon,
T.isDependent() || anyDependentTemplateArguments(Args, NumArgs)),
- Context(Context),
+ ContextAndCurrentInstantiation(&Context, IsCurrentInstantiation),
Template(T), NumArgs(NumArgs) {
assert((!Canon.isNull() ||
T.isDependent() || anyDependentTemplateArguments(Args, NumArgs)) &&
@@ -1044,9 +1045,11 @@ TemplateSpecializationType::getArg(unsigned Idx) const {
void
TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
TemplateName T,
+ bool IsCurrentInstantiation,
const TemplateArgument *Args,
unsigned NumArgs,
ASTContext &Context) {
+ ID.AddBoolean(IsCurrentInstantiation);
T.Profile(ID);
for (unsigned Idx = 0; Idx < NumArgs; ++Idx)
Args[Idx].Profile(ID, Context);