Modular Codegen: Support homing debug info for types in modular objects

Matching the function-homing support for modular codegen. Any type
implicitly (implicit template specializations) or explicitly defined in
a module is attached to that module's object file and omitted elsewhere
(only a declaration used if necessary for references).

llvm-svn: 299987
diff --git a/clang/test/Modules/Inputs/codegen-nodep/foo.h b/clang/test/Modules/Inputs/codegen-nodep/foo.h
index af91e8d..e7b20a5 100644
--- a/clang/test/Modules/Inputs/codegen-nodep/foo.h
+++ b/clang/test/Modules/Inputs/codegen-nodep/foo.h
@@ -1,5 +1,11 @@
 template <typename T>
-void ftempl() {
+void foot() {
 }
-inline void f() {
+inline void foo() {
 }
+
+template <typename T>
+struct bart {
+};
+struct bar {
+};
diff --git a/clang/test/Modules/codegen-nodep.test b/clang/test/Modules/codegen-nodep.test
index cb2b4e3..0c3eb47 100644
--- a/clang/test/Modules/codegen-nodep.test
+++ b/clang/test/Modules/codegen-nodep.test
@@ -7,7 +7,7 @@
 RUN:          | llvm-bcanalyzer - -dump \
 RUN:          | FileCheck %s
 
-Ensure there's only one modular codegen decl - the sentinel plain inline
-function, not any for the function template.
+Ensure there are only two modular codegen decls (one for the class, one for the
+function - none for the class and function templates).
 
-CHECK: <MODULAR_CODEGEN_DECLS op0={{[0-9]+}}/>
+CHECK: <MODULAR_CODEGEN_DECLS op0={{[0-9]+}} op1={{[0-9]+}}/>
diff --git a/clang/test/Modules/codegen.test b/clang/test/Modules/codegen.test
index 6807640..ce252e8 100644
--- a/clang/test/Modules/codegen.test
+++ b/clang/test/Modules/codegen.test
@@ -3,8 +3,8 @@
 
 RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
 
-RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s
-RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s
 
 FOO: $_Z2f1PKcz = comdat any
 FOO: $_ZN13implicit_dtorD1Ev = comdat any
@@ -25,3 +25,11 @@
 USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD1Ev
 USE: define linkonce_odr void @_Z4instIiEvv
 USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD2Ev
+
+Modular debug info puts the definition of a class defined in a module in that
+module's object. Users of the module only get a declaration.
+
+'distinct' is used for definition records (the flags field is empty/unspecified)
+FOO: = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "implicit_dtor"
+Declarations are non-distinct and include the 'DIFlagFwdDecl' flag.
+USE: = !DICompositeType(tag: DW_TAG_structure_type, name: "implicit_dtor", {{.*}}, flags: DIFlagFwdDecl