}
assert(D && "missing definition for pattern of instantiated definition");
- // FIXME: If we merged any other decl into D, and that declaration is visible,
- // then we should consider a definition to be visible.
*Suggested = D;
- return LookupResult::isVisible(*this, D);
+ if (LookupResult::isVisible(*this, D))
+ return true;
+
+ // The external source may have additional definitions of this type that are
+ // visible, so complete the redeclaration chain now and ask again.
+ if (auto *Source = Context.getExternalSource()) {
+ Source->CompleteRedeclChain(D);
+ return LookupResult::isVisible(*this, D);
+ }
+
+ return false;
}
/// Locks in the inheritance model for the given class and all of its bases.
case UPD_DECL_EXPORTED:
unsigned SubmoduleID = readSubmoduleID(Record, Idx);
+ auto *Exported = cast<NamedDecl>(D);
+ if (auto *TD = dyn_cast<TagDecl>(Exported))
+ Exported = TD->getDefinition();
Module *Owner = SubmoduleID ? Reader.getSubmodule(SubmoduleID) : nullptr;
if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
// FIXME: This doesn't send the right notifications if there are
--- /dev/null
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-map-file=%S/Inputs/merge-class-definition-visibility/modmap \
+// RUN: -I%S/Inputs/merge-class-definition-visibility \
+// RUN: -fmodules-cache-path=%t %s -verify
+// expected-no-diagnostics
+
+#include "c.h"
+template<typename T> struct X { T t; };
+typedef X<A> XA;
+
+#include "d.h"
+// Ensure that this triggers the import of the second definition from d.h,
+// which is necessary to make the definition of A visible in the template
+// instantiation.
+XA xa;