[modules] When performing redeclaration lookup for a using declaration, prefer
UsingShadowDecls over other declarations of the same entity in the lookup
results. This ensures that we build correct redeclaration chains for the
UsingShadowDecls (otherwise we could see assertions and other misbehavior in
modules builds, when merging combines multiple redeclaration chains for the
same entity from the same module into one chain).
llvm-svn: 243592
diff --git a/clang/test/Modules/Inputs/submodules-merge-defs/defs.h b/clang/test/Modules/Inputs/submodules-merge-defs/defs.h
index 07dfac7..e4c86d80 100644
--- a/clang/test/Modules/Inputs/submodules-merge-defs/defs.h
+++ b/clang/test/Modules/Inputs/submodules-merge-defs/defs.h
@@ -97,3 +97,9 @@
enum ScopedEnum : int;
enum ScopedEnum : int { a, b, c };
+
+namespace RedeclDifferentDeclKind {
+ struct X {};
+ typedef X X;
+ using RedeclDifferentDeclKind::X;
+}
diff --git a/clang/test/Modules/Inputs/using-decl-redecl/a.h b/clang/test/Modules/Inputs/using-decl-redecl/a.h
new file mode 100644
index 0000000..4775469
--- /dev/null
+++ b/clang/test/Modules/Inputs/using-decl-redecl/a.h
@@ -0,0 +1,2 @@
+struct string {};
+namespace N { typedef ::string clstring; }
diff --git a/clang/test/Modules/Inputs/using-decl-redecl/b.h b/clang/test/Modules/Inputs/using-decl-redecl/b.h
new file mode 100644
index 0000000..0714bb9
--- /dev/null
+++ b/clang/test/Modules/Inputs/using-decl-redecl/b.h
@@ -0,0 +1,3 @@
+#include "a.h"
+namespace N { using ::N::clstring; }
+extern N::clstring b;
diff --git a/clang/test/Modules/Inputs/using-decl-redecl/c.h b/clang/test/Modules/Inputs/using-decl-redecl/c.h
new file mode 100644
index 0000000..e44e1a0
--- /dev/null
+++ b/clang/test/Modules/Inputs/using-decl-redecl/c.h
@@ -0,0 +1,2 @@
+#include "b.h"
+namespace N { using ::N::clstring; }
diff --git a/clang/test/Modules/Inputs/using-decl-redecl/module.modulemap b/clang/test/Modules/Inputs/using-decl-redecl/module.modulemap
new file mode 100644
index 0000000..bd6ea83
--- /dev/null
+++ b/clang/test/Modules/Inputs/using-decl-redecl/module.modulemap
@@ -0,0 +1,3 @@
+module a { header "a.h" }
+module b { header "b.h" export * }
+module c { header "c.h" export * }
diff --git a/clang/test/Modules/using-decl-redecl.cpp b/clang/test/Modules/using-decl-redecl.cpp
new file mode 100644
index 0000000..0e78cec
--- /dev/null
+++ b/clang/test/Modules/using-decl-redecl.cpp
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t \
+// RUN: -fmodule-map-file=%S/Inputs/using-decl-redecl/module.modulemap \
+// RUN: -I%S/Inputs/using-decl-redecl \
+// RUN: -verify %s
+#include "c.h"
+N::clstring y = b;
+
+// Use a typo to trigger import of all declarations in N.
+N::clstrinh s; // expected-error {{did you mean 'clstring'}}
+// expected-note@a.h:2 {{here}}