diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-08-15 22:29:14 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-08-15 22:29:14 +0000 |
commit | ccec9d8ceec1b2ef78f68bcef4d9c87c0fa8efbc (patch) | |
tree | f2af1ab413b55e2fbb00af2f3b170053861a4457 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 97e4218ffa6d226b28f694d9f290acfc41dbc2b9 (diff) | |
download | bcm5719-llvm-ccec9d8ceec1b2ef78f68bcef4d9c87c0fa8efbc.tar.gz bcm5719-llvm-ccec9d8ceec1b2ef78f68bcef4d9c87c0fa8efbc.zip |
Add a RAII class for saving and restoring instantiations and uses. No behavior change.
llvm-svn: 215780
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 57 |
1 files changed, 18 insertions, 39 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index cddd5b188d5..b73c2b137c4 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3389,13 +3389,13 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // If we're performing recursive template instantiation, create our own // queue of pending implicit instantiations that we will instantiate later, // while we're still within our own instantiation context. - SmallVector<VTableUse, 16> SavedVTableUses; - std::deque<PendingImplicitInstantiation> SavedPendingInstantiations; SavePendingLocalImplicitInstantiationsRAII SavedPendingLocalImplicitInstantiations(*this); + std::unique_ptr<SavePendingInstantiationsAndVTableUsesRAII> + SavePendingInstantiationsAndVTableUses; if (Recursive) { - VTableUses.swap(SavedVTableUses); - PendingInstantiations.swap(SavedPendingInstantiations); + SavePendingInstantiationsAndVTableUses.reset( + new SavePendingInstantiationsAndVTableUsesRAII(*this)); } EnterExpressionEvaluationContext EvalContext(*this, @@ -3466,15 +3466,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // instantiation of this template. PerformPendingInstantiations(); - // Restore the set of pending vtables. - assert(VTableUses.empty() && - "VTableUses should be empty before it is discarded."); - VTableUses.swap(SavedVTableUses); - - // Restore the set of pending implicit instantiations. - assert(PendingInstantiations.empty() && - "PendingInstantiations should be empty before it is discarded."); - PendingInstantiations.swap(SavedPendingInstantiations); + // Restore PendingInstantiations and VTableUses. + SavePendingInstantiationsAndVTableUses.reset(); } } @@ -3790,11 +3783,11 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, // If we're performing recursive template instantiation, create our own // queue of pending implicit instantiations that we will instantiate // later, while we're still within our own instantiation context. - SmallVector<VTableUse, 16> SavedVTableUses; - std::deque<PendingImplicitInstantiation> SavedPendingInstantiations; + std::unique_ptr<SavePendingInstantiationsAndVTableUsesRAII> + SavePendingInstantiationsAndVTableUses; if (Recursive) { - VTableUses.swap(SavedVTableUses); - PendingInstantiations.swap(SavedPendingInstantiations); + SavePendingInstantiationsAndVTableUses.reset( + new SavePendingInstantiationsAndVTableUsesRAII(*this)); } LocalInstantiationScope Local(*this); @@ -3822,15 +3815,8 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, // instantiation of this template. PerformPendingInstantiations(); - // Restore the set of pending vtables. - assert(VTableUses.empty() && - "VTableUses should be empty before it is discarded."); - VTableUses.swap(SavedVTableUses); - - // Restore the set of pending implicit instantiations. - assert(PendingInstantiations.empty() && - "PendingInstantiations should be empty before it is discarded."); - PendingInstantiations.swap(SavedPendingInstantiations); + // Restore PendingInstantiations and VTableUses. + SavePendingInstantiationsAndVTableUses.reset(); } } @@ -3914,13 +3900,13 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, // If we're performing recursive template instantiation, create our own // queue of pending implicit instantiations that we will instantiate later, // while we're still within our own instantiation context. - SmallVector<VTableUse, 16> SavedVTableUses; - std::deque<PendingImplicitInstantiation> SavedPendingInstantiations; SavePendingLocalImplicitInstantiationsRAII SavedPendingLocalImplicitInstantiations(*this); + std::unique_ptr<SavePendingInstantiationsAndVTableUsesRAII> + SavePendingInstantiationsAndVTableUses; if (Recursive) { - VTableUses.swap(SavedVTableUses); - PendingInstantiations.swap(SavedPendingInstantiations); + SavePendingInstantiationsAndVTableUses.reset( + new SavePendingInstantiationsAndVTableUsesRAII(*this)); } // Enter the scope of this instantiation. We don't use @@ -3987,15 +3973,8 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, // instantiation of this template. PerformPendingInstantiations(); - // Restore the set of pending vtables. - assert(VTableUses.empty() && - "VTableUses should be empty before it is discarded."); - VTableUses.swap(SavedVTableUses); - - // Restore the set of pending implicit instantiations. - assert(PendingInstantiations.empty() && - "PendingInstantiations should be empty before it is discarded."); - PendingInstantiations.swap(SavedPendingInstantiations); + // Restore PendingInstantiations and VTableUses. + SavePendingInstantiationsAndVTableUses.reset(); } } |