summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp6
-rw-r--r--clang/test/CodeGen/debug-info-typedef.c8
-rw-r--r--clang/test/CodeGen/debug-info-typedef.h2
3 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index faf6fbba1a4..ff17a03dccd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -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,
diff --git a/clang/test/CodeGen/debug-info-typedef.c b/clang/test/CodeGen/debug-info-typedef.c
new file mode 100644
index 00000000000..c3adcf12aa8
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-typedef.c
@@ -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"
+
+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",
diff --git a/clang/test/CodeGen/debug-info-typedef.h b/clang/test/CodeGen/debug-info-typedef.h
new file mode 100644
index 00000000000..afdb9fb13ca
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-typedef.h
@@ -0,0 +1,2 @@
+typedef int MyType;
+
OpenPOWER on IntegriCloud