diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2010-11-25 00:35:20 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2010-11-25 00:35:20 +0000 |
commit | 2a5f99eb4e2af771faacfceb9f78e230129c5e5a (patch) | |
tree | 8634c7998e24299a51169097cfec604e58d46208 /lib/Sema/Sema.cpp | |
parent | 0b9fb2f6b4845bfe5e25b576ae8f2ffa284f9cb1 (diff) |
Tie DefineVTablesUsed() in with recursive function instantiation so that we emit
a useful template instantiation stack. Fixes PR8640.
This also causes a slight change to where the "instantianted from" note shows up
in truly esoteric cases (see the change to test/SemaCXX/destructor.cpp), but
that isn't directly the fault of this patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120135 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index ec7b61d32a..e9791a0e64 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -284,26 +284,24 @@ static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) { void Sema::ActOnEndOfTranslationUnit() { // At PCH writing, implicit instantiations and VTable handling info are // stored and performed when the PCH is included. - if (CompleteTranslationUnit) - while (1) { - // C++: Perform implicit template instantiations. - // - // FIXME: When we perform these implicit instantiations, we do not - // carefully keep track of the point of instantiation (C++ [temp.point]). - // This means that name lookup that occurs within the template - // instantiation will always happen at the end of the translation unit, - // so it will find some names that should not be found. Although this is - // common behavior for C++ compilers, it is technically wrong. In the - // future, we either need to be able to filter the results of name lookup - // or we need to perform template instantiations earlier. - PerformPendingInstantiations(); - - /// If DefinedUsedVTables ends up marking any virtual member - /// functions it might lead to more pending template - /// instantiations, which is why we need to loop here. - if (!DefineUsedVTables()) - break; - } + if (CompleteTranslationUnit) { + // If DefinedUsedVTables ends up marking any virtual member functions it + // might lead to more pending template instantiations, which we then need + // to instantiate. + DefineUsedVTables(); + + // C++: Perform implicit template instantiations. + // + // FIXME: When we perform these implicit instantiations, we do not + // carefully keep track of the point of instantiation (C++ [temp.point]). + // This means that name lookup that occurs within the template + // instantiation will always happen at the end of the translation unit, + // so it will find some names that should not be found. Although this is + // common behavior for C++ compilers, it is technically wrong. In the + // future, we either need to be able to filter the results of name lookup + // or we need to perform template instantiations earlier. + PerformPendingInstantiations(); + } // Remove file scoped decls that turned out to be used. UnusedFileScopedDecls.erase(std::remove_if(UnusedFileScopedDecls.begin(), |