diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-06-22 20:57:11 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-06-22 20:57:11 +0000 |
commit | ac7610dad6653bad02dd42de198ca358b6fb1f1d (patch) | |
tree | 788285341527ca7351391c7d608b6386fbd98dd2 /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 05a5c45507243b88ee9e1b3f1ac2fb05b611d7d2 (diff) |
Rework the way we track which declarations are "used" during
compilation, and (hopefully) introduce RAII objects for changing the
"potentially evaluated" state at all of the necessary places within
Sema and Parser. Other changes:
- Set the unevaluated/potentially-evaluated context appropriately
during template instantiation.
- We now recognize three different states while parsing or
instantiating expressions: unevaluated, potentially evaluated, and
potentially potentially evaluated (for C++'s typeid).
- When we're in a potentially potentially-evaluated context, queue
up MarkDeclarationReferenced calls in a stack. For C++ typeid
expressions that are potentially evaluated, we will play back
these MarkDeclarationReferenced calls when we exit the
corresponding potentially potentially-evaluated context.
- Non-type template arguments are now parsed as constant
expressions, so they are not potentially-evaluated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 3992f8cbe5..1c4e907d4d 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -420,6 +420,7 @@ InstantiateDependentSizedArrayType(const DependentSizedArrayType *T, } // Instantiate the size expression + EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated); Sema::OwningExprResult InstantiatedArraySize = SemaRef.InstantiateExpr(ArraySize, TemplateArgs); if (InstantiatedArraySize.isInvalid()) @@ -443,6 +444,10 @@ InstantiateDependentSizedExtVectorType(const DependentSizedExtVectorType *T, return QualType(); } + // The expression in a dependent-sized extended vector type is not + // potentially evaluated. + EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated); + // Instantiate the size expression. const Expr *SizeExpr = T->getSizeExpr(); Sema::OwningExprResult InstantiatedArraySize = @@ -520,6 +525,9 @@ TemplateTypeInstantiator::InstantiateTypedefType(const TypedefType *T, QualType TemplateTypeInstantiator::InstantiateTypeOfExprType(const TypeOfExprType *T, unsigned Quals) const { + // The expression in a typeof is not potentially evaluated. + EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated); + Sema::OwningExprResult E = SemaRef.InstantiateExpr(T->getUnderlyingExpr(), TemplateArgs); if (E.isInvalid()) @@ -1175,6 +1183,9 @@ TemplateArgument Sema::Instantiate(TemplateArgument Arg, return Arg; case TemplateArgument::Expression: { + // Template argument expressions are not potentially evaluated. + EnterExpressionEvaluationContext Unevaluated(*this, Action::Unevaluated); + Sema::OwningExprResult E = InstantiateExpr(Arg.getAsExpr(), TemplateArgs); if (E.isInvalid()) return TemplateArgument(); |