Move the computation of whether a DWARF compile unit
authorJason Molenda <jmolenda@apple.com>
Fri, 31 Jul 2015 05:47:00 +0000 (05:47 +0000)
committerJason Molenda <jmolenda@apple.com>
Fri, 31 Jul 2015 05:47:00 +0000 (05:47 +0000)
is optimized into DWARFCompileUnit, where it should have
been.  Next I'll need to call this from another section
of code for DWARF-in-.o-file behavior correctness.

llvm-svn: 243736

lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

index 6093310..98d4c1d 100644 (file)
@@ -52,7 +52,8 @@ DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF* dwarf2Data) :
     m_producer_version_minor (0),
     m_producer_version_update (0),
     m_language_type (eLanguageTypeUnknown),
-    m_is_dwarf64    (false)
+    m_is_dwarf64    (false),
+    m_is_optimized  (eLazyBoolCalculate)
 {
 }
 
@@ -71,6 +72,7 @@ DWARFCompileUnit::Clear()
     m_producer      = eProducerInvalid;
     m_language_type = eLanguageTypeUnknown;
     m_is_dwarf64    = false;
+    m_is_optimized  = eLazyBoolCalculate;
 }
 
 bool
@@ -1108,3 +1110,27 @@ DWARFCompileUnit::IsDWARF64() const
     return m_is_dwarf64;
 }
 
+bool
+DWARFCompileUnit::GetIsOptimized ()
+{
+    if (m_is_optimized == eLazyBoolCalculate)
+    {
+        const DWARFDebugInfoEntry *die = GetCompileUnitDIEOnly();
+        if (die)
+        {
+            m_is_optimized = eLazyBoolNo;
+            if (die->GetAttributeValueAsUnsigned (m_dwarf2Data, this, DW_AT_APPLE_optimized, 0) == 1)
+            {
+                m_is_optimized = eLazyBoolYes;
+            }
+        }
+    }
+    if (m_is_optimized == eLazyBoolYes)
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
index 93c8df8..9fcc550 100644 (file)
@@ -196,6 +196,9 @@ public:
     bool
     IsDWARF64() const;
 
+    bool
+    GetIsOptimized ();
+
 protected:
     SymbolFileDWARF*    m_dwarf2Data;
     const DWARFAbbreviationDeclarationSet *m_abbrevs;
@@ -213,6 +216,7 @@ protected:
     uint32_t            m_producer_version_update;
     lldb::LanguageType  m_language_type;
     bool                m_is_dwarf64;
+    lldb_private::LazyBool m_is_optimized;
     
     void
     ParseProducerInfo ();
index 297f9ba..3f2e1d8 100644 (file)
@@ -1100,11 +1100,7 @@ SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx)
 
                         LanguageType cu_language = DWARFCompileUnit::LanguageTypeFromDWARF(cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0));
 
-                        bool is_optimized = false;
-                        if (cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_APPLE_optimized, 0) == 1)
-                        {
-                            is_optimized = true;
-                        }
+                        bool is_optimized = dwarf_cu->GetIsOptimized ();
                         cu_sp.reset(new CompileUnit (module_sp,
                                                      dwarf_cu,
                                                      cu_file_spec,