r199757 - Debug info: use the file a typedef is defined in as its decl_file instead

David Blaikie dblaikie at gmail.com
Tue Jan 21 10:48:35 PST 2014


On Tue, Jan 21, 2014 at 10:20 AM, Adrian Prantl <aprantl at apple.com> wrote:

> Author: adrian
> Date: Tue Jan 21 12:20:52 2014
> New Revision: 199757
>
> URL: http://llvm.org/viewvc/llvm-project?rev=199757&view=rev
> Log:
> Debug info: use the file a typedef is defined in as its decl_file instead
> of the current compilation unit.
> As a side effect this enables many more LTO uniquing opportunities.
>
> rdar://problem/15851206
>
> Added:
>     cfe/trunk/test/CodeGen/debug-info-typedef.c
>     cfe/trunk/test/CodeGen/debug-info-typedef.h
> Modified:
>     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=199757&r1=199756&r2=199757&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Jan 21 12:20:52 2014
> @@ -739,14 +739,16 @@ llvm::DIType CGDebugInfo::CreateType(con
>      return llvm::DIType();
>    // We don't set size information, but do specify where the typedef was
>    // declared.
> -  unsigned Line = getLineNumber(Ty->getDecl()->getLocation());
> +  SourceLocation Loc = Ty->getDecl()->getLocation();
> +  llvm::DIFile File = getOrCreateFile(Loc);
> +  unsigned Line = getLineNumber(Loc);
>    const TypedefNameDecl *TyDecl = Ty->getDecl();
>
>    llvm::DIDescriptor TypedefContext =
>      getContextDescriptor(cast<Decl>(Ty->getDecl()->getDeclContext()));
>
>    return
> -    DBuilder.createTypedef(Src, TyDecl->getName(), Unit, Line,
> TypedefContext);
> +    DBuilder.createTypedef(Src, TyDecl->getName(), File, Line,
> TypedefContext);
>  }
>
>  llvm::DIType CGDebugInfo::CreateType(const FunctionType *Ty,
>
> Added: cfe/trunk/test/CodeGen/debug-info-typedef.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-typedef.c?rev=199757&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/CodeGen/debug-info-typedef.c (added)
> +++ cfe/trunk/test/CodeGen/debug-info-typedef.c Tue Jan 21 12:20:52 2014
> @@ -0,0 +1,8 @@
> +// RUN: %clang_cc1 -emit-llvm -g -I%p %s -o - | FileCheck %s
> +// Test that the location of the typedef points to the header file.
> +#include "typedef.h"
>

Could you simplify this into one file with a #line directive, rather than
two files? (easier to read the test case that way, probably)


> +
> +MyType a;
> +
> +// CHECK: metadata ![[HEADER:[0-9]+]]} ; [ DW_TAG_typedef ] [MyType]
> [line 1, size 0, align 0, offset 0] [from int]
> +// CHECK: ![[HEADER]] = {{.*}}debug-info-typedef.h",
>
> Added: cfe/trunk/test/CodeGen/debug-info-typedef.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-typedef.h?rev=199757&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/CodeGen/debug-info-typedef.h (added)
> +++ cfe/trunk/test/CodeGen/debug-info-typedef.h Tue Jan 21 12:20:52 2014
> @@ -0,0 +1,2 @@
> +typedef int MyType;
> +
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140121/9a891f9f/attachment.html>


More information about the cfe-commits mailing list