diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-01-16 22:29:39 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-01-16 22:29:39 +0000 |
| commit | 7f792cf329578f0b75d4b5676464bde602e467bb (patch) | |
| tree | dcff6177142787f9decf7207d1d6147bdf4169cd /clang/lib/Sema/Sema.h | |
| parent | 520442b32c4918097b3f874206e570e40b0d66d6 (diff) | |
| download | bcm5719-llvm-7f792cf329578f0b75d4b5676464bde602e467bb.tar.gz bcm5719-llvm-7f792cf329578f0b75d4b5676464bde602e467bb.zip | |
Introduce a second queue of "local" pending implicit instantiation,
which are instantiations of the member functions of local
classes. These implicit instantiations have to occur at the same time
as---and in the same local instantiation scope as---the enclosing
function, since the member functions of the local class can refer to
locals within the enclosing function. This should really, really fix PR5764.
llvm-svn: 93666
Diffstat (limited to 'clang/lib/Sema/Sema.h')
| -rw-r--r-- | clang/lib/Sema/Sema.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h index c14ce293aca..02e3a7a93d4 100644 --- a/clang/lib/Sema/Sema.h +++ b/clang/lib/Sema/Sema.h @@ -3165,13 +3165,17 @@ public: /// relevant to this particular scope). LocalInstantiationScope *Outer; + /// \brief Whether we have already exited this scope. + bool Exited; + // This class is non-copyable LocalInstantiationScope(const LocalInstantiationScope &); LocalInstantiationScope &operator=(const LocalInstantiationScope &); public: LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false) - : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope) { + : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope), + Exited(false) { if (!CombineWithOuterScope) SemaRef.CurrentInstantiationScope = this; else @@ -3180,7 +3184,15 @@ public: } ~LocalInstantiationScope() { + if (!Exited) + SemaRef.CurrentInstantiationScope = Outer; + } + + /// \brief Exit this local instantiation scope early. + void Exit() { SemaRef.CurrentInstantiationScope = Outer; + LocalDecls.clear(); + Exited = true; } Decl *getInstantiationOf(const Decl *D) { @@ -3227,7 +3239,16 @@ public: /// but have not yet been performed. std::deque<PendingImplicitInstantiation> PendingImplicitInstantiations; - void PerformPendingImplicitInstantiations(); + /// \brief The queue of implicit template instantiations that are required + /// and must be performed within the current local scope. + /// + /// This queue is only used for member functions of local classes in + /// templates, which must be instantiated in the same scope as their + /// enclosing function, so that they can reference function-local + /// types, static variables, enumerators, etc. + std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations; + + void PerformPendingImplicitInstantiations(bool LocalOnly = false); TypeSourceInfo *SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, |

