Debug Info: Add a file: field to DIImportedEntity.

DIImportedEntity has a line number, but not a file field. To determine
the decl_line/decl_file we combine the line number from the
DIImportedEntity with the file from the DIImportedEntity's scope. This
does not work correctly when the parent scope is a DINamespace or a
DIModule, both of which do not have a source file.

This patch adds a file field to DIImportedEntity to unambiguously
identify the source location of the using/import declaration.  Most
testcase updates are mechanical, the interesting one is the removal of
the FIXME in test/DebugInfo/Generic/namespace.ll.

This fixes PR33822. See https://bugs.llvm.org/show_bug.cgi?id=33822
for more context.

<rdar://problem/33357889>
https://bugs.llvm.org/show_bug.cgi?id=33822

Differential Revision: https://reviews.llvm.org/D35583

llvm-svn: 308398
diff --git a/llvm/test/Bitcode/DIGlobalVariableExpression.ll b/llvm/test/Bitcode/DIGlobalVariableExpression.ll
index 31c3fda..3cf0824 100644
--- a/llvm/test/Bitcode/DIGlobalVariableExpression.ll
+++ b/llvm/test/Bitcode/DIGlobalVariableExpression.ll
@@ -36,4 +36,4 @@
 !9 = !{!"clang version 4.0.0 (trunk 286129) (llvm/trunk 286128)"}
 !10 = distinct !DIGlobalVariable(name: "c", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true, expr: !DIExpression(DW_OP_constu, 23, DW_OP_stack_value))
 !11 = distinct !DIGlobalVariable(name: "h", scope: !1, file: !2, line: 2, type: !5, isLocal: false, isDefinition: true)
-!12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, line: 1, scope: !1, entity: !11)
+!12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, file: !2, line: 1, scope: !1, entity: !11)
diff --git a/llvm/test/Bitcode/upgrade-importedentity.ll b/llvm/test/Bitcode/upgrade-importedentity.ll
new file mode 100644
index 0000000..134ccf1
--- /dev/null
+++ b/llvm/test/Bitcode/upgrade-importedentity.ll
@@ -0,0 +1,15 @@
+; RUN:  llvm-dis < %s.bc | FileCheck %s
+; RUN:  verify-uselistorder < %s.bc
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!9, !10}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 308185) (llvm/trunk 308186)", emissionKind: FullDebug, imports: !3)
+!1 = !DIFile(filename: "using.ii", directory: "/")
+!3 = !{!4}
+!4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !5, entity: !8, line: 301)
+; CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !5)
+!5 = !DINamespace(name: "M", scope: null)
+!8 = !DINamespace(name: "N", scope: null)
+!9 = !{i32 2, !"Dwarf Version", i32 4}
+!10 = !{i32 2, !"Debug Info Version", i32 3}
diff --git a/llvm/test/Bitcode/upgrade-importedentity.ll.bc b/llvm/test/Bitcode/upgrade-importedentity.ll.bc
new file mode 100644
index 0000000..7fa833b
--- /dev/null
+++ b/llvm/test/Bitcode/upgrade-importedentity.ll.bc
Binary files differ