aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-11-06 19:19:55 +0000
committerAnders Carlsson <andersca@mac.com>2009-11-06 19:19:55 +0000
commita031b35ba4da13e105a349493f5351014cfb3354 (patch)
treea68444a44dc364eabe0f59e7e0cba6908bf07b0e /lib/CodeGen/CGDebugInfo.cpp
parent30509a30a9a6ac9ee737e5cf39744a92170d7ea4 (diff)
Simplify the debug info code, handle lvalue references and template specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86277 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp44
1 files changed, 31 insertions, 13 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index e7e581b00a..8f4aeb400a 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -242,32 +242,37 @@ llvm::DIType CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DICompileUnit U
llvm::DIType CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty,
llvm::DICompileUnit Unit) {
- llvm::DIType EltTy = getOrCreateType(Ty->getPointeeType(), Unit);
-
- // Bit size, align and offset of the type.
- uint64_t Size = M->getContext().getTypeSize(Ty);
- uint64_t Align = M->getContext().getTypeAlign(Ty);
-
llvm::DIType DbgTy =
- DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type, Unit,
- "", llvm::DICompileUnit(),
- 0, Size, Align, 0, 0, EltTy);
+ CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty,
+ Ty->getPointeeType(), Unit);
TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = DbgTy.getNode();
return DbgTy;
}
llvm::DIType CGDebugInfo::CreateType(const PointerType *Ty,
llvm::DICompileUnit Unit) {
- llvm::DIType EltTy = getOrCreateType(Ty->getPointeeType(), Unit);
+ return CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty,
+ Ty->getPointeeType(), Unit);
+}
+
+llvm::DIType CGDebugInfo::CreatePointerLikeType(unsigned Tag,
+ const Type *Ty,
+ QualType PointeeTy,
+ llvm::DICompileUnit Unit) {
+ llvm::DIType EltTy = getOrCreateType(PointeeTy, Unit);
// Bit size, align and offset of the type.
- uint64_t Size = M->getContext().getTypeSize(Ty);
+
+ // Size is always the size of a pointer. We can't use getTypeSize here
+ // because that does not return the correct value for references.
+ uint64_t Size =
+ M->getContext().Target.getPointerWidth(PointeeTy.getAddressSpace());
uint64_t Align = M->getContext().getTypeAlign(Ty);
return
- DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type, Unit,
- "", llvm::DICompileUnit(),
+ DebugFactory.CreateDerivedType(Tag, Unit, "", llvm::DICompileUnit(),
0, Size, Align, 0, 0, EltTy);
+
}
llvm::DIType CGDebugInfo::CreateType(const BlockPointerType *Ty,
@@ -802,6 +807,11 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty,
return DbgTy;
}
+llvm::DIType CGDebugInfo::CreateType(const LValueReferenceType *Ty,
+ llvm::DICompileUnit Unit) {
+ return CreatePointerLikeType(llvm::dwarf::DW_TAG_reference_type,
+ Ty, Ty->getPointeeType(), Unit);
+}
/// getOrCreateType - Get the type from the cache or create a new
/// one if necessary.
@@ -890,6 +900,14 @@ llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty,
return CreateTypeNode(T->getReplacementType(), Unit);
}
+ case Type::TemplateSpecialization: {
+ const TemplateSpecializationType *T = cast<TemplateSpecializationType>(Ty);
+ return CreateTypeNode(T->desugar(), Unit);
+ }
+
+ case Type::LValueReference:
+ return CreateType(cast<LValueReferenceType>(Ty), Unit);
+
}
}