diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 197fcac150f8..8dc2ac8d1f05 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -173,28 +173,35 @@ llvm::DIType CGDebugInfo::CreateType(const ComplexType *Ty, Offset, /*flags*/ 0, Encoding); } -/// getOrCreateCVRType - Get the CVR qualified type from the cache or create +/// CreateCVRType - Get the qualified type from the cache or create /// a new one if necessary. -llvm::DIType CGDebugInfo::CreateCVRType(QualType Ty, llvm::DICompileUnit Unit) { +llvm::DIType CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DICompileUnit Unit) { + QualifierCollector Qc; + const Type *T = Qc.strip(Ty); + + // Ignore these qualifiers for now. + Qc.removeObjCGCAttr(); + Qc.removeAddressSpace(); + // We will create one Derived type for one qualifier and recurse to handle any // additional ones. - llvm::DIType FromTy; unsigned Tag; - if (Ty.isConstQualified()) { + if (Qc.hasConst()) { Tag = llvm::dwarf::DW_TAG_const_type; - Ty.removeConst(); - FromTy = getOrCreateType(Ty, Unit); - } else if (Ty.isVolatileQualified()) { + Qc.removeConst(); + } else if (Qc.hasVolatile()) { Tag = llvm::dwarf::DW_TAG_volatile_type; - Ty.removeVolatile(); - FromTy = getOrCreateType(Ty, Unit); - } else { - assert(Ty.isRestrictQualified() && "Unknown type qualifier for debug info"); + Qc.removeVolatile(); + } else if (Qc.hasRestrict()) { Tag = llvm::dwarf::DW_TAG_restrict_type; - Ty.removeRestrict(); - FromTy = getOrCreateType(Ty, Unit); + Qc.removeRestrict(); + } else { + assert(Qc.empty() && "Unknown type qualifier for debug info"); + return getOrCreateType(QualType(T, 0), Unit); } + llvm::DIType FromTy = getOrCreateType(Qc.apply(T), Unit); + // No need to fill in the Name, Line, Size, Alignment, Offset in case of // CVR derived types. return DebugFactory.CreateDerivedType(Tag, Unit, "", llvm::DICompileUnit(), @@ -770,9 +777,9 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, /// new one if necessary. llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DICompileUnit Unit) { - // Handle CVR qualifiers, which recursively handles what they refer to. - if (Ty.getCVRQualifiers()) - return CreateCVRType(Ty, Unit); + // Handle qualifiers, which recursively handles what they refer to. + if (Ty.hasQualifiers()) + return CreateQualifiedType(Ty, Unit); // Work out details of type. switch (Ty->getTypeClass()) { diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index b796b1e97ce1..dc256003f610 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -59,7 +59,7 @@ class CGDebugInfo { /// Helper functions for getOrCreateType. llvm::DIType CreateType(const BuiltinType *Ty, llvm::DICompileUnit U); llvm::DIType CreateType(const ComplexType *Ty, llvm::DICompileUnit U); - llvm::DIType CreateCVRType(QualType Ty, llvm::DICompileUnit U); + llvm::DIType CreateQualifiedType(QualType Ty, llvm::DICompileUnit U); llvm::DIType CreateType(const TypedefType *Ty, llvm::DICompileUnit U); llvm::DIType CreateType(const ObjCObjectPointerType *Ty, llvm::DICompileUnit Unit);