PR15956: Debug Info: Include the appropriate file location in types created due to using declarations
We might benefit from API refactoring here (why pass in a value that's
derived from another parameter?) but this is the immediate issue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181747 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 583b239..f6ad8f2 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -2178,8 +2178,10 @@
// we would otherwise do to get a type for a pointee. (forward declarations in
// limited debug info, full definitions (if the type definition is available)
// in unlimited debug info)
- if (const TypeDecl *RD = dyn_cast<TypeDecl>(D))
- return CreatePointeeType(QualType(RD->getTypeForDecl(), 0), llvm::DIFile());
+ if (const TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
+ llvm::DIFile DefUnit = getOrCreateFile(TD->getLocation());
+ return CreatePointeeType(CGM.getContext().getTypeDeclType(TD), DefUnit);
+ }
// Otherwise fall back to a fairly rudimentary cache of existing declarations.
// This doesn't handle providing declarations (for functions or variables) for
// entities without definitions in this TU, nor when the definition proceeds