on darwin<10, fallback to .weak_definition (PPC,X86)
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DIEHash.cpp
index 85761c6ec55d451ae72f9615e5a443c905ec1227..11cc454b33c31331f50ddcf9e6ec4122a4f0c96e 100644 (file)
@@ -13,9 +13,9 @@
 
 #define DEBUG_TYPE "dwarfdebug"
 
-#include "DIE.h"
 #include "DIEHash.h"
-#include "DwarfCompileUnit.h"
+
+#include "DIE.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Debug.h"
@@ -91,10 +91,12 @@ void DIEHash::addParentContext(const DIE &Parent) {
   // outermost such construct...
   SmallVector<const DIE *, 1> Parents;
   const DIE *Cur = &Parent;
-  while (Cur->getTag() != dwarf::DW_TAG_compile_unit) {
+  while (Cur->getParent()) {
     Parents.push_back(Cur);
     Cur = Cur->getParent();
   }
+  assert(Cur->getTag() == dwarf::DW_TAG_compile_unit ||
+         Cur->getTag() == dwarf::DW_TAG_type_unit);
 
   // Reverse iterate over our list to go from the outermost construct to the
   // innermost.