|
@@ -1263,13 +1263,15 @@ static bool shouldBeHidden(NamedDecl *D) {
|
|
StoredDeclsMap *DeclContext::buildLookup() {
|
|
StoredDeclsMap *DeclContext::buildLookup() {
|
|
assert(this == getPrimaryContext() && "buildLookup called on non-primary DC");
|
|
assert(this == getPrimaryContext() && "buildLookup called on non-primary DC");
|
|
|
|
|
|
|
|
+ // FIXME: Should we keep going if hasExternalVisibleStorage?
|
|
if (!LookupPtr.getInt())
|
|
if (!LookupPtr.getInt())
|
|
return LookupPtr.getPointer();
|
|
return LookupPtr.getPointer();
|
|
|
|
|
|
SmallVector<DeclContext *, 2> Contexts;
|
|
SmallVector<DeclContext *, 2> Contexts;
|
|
collectAllContexts(Contexts);
|
|
collectAllContexts(Contexts);
|
|
for (unsigned I = 0, N = Contexts.size(); I != N; ++I)
|
|
for (unsigned I = 0, N = Contexts.size(); I != N; ++I)
|
|
- buildLookupImpl(Contexts[I], hasExternalVisibleStorage());
|
|
|
|
|
|
+ buildLookupImpl<&DeclContext::decls_begin,
|
|
|
|
+ &DeclContext::decls_end>(Contexts[I], false);
|
|
|
|
|
|
// We no longer have any lazy decls.
|
|
// We no longer have any lazy decls.
|
|
LookupPtr.setInt(false);
|
|
LookupPtr.setInt(false);
|
|
@@ -1280,8 +1282,13 @@ StoredDeclsMap *DeclContext::buildLookup() {
|
|
/// declarations contained within DCtx, which will either be this
|
|
/// declarations contained within DCtx, which will either be this
|
|
/// DeclContext, a DeclContext linked to it, or a transparent context
|
|
/// DeclContext, a DeclContext linked to it, or a transparent context
|
|
/// nested within it.
|
|
/// nested within it.
|
|
|
|
+template<DeclContext::decl_iterator (DeclContext::*Begin)() const,
|
|
|
|
+ DeclContext::decl_iterator (DeclContext::*End)() const>
|
|
void DeclContext::buildLookupImpl(DeclContext *DCtx, bool Internal) {
|
|
void DeclContext::buildLookupImpl(DeclContext *DCtx, bool Internal) {
|
|
- for (Decl *D : DCtx->noload_decls()) {
|
|
|
|
|
|
+ for (decl_iterator I = (DCtx->*Begin)(), E = (DCtx->*End)();
|
|
|
|
+ I != E; ++I) {
|
|
|
|
+ Decl *D = *I;
|
|
|
|
+
|
|
// Insert this declaration into the lookup structure, but only if
|
|
// Insert this declaration into the lookup structure, but only if
|
|
// it's semantically within its decl context. Any other decls which
|
|
// it's semantically within its decl context. Any other decls which
|
|
// should be found in this context are added eagerly.
|
|
// should be found in this context are added eagerly.
|
|
@@ -1302,7 +1309,7 @@ void DeclContext::buildLookupImpl(DeclContext *DCtx, bool Internal) {
|
|
// context (recursively).
|
|
// context (recursively).
|
|
if (DeclContext *InnerCtx = dyn_cast<DeclContext>(D))
|
|
if (DeclContext *InnerCtx = dyn_cast<DeclContext>(D))
|
|
if (InnerCtx->isTransparentContext() || InnerCtx->isInlineNamespace())
|
|
if (InnerCtx->isTransparentContext() || InnerCtx->isInlineNamespace())
|
|
- buildLookupImpl(InnerCtx, Internal);
|
|
|
|
|
|
+ buildLookupImpl<Begin, End>(InnerCtx, Internal);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1381,8 +1388,26 @@ DeclContext::noload_lookup(DeclarationName Name) {
|
|
if (PrimaryContext != this)
|
|
if (PrimaryContext != this)
|
|
return PrimaryContext->noload_lookup(Name);
|
|
return PrimaryContext->noload_lookup(Name);
|
|
|
|
|
|
- // Note that buildLookups does not trigger any deserialization.
|
|
|
|
- StoredDeclsMap *Map = buildLookup();
|
|
|
|
|
|
+ StoredDeclsMap *Map = LookupPtr.getPointer();
|
|
|
|
+ if (LookupPtr.getInt()) {
|
|
|
|
+ // Carefully build the lookup map, without deserializing anything.
|
|
|
|
+ SmallVector<DeclContext *, 2> Contexts;
|
|
|
|
+ collectAllContexts(Contexts);
|
|
|
|
+ for (unsigned I = 0, N = Contexts.size(); I != N; ++I)
|
|
|
|
+ buildLookupImpl<&DeclContext::noload_decls_begin,
|
|
|
|
+ &DeclContext::noload_decls_end>(Contexts[I], true);
|
|
|
|
+
|
|
|
|
+ // We no longer have any lazy decls.
|
|
|
|
+ LookupPtr.setInt(false);
|
|
|
|
+
|
|
|
|
+ // There may now be names for which we have local decls but are
|
|
|
|
+ // missing the external decls. FIXME: Just set the hasExternalDecls
|
|
|
|
+ // flag on those names that have external decls.
|
|
|
|
+ NeedToReconcileExternalVisibleStorage = true;
|
|
|
|
+
|
|
|
|
+ Map = LookupPtr.getPointer();
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!Map)
|
|
if (!Map)
|
|
return lookup_result();
|
|
return lookup_result();
|
|
|
|
|