Debug Info (-gmodules): emit full types for non-anchored template specializations
Before this patch, clang would emit a (module-)forward declaration for
template instantiations that are not anchored by an explicit template
instantiation, but still are guaranteed to be available in an imported
module. Unfortunately detecting the owning module doesn't reliably
work when local submodule visibility is enabled and the template is
inside a cross-module namespace.
This make clang debuggable again with -gmodules and LSV enabled.
rdar://problem/41552377
llvm-svn: 345109
diff --git a/clang/test/Modules/Inputs/lsv-debuginfo/A/ADT.h b/clang/test/Modules/Inputs/lsv-debuginfo/A/ADT.h
new file mode 100644
index 0000000..f48d4f7
--- /dev/null
+++ b/clang/test/Modules/Inputs/lsv-debuginfo/A/ADT.h
@@ -0,0 +1,45 @@
+#ifndef ADT
+#define ADT
+
+#ifdef WITH_NAMESPACE
+namespace llvm {
+#endif
+template <unsigned Alignment, unsigned Size>
+struct AlignedCharArray {
+ alignas(Alignment) char buffer[Size];
+};
+
+template <typename T1>
+class AlignerImpl {
+ T1 t1;
+};
+
+template <typename T1>
+union SizerImpl {
+ char arr1[sizeof(T1)];
+};
+
+template <typename T1>
+struct AlignedCharArrayUnion
+ : AlignedCharArray<alignof(AlignerImpl<T1>), sizeof(SizerImpl<T1>)> {};
+
+template <typename T, unsigned N>
+struct SmallVectorStorage {
+ AlignedCharArrayUnion<T> InlineElts[N];
+};
+template <typename T, unsigned N>
+class SmallVector : SmallVectorStorage<T, N> {};
+
+template <typename T>
+struct OptionalStorage {
+ AlignedCharArrayUnion<T> storage;
+};
+template <typename T>
+class Optional {
+ OptionalStorage<T> Storage;
+};
+
+#ifdef WITH_NAMESPACE
+} // namespace llvm
+#endif
+#endif
diff --git a/clang/test/Modules/Inputs/lsv-debuginfo/B/B.h b/clang/test/Modules/Inputs/lsv-debuginfo/B/B.h
new file mode 100644
index 0000000..c00bc3c
--- /dev/null
+++ b/clang/test/Modules/Inputs/lsv-debuginfo/B/B.h
@@ -0,0 +1,14 @@
+#ifndef B_H
+#define B_H
+#include <A/ADT.h>
+#include <C/C.h>
+
+namespace llvm {
+struct S {
+ unsigned a, b, c, d;
+};
+class C {
+ Optional<S> S;
+};
+}
+#endif
diff --git a/clang/test/Modules/Inputs/lsv-debuginfo/C/C.h b/clang/test/Modules/Inputs/lsv-debuginfo/C/C.h
new file mode 100644
index 0000000..52c6e4d
--- /dev/null
+++ b/clang/test/Modules/Inputs/lsv-debuginfo/C/C.h
@@ -0,0 +1,13 @@
+#ifndef C_H
+#define C_H
+#include <A/ADT.h>
+
+namespace llvm {
+class D {
+ struct Q {
+ unsigned a, b, c, d;
+ };
+ SmallVector<Q, 4> q;
+};
+} // namespace llvm
+#endif
diff --git a/clang/test/Modules/Inputs/lsv-debuginfo/module.modulemap b/clang/test/Modules/Inputs/lsv-debuginfo/module.modulemap
new file mode 100644
index 0000000..5bb0449
--- /dev/null
+++ b/clang/test/Modules/Inputs/lsv-debuginfo/module.modulemap
@@ -0,0 +1,9 @@
+module A {
+ umbrella "A" module * { export * }
+}
+module B {
+ umbrella "B" module * { export * }
+}
+module C {
+ umbrella "C" module * { export * }
+}