summaryrefslogtreecommitdiffstats
path: root/lib/Sema/MultiplexExternalSemaSource.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-05-16 23:01:30 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-05-16 23:01:30 +0000
commit3ad9bfabb64f758b5166353d978f18891c4e4a7f (patch)
treeb66f75ae8ff18581e9af97cc043fde52c53edbbc /lib/Sema/MultiplexExternalSemaSource.cpp
parentdb597e2297f8e1b204959deca03e0466147cc0d1 (diff)
If a declaration is loaded, and then a module import adds a redeclaration, then
ensure that querying the first declaration for its most recent declaration checks for redeclarations from the imported module. This works as follows: * The 'most recent' pointer on a canonical declaration grows a pointer to the external AST source and a generation number (space- and time-optimized for the case where there is no external source). * Each time the 'most recent' pointer is queried, if it has an external source, we check whether it's up to date, and update it if not. * The ancillary data stored on the canonical declaration is allocated lazily to avoid filling it in for declarations that end up being non-canonical. We'll still perform a redundant (ASTContext) allocation if someone asks for the most recent declaration from a decl before setPreviousDecl is called, but such cases are probably all bugs, and are now easy to find. Some finessing is still in order here -- in particular, we use a very general mechanism for handling the DefinitionData pointer on CXXRecordData, and a more targeted approach would be more compact. Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was addressing only a corner of the full problem space here. That's not covered by this patch. Early performance benchmarks show that this makes no measurable difference to Clang performance without modules enabled (and fixes a major correctness issue with modules enabled). I'll revert if a full performance comparison shows any problems. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209046 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/MultiplexExternalSemaSource.cpp')
-rw-r--r--lib/Sema/MultiplexExternalSemaSource.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Sema/MultiplexExternalSemaSource.cpp b/lib/Sema/MultiplexExternalSemaSource.cpp
index ad7627a457..35072a5fac 100644
--- a/lib/Sema/MultiplexExternalSemaSource.cpp
+++ b/lib/Sema/MultiplexExternalSemaSource.cpp
@@ -49,6 +49,11 @@ Decl *MultiplexExternalSemaSource::GetExternalDecl(uint32_t ID) {
return 0;
}
+void MultiplexExternalSemaSource::CompleteRedeclChain(const Decl *D) {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->CompleteRedeclChain(D);
+}
+
Selector MultiplexExternalSemaSource::GetExternalSelector(uint32_t ID) {
Selector Sel;
for(size_t i = 0; i < Sources.size(); ++i) {