Basic types are language defined builtins. They are always defined at top most level.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117613 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 97639db..46d1447 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -179,6 +179,12 @@
 
 }
 
+/// getOrCreateMainFile - Get the file info for main compile unit.
+llvm::DIFile CGDebugInfo::getOrCreateMainFile() {
+  return DebugFactory.CreateFile(TheCU.getFilename(), TheCU.getDirectory(),
+                                 TheCU);
+}
+
 /// getLineNumber - Get line number for the location. If location is invalid
 /// then use current location.
 unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
@@ -340,10 +346,9 @@
   uint64_t Size = CGM.getContext().getTypeSize(BT);
   uint64_t Align = CGM.getContext().getTypeAlign(BT);
   uint64_t Offset = 0;
-  
   llvm::DIType DbgTy = 
-    DebugFactory.CreateBasicType(Unit, BTName,
-                                 Unit, 0, Size, Align,
+    DebugFactory.CreateBasicType(TheCU, BTName, getOrCreateMainFile(),
+                                 0, Size, Align,
                                  Offset, /*flags*/ 0, Encoding);
   return DbgTy;
 }
@@ -360,9 +365,8 @@
   uint64_t Offset = 0;
 
   llvm::DIType DbgTy = 
-    DebugFactory.CreateBasicType(Unit, "complex",
-                                 Unit, 0, Size, Align,
-                                 Offset, /*flags*/ 0, Encoding);
+    DebugFactory.CreateBasicType(TheCU, "complex", getOrCreateMainFile(), 
+                                 0, Size, Align, Offset, /*flags*/ 0, Encoding);
   return DbgTy;
 }