[cfe-commits] r91840 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Douglas Gregor
dgregor at apple.com
Mon Dec 21 12:18:31 PST 2009
Author: dgregor
Date: Mon Dec 21 14:18:30 2009
New Revision: 91840
URL: http://llvm.org/viewvc/llvm-project?rev=91840&view=rev
Log:
Improve on my previous fix for debug information. Rather than
recursing in CGDebugInfo::CreateTypeNode, teach
CanonicalizeTypeForDebugInfo---now called UnwrapTypeForDebugInfo---to
keep unwrapping the type until we hit something that can be
represented by debug information. Thanks to Anders for pointing this out!
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=91840&r1=91839&r2=91840&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Dec 21 14:18:30 2009
@@ -830,27 +830,43 @@
0, 0, 0, llvm::DIType(), Elements);
}
-static QualType CanonicalizeTypeForDebugInfo(QualType T) {
- switch (T->getTypeClass()) {
- default:
- return T;
- case Type::TemplateSpecialization:
- return cast<TemplateSpecializationType>(T)->desugar();
- case Type::TypeOfExpr: {
- TypeOfExprType *Ty = cast<TypeOfExprType>(T);
- return CanonicalizeTypeForDebugInfo(Ty->getUnderlyingExpr()->getType());
- }
- case Type::TypeOf:
- return cast<TypeOfType>(T)->getUnderlyingType();
- case Type::Decltype:
- return cast<DecltypeType>(T)->getUnderlyingType();
- case Type::QualifiedName:
- return cast<QualifiedNameType>(T)->getNamedType();
- case Type::SubstTemplateTypeParm:
- return cast<SubstTemplateTypeParmType>(T)->getReplacementType();
- case Type::Elaborated:
- return cast<ElaboratedType>(T)->getUnderlyingType();
- }
+static QualType UnwrapTypeForDebugInfo(QualType T) {
+ do {
+ QualType LastT = T;
+ switch (T->getTypeClass()) {
+ default:
+ return T;
+ case Type::TemplateSpecialization:
+ T = cast<TemplateSpecializationType>(T)->desugar();
+ break;
+ case Type::TypeOfExpr: {
+ TypeOfExprType *Ty = cast<TypeOfExprType>(T);
+ T = Ty->getUnderlyingExpr()->getType();
+ break;
+ }
+ case Type::TypeOf:
+ T = cast<TypeOfType>(T)->getUnderlyingType();
+ break;
+ case Type::Decltype:
+ T = cast<DecltypeType>(T)->getUnderlyingType();
+ break;
+ case Type::QualifiedName:
+ T = cast<QualifiedNameType>(T)->getNamedType();
+ break;
+ case Type::SubstTemplateTypeParm:
+ T = cast<SubstTemplateTypeParmType>(T)->getReplacementType();
+ break;
+ case Type::Elaborated:
+ T = cast<ElaboratedType>(T)->getUnderlyingType();
+ break;
+ }
+
+ assert(T != LastT && "Type unwrapping failed to unwrap!");
+ if (T == LastT)
+ return T;
+ } while (true);
+
+ return T;
}
/// getOrCreateType - Get the type from the cache or create a new
@@ -860,8 +876,8 @@
if (Ty.isNull())
return llvm::DIType();
- // Canonicalize the type.
- Ty = CanonicalizeTypeForDebugInfo(Ty);
+ // Unwrap the type as needed for debug information.
+ Ty = UnwrapTypeForDebugInfo(Ty);
// Check for existing entry.
std::map<void *, llvm::WeakVH>::iterator it =
@@ -932,44 +948,19 @@
return CreateType(cast<MemberPointerType>(Ty), Unit);
case Type::TemplateSpecialization:
- // DWARF can't represent template specialization types; instead,
- // we drill down to the canonical type, which will be a record type.
- return CreateType(cast<RecordType>(CGM.getContext().getCanonicalType(Ty)),
- Unit);
-
case Type::Elaborated:
- // DWARF can't represent elaborated type specifiers any differently from
- // the underlying type, so create a type node for the underlying type.
- return CreateTypeNode(cast<ElaboratedType>(Ty)->getUnderlyingType(), Unit);
-
case Type::QualifiedName:
- // DWARF can't represent qualified names any differently from the type
- // being named, so create a type node for that type.
- return CreateTypeNode(cast<QualifiedNameType>(Ty)->getNamedType(), Unit);
-
case Type::SubstTemplateTypeParm:
- // DWARF can't represent substituted template type parameter types,
- // so create a type node for the type that the template type parameter was
- // replaced with.
- return CreateTypeNode(cast<SubstTemplateTypeParmType>(Ty)
- ->getReplacementType(),
- Unit);
-
case Type::TypeOfExpr:
case Type::TypeOf:
- // FIXME: Implement!
- Diag = "typeof";
- break;
+ case Type::Decltype:
+ llvm_unreachable("type should have been unwrapped!");
+ return llvm::DIType();
case Type::RValueReference:
// FIXME: Implement!
Diag = "rvalue references";
break;
-
- case Type::Decltype:
- // FIXME: Implement!
- Diag = "decltype";
- break;
}
assert(Diag && "Fall through without a diagnostic?");
More information about the cfe-commits
mailing list