forked from OSchip/llvm-project
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. This reapplies r199757 with a better testcase. llvm-svn: 199760
This commit is contained in:
parent
a88d7abeb1
commit
3eff225a44
|
@ -739,14 +739,16 @@ llvm::DIType CGDebugInfo::CreateType(const TypedefType *Ty, llvm::DIFile Unit) {
|
|||
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,
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// RUN: %clang_cc1 -emit-llvm -g -I%p %s -o - | FileCheck %s
|
||||
// Test that the location of the typedef points to the header file.
|
||||
#line 1 "a.c"
|
||||
#line 2 "b.h"
|
||||
typedef int MyType;
|
||||
#line 2 "a.c"
|
||||
|
||||
MyType a;
|
||||
|
||||
// CHECK: metadata ![[HEADER:[0-9]+]], null, metadata !"MyType"{{.*}} ; [ DW_TAG_typedef ] [MyType] [line 2, size 0, align 0, offset 0] [from int]
|
||||
// CHECK: ![[HEADER]] = metadata !{metadata !"b.h",
|
Loading…
Reference in New Issue