When computing the size of a base type be conservative if the type
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfUnit.cpp
index 581fe22648295e6a97d150c4506cfb6e6e279cf2..c743cbbb45d43ebd072e1a50851f173701c83d45 100644 (file)
@@ -751,8 +751,9 @@ static uint64_t getBaseTypeSize(DwarfDebug *DD, DIDerivedType Ty) {
 
   DIType BaseType = DD->resolve(Ty.getTypeDerivedFrom());
 
-  // If this type is not derived from any type then take conservative approach.
-  if (!BaseType.isValid())
+  // If this type is not derived from any type or the type is a declaration then
+  // take conservative approach.
+  if (!BaseType.isValid() || BaseType.isForwardDecl())
     return Ty.getSizeInBits();
 
   // If this is a derived type, go ahead and get the base type, unless it's a