if (Decl *Redecl = D->getPreviousDecl()) {
// For Redeclarable decls, a prior declaration might be local.
for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
- if (!Redecl->isFromASTFile())
+ // If we find a local decl, we're done.
+ if (!Redecl->isFromASTFile()) {
+ // Exception: in very rare cases (for injected-class-names), not all
+ // redeclarations are in the same semantic context. Skip ones in a
+ // different context. They don't go in this lookup table at all.
+ if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
+ D->getDeclContext()->getRedeclContext()))
+ continue;
return cast<NamedDecl>(Redecl);
+ }
+
// If we find a decl from a (chained-)PCH stop since we won't find a
// local one.
- if (D->getOwningModuleID() == 0)
+ if (Redecl->getOwningModuleID() == 0)
break;
}
} else if (Decl *First = D->getCanonicalDecl()) {
--- /dev/null
+module "c.h" {header "c.h" export *}
+module "b2.h" { header "b2.h" export *}
+module "b.h" {header "b.h" export *}
+module "b111.h" { header "b111.h" export *}
+module "b11.h" { header "b11.h" export *}
+module "b1111.h" { header "b1111.h" export *}
+module "b1112.h" { header "b1112.h" export *}
--- /dev/null
+#ifndef _GLIBCXX_STRING
+#define _GLIBCXX_STRING
+template<typename> struct basic_string {
+ struct _Alloc_hider {} _M_dataplus;
+ ~basic_string() { _Alloc_hider h; }
+};
+extern template class basic_string<char>;
+#endif
--- /dev/null
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR27513 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR27513/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR27513 -verify %s
+
+#include "Inputs/PR27513/a.h"
+
+//expected-no-diagnostics