]> granicus.if.org Git - clang/commitdiff
Fix an infinite loop arising when trying to generate debug information
authorJohn McCall <rjmccall@apple.com>
Fri, 25 Sep 2009 01:40:47 +0000 (01:40 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 25 Sep 2009 01:40:47 +0000 (01:40 +0000)
for a ObjC class with an ivar of weak self type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82745 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h

index 197fcac150f8cbc6a650edb418a11d941010d98f..8dc2ac8d1f057622e6e4b7f962a060f1b7726b45 100644 (file)
@@ -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()) {
index b796b1e97ce154b5e5d7f3902c859e07aabb1bf4..dc256003f61060e65e8631f098d8b3149485ff37 100644 (file)
@@ -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);