<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 21, 2014 at 10:20 AM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Tue Jan 21 12:20:52 2014<br>
New Revision: 199757<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=199757&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=199757&view=rev</a><br>
Log:<br>
Debug info: use the file a typedef is defined in as its decl_file instead<br>
of the current compilation unit.<br>
As a side effect this enables many more LTO uniquing opportunities.<br>
<br>
rdar://problem/15851206<br>
<br>
Added:<br>
    cfe/trunk/test/CodeGen/debug-info-typedef.c<br>
    cfe/trunk/test/CodeGen/debug-info-typedef.h<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=199757&r1=199756&r2=199757&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=199757&r1=199756&r2=199757&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Jan 21 12:20:52 2014<br>
@@ -739,14 +739,16 @@ llvm::DIType CGDebugInfo::CreateType(con<br>
     return llvm::DIType();<br>
   // We don't set size information, but do specify where the typedef was<br>
   // declared.<br>
-  unsigned Line = getLineNumber(Ty->getDecl()->getLocation());<br>
+  SourceLocation Loc = Ty->getDecl()->getLocation();<br>
+  llvm::DIFile File = getOrCreateFile(Loc);<br>
+  unsigned Line = getLineNumber(Loc);<br>
   const TypedefNameDecl *TyDecl = Ty->getDecl();<br>
<br>
   llvm::DIDescriptor TypedefContext =<br>
     getContextDescriptor(cast<Decl>(Ty->getDecl()->getDeclContext()));<br>
<br>
   return<br>
-    DBuilder.createTypedef(Src, TyDecl->getName(), Unit, Line, TypedefContext);<br>
+    DBuilder.createTypedef(Src, TyDecl->getName(), File, Line, TypedefContext);<br>
 }<br>
<br>
 llvm::DIType CGDebugInfo::CreateType(const FunctionType *Ty,<br>
<br>
Added: cfe/trunk/test/CodeGen/debug-info-typedef.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-typedef.c?rev=199757&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-typedef.c?rev=199757&view=auto</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGen/debug-info-typedef.c (added)<br>
+++ cfe/trunk/test/CodeGen/debug-info-typedef.c Tue Jan 21 12:20:52 2014<br>
@@ -0,0 +1,8 @@<br>
+// RUN: %clang_cc1 -emit-llvm -g -I%p %s -o - | FileCheck %s<br>
+// Test that the location of the typedef points to the header file.<br>
+#include "typedef.h"<br></blockquote><div><br></div><div>Could you simplify this into one file with a #line directive, rather than two files? (easier to read the test case that way, probably)</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+MyType a;<br>
+<br>
+// CHECK: metadata ![[HEADER:[0-9]+]]} ; [ DW_TAG_typedef ] [MyType] [line 1, size 0, align 0, offset 0] [from int]<br>
+// CHECK: ![[HEADER]] = {{.*}}debug-info-typedef.h",<br>
<br>
Added: cfe/trunk/test/CodeGen/debug-info-typedef.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-typedef.h?rev=199757&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-typedef.h?rev=199757&view=auto</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGen/debug-info-typedef.h (added)<br>
+++ cfe/trunk/test/CodeGen/debug-info-typedef.h Tue Jan 21 12:20:52 2014<br>
@@ -0,0 +1,2 @@<br>
+typedef int MyType;<br>
+<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>