aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-12 22:20:26 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-12 22:20:26 +0000
commitc971f8694661776ecdec2ccc33fbe0333eeaf191 (patch)
treed3f2b68258b1409f9b5cee2f406605bbe2a05a9a /lib/Sema
parente6fbdf538bc50122876639e08a1401e2bc9555ba (diff)
Store the type of the integral value within a TemplateArgument, so that we can more efficiently reconstruct an IntegerLiteral from it during template instantiation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66833 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaTemplate.cpp3
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp16
2 files changed, 6 insertions, 13 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index ea91a3836a..6fc4515571 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -1280,7 +1280,8 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
IntegerType->isSignedIntegerType());
CanonicalArg = Value;
- Converted->push_back(TemplateArgument(StartLoc, CanonicalArg));
+ Converted->push_back(TemplateArgument(StartLoc, CanonicalArg,
+ Context.getCanonicalType(IntegerType)));
}
return false;
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 6ed4d9fb44..6252e29e56 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -595,19 +595,11 @@ TemplateExprInstantiator::VisitDeclRefExpr(DeclRefExpr *E) {
Decl *D = E->getDecl();
if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
assert(NTTP->getDepth() == 0 && "No nested templates yet");
- QualType T = NTTP->getType();
- if (T->isDependentType()) {
- // FIXME: We'll be doing this instantiation a lot. Should we
- // cache this information in the TemplateArgument itself?
- T = SemaRef.InstantiateType(T, TemplateArgs, NumTemplateArgs,
- E->getSourceRange().getBegin(),
- NTTP->getDeclName());
- if (T.isNull())
- return SemaRef.ExprError();
- }
+ const TemplateArgument &Arg = TemplateArgs[NTTP->getPosition()];
return SemaRef.Owned(new (SemaRef.Context) IntegerLiteral(
- *TemplateArgs[NTTP->getPosition()].getAsIntegral(),
- T, E->getSourceRange().getBegin()));
+ *Arg.getAsIntegral(),
+ Arg.getIntegralType(),
+ E->getSourceRange().getBegin()));
} else
assert(false && "Can't handle arbitrary declaration references");