[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code

Kate Stone via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016


Modified: lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp (original)
+++ lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp Tue Sep  6 15:57:50 2016
@@ -43,1076 +43,836 @@ using namespace lldb_private;
 // Anonymous namespace
 // -----------------------------------------------------------------------------
 
-namespace sddarwinlog_private
-{
-    const uint64_t NANOS_PER_MICRO = 1000;
-    const uint64_t NANOS_PER_MILLI = NANOS_PER_MICRO * 1000;
-    const uint64_t NANOS_PER_SECOND = NANOS_PER_MILLI * 1000;
-    const uint64_t NANOS_PER_MINUTE = NANOS_PER_SECOND * 60;
-    const uint64_t NANOS_PER_HOUR = NANOS_PER_MINUTE * 60;
-
-    static bool DEFAULT_FILTER_FALLTHROUGH_ACCEPTS = true;
-
-    //------------------------------------------------------------------
-    /// Global, sticky enable switch.  If true, the user has explicitly
-    /// run the enable command.  When a process launches or is attached to,
-    /// we will enable DarwinLog if either the settings for auto-enable is
-    /// on, or if the user had explicitly run enable at some point prior
-    /// to the launch/attach.
-    //------------------------------------------------------------------
-    static bool s_is_explicitly_enabled;
-
-    class EnableOptions;
-    using EnableOptionsSP = std::shared_ptr<EnableOptions>;
-
-    using OptionsMap = std::map<DebuggerWP, EnableOptionsSP,
-                                std::owner_less<DebuggerWP>>;
-
-    static OptionsMap&
-    GetGlobalOptionsMap()
-    {
-        static OptionsMap s_options_map;
-        return s_options_map;
-    }
-
-    static std::mutex&
-    GetGlobalOptionsMapLock()
-    {
-        static std::mutex s_options_map_lock;
-        return s_options_map_lock;
-    }
-
-    EnableOptionsSP
-    GetGlobalEnableOptions(const DebuggerSP &debugger_sp)
-    {
-        if (!debugger_sp)
-            return EnableOptionsSP();
-
-        std::lock_guard<std::mutex> locker(GetGlobalOptionsMapLock());
-        OptionsMap &options_map = GetGlobalOptionsMap();
-        DebuggerWP debugger_wp(debugger_sp);
-        auto find_it = options_map.find(debugger_wp);
-        if (find_it != options_map.end())
-            return find_it->second;
-        else
-            return EnableOptionsSP();
-    }
-
-    void
-    SetGlobalEnableOptions(const DebuggerSP &debugger_sp,
-                           const EnableOptionsSP &options_sp)
-    {
-        std::lock_guard<std::mutex> locker(GetGlobalOptionsMapLock());
-        OptionsMap &options_map = GetGlobalOptionsMap();
-        DebuggerWP debugger_wp(debugger_sp);
-        auto find_it = options_map.find(debugger_wp);
-        if (find_it != options_map.end())
-            find_it->second = options_sp;
-        else
-            options_map.insert(std::make_pair(debugger_wp, options_sp));
-    }
+namespace sddarwinlog_private {
+const uint64_t NANOS_PER_MICRO = 1000;
+const uint64_t NANOS_PER_MILLI = NANOS_PER_MICRO * 1000;
+const uint64_t NANOS_PER_SECOND = NANOS_PER_MILLI * 1000;
+const uint64_t NANOS_PER_MINUTE = NANOS_PER_SECOND * 60;
+const uint64_t NANOS_PER_HOUR = NANOS_PER_MINUTE * 60;
+
+static bool DEFAULT_FILTER_FALLTHROUGH_ACCEPTS = true;
+
+//------------------------------------------------------------------
+/// Global, sticky enable switch.  If true, the user has explicitly
+/// run the enable command.  When a process launches or is attached to,
+/// we will enable DarwinLog if either the settings for auto-enable is
+/// on, or if the user had explicitly run enable at some point prior
+/// to the launch/attach.
+//------------------------------------------------------------------
+static bool s_is_explicitly_enabled;
+
+class EnableOptions;
+using EnableOptionsSP = std::shared_ptr<EnableOptions>;
+
+using OptionsMap =
+    std::map<DebuggerWP, EnableOptionsSP, std::owner_less<DebuggerWP>>;
+
+static OptionsMap &GetGlobalOptionsMap() {
+  static OptionsMap s_options_map;
+  return s_options_map;
+}
+
+static std::mutex &GetGlobalOptionsMapLock() {
+  static std::mutex s_options_map_lock;
+  return s_options_map_lock;
+}
+
+EnableOptionsSP GetGlobalEnableOptions(const DebuggerSP &debugger_sp) {
+  if (!debugger_sp)
+    return EnableOptionsSP();
+
+  std::lock_guard<std::mutex> locker(GetGlobalOptionsMapLock());
+  OptionsMap &options_map = GetGlobalOptionsMap();
+  DebuggerWP debugger_wp(debugger_sp);
+  auto find_it = options_map.find(debugger_wp);
+  if (find_it != options_map.end())
+    return find_it->second;
+  else
+    return EnableOptionsSP();
+}
+
+void SetGlobalEnableOptions(const DebuggerSP &debugger_sp,
+                            const EnableOptionsSP &options_sp) {
+  std::lock_guard<std::mutex> locker(GetGlobalOptionsMapLock());
+  OptionsMap &options_map = GetGlobalOptionsMap();
+  DebuggerWP debugger_wp(debugger_sp);
+  auto find_it = options_map.find(debugger_wp);
+  if (find_it != options_map.end())
+    find_it->second = options_sp;
+  else
+    options_map.insert(std::make_pair(debugger_wp, options_sp));
+}
 
 #pragma mark -
 #pragma mark Settings Handling
 
-    //------------------------------------------------------------------
-    /// Code to handle the StructuredDataDarwinLog settings
-    //------------------------------------------------------------------
-
-    static PropertyDefinition
-    g_properties[] =
-    {
-        {
-            "enable-on-startup" ,        // name
-            OptionValue::eTypeBoolean, // type
-            true,                      // global
-            false,                     // default uint value
-            nullptr,                   // default cstring value
-            nullptr,                   // enum values
-            "Enable Darwin os_log collection when debugged process is launched "
-            "or attached."             // description
-        },
-        {
-            "auto-enable-options" ,    // name
-            OptionValue::eTypeString,  // type
-            true,                      // global
-            0,                         // default uint value
-            "",                        // default cstring value
-            nullptr,                   // enum values
-            "Specify the options to 'plugin structured-data darwin-log enable' "
-            "that should be applied when automatically enabling logging on "
-            "startup/attach."          // description
-        },
-        // Last entry sentinel.
-        {
-            nullptr,
-            OptionValue::eTypeInvalid,
-            false,
-            0  ,
-            nullptr,
-            nullptr,
-            nullptr
-        }
-    };
+//------------------------------------------------------------------
+/// Code to handle the StructuredDataDarwinLog settings
+//------------------------------------------------------------------
+
+static PropertyDefinition g_properties[] = {
+    {
+        "enable-on-startup",       // name
+        OptionValue::eTypeBoolean, // type
+        true,                      // global
+        false,                     // default uint value
+        nullptr,                   // default cstring value
+        nullptr,                   // enum values
+        "Enable Darwin os_log collection when debugged process is launched "
+        "or attached." // description
+    },
+    {
+        "auto-enable-options",    // name
+        OptionValue::eTypeString, // type
+        true,                     // global
+        0,                        // default uint value
+        "",                       // default cstring value
+        nullptr,                  // enum values
+        "Specify the options to 'plugin structured-data darwin-log enable' "
+        "that should be applied when automatically enabling logging on "
+        "startup/attach." // description
+    },
+    // Last entry sentinel.
+    {nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr}};
+
+enum { ePropertyEnableOnStartup = 0, ePropertyAutoEnableOptions = 1 };
+
+class StructuredDataDarwinLogProperties : public Properties {
+public:
+  static ConstString &GetSettingName() {
+    static ConstString g_setting_name("darwin-log");
+    return g_setting_name;
+  }
+
+  StructuredDataDarwinLogProperties() : Properties() {
+    m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+    m_collection_sp->Initialize(g_properties);
+  }
+
+  virtual ~StructuredDataDarwinLogProperties() {}
+
+  bool GetEnableOnStartup() const {
+    const uint32_t idx = ePropertyEnableOnStartup;
+    return m_collection_sp->GetPropertyAtIndexAsBoolean(
+        nullptr, idx, g_properties[idx].default_uint_value != 0);
+  }
+
+  const char *GetAutoEnableOptions() const {
+    const uint32_t idx = ePropertyAutoEnableOptions;
+    return m_collection_sp->GetPropertyAtIndexAsString(
+        nullptr, idx, g_properties[idx].default_cstr_value);
+  }
 
-    enum {
-        ePropertyEnableOnStartup = 0,
-        ePropertyAutoEnableOptions = 1
-    };
+  const char *GetLoggingModuleName() const { return "libsystem_trace.dylib"; }
+};
 
-    class StructuredDataDarwinLogProperties : public Properties
-    {
-    public:
-
-        static ConstString &
-        GetSettingName ()
-        {
-            static ConstString g_setting_name("darwin-log");
-            return g_setting_name;
-        }
-
-        StructuredDataDarwinLogProperties() :
-        Properties ()
-        {
-            m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
-            m_collection_sp->Initialize(g_properties);
-        }
-
-        virtual
-        ~StructuredDataDarwinLogProperties()
-        {
-        }
-
-        bool
-        GetEnableOnStartup() const
-        {
-            const uint32_t idx = ePropertyEnableOnStartup;
-            return m_collection_sp->GetPropertyAtIndexAsBoolean(nullptr, idx,
-                                     g_properties[idx].default_uint_value != 0);
-        }
-
-        const char*
-        GetAutoEnableOptions() const
-        {
-            const uint32_t idx = ePropertyAutoEnableOptions;
-            return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx,
-                                          g_properties[idx].default_cstr_value);
-        }
-
-        const char*
-        GetLoggingModuleName() const
-        {
-            return "libsystem_trace.dylib";
-        }
-    };
-
-    using StructuredDataDarwinLogPropertiesSP =
+using StructuredDataDarwinLogPropertiesSP =
     std::shared_ptr<StructuredDataDarwinLogProperties>;
 
-    static const StructuredDataDarwinLogPropertiesSP&
-    GetGlobalProperties()
-    {
-        static StructuredDataDarwinLogPropertiesSP g_settings_sp;
-        if (!g_settings_sp)
-            g_settings_sp.reset(new StructuredDataDarwinLogProperties());
-        return g_settings_sp;
-    }
+static const StructuredDataDarwinLogPropertiesSP &GetGlobalProperties() {
+  static StructuredDataDarwinLogPropertiesSP g_settings_sp;
+  if (!g_settings_sp)
+    g_settings_sp.reset(new StructuredDataDarwinLogProperties());
+  return g_settings_sp;
+}
+
+const char *const s_filter_attributes[] = {
+    "activity",       // current activity
+    "activity-chain", // entire activity chain, each level separated by ':'
+    "category",       // category of the log message
+    "message",        // message contents, fully expanded
+    "subsystem"       // subsystem of the log message
+
+    // Consider impelmenting this action as it would be cheaper to filter.
+    // "message" requires always formatting the message, which is a waste
+    // of cycles if it ends up being rejected.
+    // "format",      // format string used to format message text
+};
+
+static const ConstString &GetDarwinLogTypeName() {
+  static const ConstString s_key_name("DarwinLog");
+  return s_key_name;
+}
+
+static const ConstString &GetLogEventType() {
+  static const ConstString s_event_type("log");
+  return s_event_type;
+}
+
+class FilterRule;
+using FilterRuleSP = std::shared_ptr<FilterRule>;
+
+class FilterRule {
+public:
+  virtual ~FilterRule() {}
+
+  using OperationCreationFunc =
+      std::function<FilterRuleSP(bool accept, size_t attribute_index,
+                                 const std::string &op_arg, Error &error)>;
+
+  static void RegisterOperation(const ConstString &operation,
+                                const OperationCreationFunc &creation_func) {
+    GetCreationFuncMap().insert(std::make_pair(operation, creation_func));
+  }
+
+  static FilterRuleSP CreateRule(bool match_accepts, size_t attribute,
+                                 const ConstString &operation,
+                                 const std::string &op_arg, Error &error) {
+    // Find the creation func for this type of filter rule.
+    auto map = GetCreationFuncMap();
+    auto find_it = map.find(operation);
+    if (find_it == map.end()) {
+      error.SetErrorStringWithFormat("unknown filter operation \""
+                                     "%s\"",
+                                     operation.GetCString());
+      return FilterRuleSP();
+    }
+
+    return find_it->second(match_accepts, attribute, op_arg, error);
+  }
+
+  StructuredData::ObjectSP Serialize() const {
+    StructuredData::Dictionary *dict_p = new StructuredData::Dictionary();
+
+    // Indicate whether this is an accept or reject rule.
+    dict_p->AddBooleanItem("accept", m_accept);
+
+    // Indicate which attribute of the message this filter references.
+    // This can drop into the rule-specific DoSerialization if we get
+    // to the point where not all FilterRule derived classes work on
+    // an attribute.  (e.g. logical and/or and other compound
+    // operations).
+    dict_p->AddStringItem("attribute", s_filter_attributes[m_attribute_index]);
+
+    // Indicate the type of the rule.
+    dict_p->AddStringItem("type", GetOperationType().GetCString());
+
+    // Let the rule add its own specific details here.
+    DoSerialization(*dict_p);
+
+    return StructuredData::ObjectSP(dict_p);
+  }
+
+  virtual void Dump(Stream &stream) const = 0;
+
+  const ConstString &GetOperationType() const { return m_operation; }
+
+protected:
+  FilterRule(bool accept, size_t attribute_index, const ConstString &operation)
+      : m_accept(accept), m_attribute_index(attribute_index),
+        m_operation(operation) {}
+
+  virtual void DoSerialization(StructuredData::Dictionary &dict) const = 0;
+
+  bool GetMatchAccepts() const { return m_accept; }
+
+  const char *GetFilterAttribute() const {
+    return s_filter_attributes[m_attribute_index];
+  }
+
+private:
+  using CreationFuncMap = std::map<ConstString, OperationCreationFunc>;
+
+  static CreationFuncMap &GetCreationFuncMap() {
+    static CreationFuncMap s_map;
+    return s_map;
+  }
+
+  const bool m_accept;
+  const size_t m_attribute_index;
+  const ConstString m_operation;
+};
+
+using FilterRules = std::vector<FilterRuleSP>;
+
+class RegexFilterRule : public FilterRule {
+public:
+  static void RegisterOperation() {
+    FilterRule::RegisterOperation(StaticGetOperation(), CreateOperation);
+  }
+
+  void Dump(Stream &stream) const override {
+    stream.Printf("%s %s regex %s", GetMatchAccepts() ? "accept" : "reject",
+                  GetFilterAttribute(), m_regex_text.c_str());
+  }
+
+protected:
+  void DoSerialization(StructuredData::Dictionary &dict) const override {
+    dict.AddStringItem("regex", m_regex_text);
+  }
+
+private:
+  static FilterRuleSP CreateOperation(bool accept, size_t attribute_index,
+                                      const std::string &op_arg, Error &error) {
+    // We treat the op_arg as a regex.  Validate it.
+    if (op_arg.empty()) {
+      error.SetErrorString("regex filter type requires a regex "
+                           "argument");
+      return FilterRuleSP();
+    }
+
+    // Instantiate the regex so we can report any errors.
+    auto regex = RegularExpression(op_arg.c_str());
+    if (!regex.IsValid()) {
+      char error_text[256];
+      error_text[0] = '\0';
+      regex.GetErrorAsCString(error_text, sizeof(error_text));
+      error.SetErrorString(error_text);
+      return FilterRuleSP();
+    }
+
+    // We passed all our checks, this appears fine.
+    error.Clear();
+    return FilterRuleSP(new RegexFilterRule(accept, attribute_index, op_arg));
+  }
+
+  static const ConstString &StaticGetOperation() {
+    static ConstString s_operation("regex");
+    return s_operation;
+  }
+
+  RegexFilterRule(bool accept, size_t attribute_index,
+                  const std::string &regex_text)
+      : FilterRule(accept, attribute_index, StaticGetOperation()),
+        m_regex_text(regex_text) {}
+
+  const std::string m_regex_text;
+};
+
+class ExactMatchFilterRule : public FilterRule {
+public:
+  static void RegisterOperation() {
+    FilterRule::RegisterOperation(StaticGetOperation(), CreateOperation);
+  }
+
+  void Dump(Stream &stream) const override {
+    stream.Printf("%s %s match %s", GetMatchAccepts() ? "accept" : "reject",
+                  GetFilterAttribute(), m_match_text.c_str());
+  }
+
+protected:
+  void DoSerialization(StructuredData::Dictionary &dict) const override {
+    dict.AddStringItem("exact_text", m_match_text);
+  }
+
+private:
+  static FilterRuleSP CreateOperation(bool accept, size_t attribute_index,
+                                      const std::string &op_arg, Error &error) {
+    if (op_arg.empty()) {
+      error.SetErrorString("exact match filter type requires an "
+                           "argument containing the text that must "
+                           "match the specified message attribute.");
+      return FilterRuleSP();
+    }
+
+    error.Clear();
+    return FilterRuleSP(
+        new ExactMatchFilterRule(accept, attribute_index, op_arg));
+  }
+
+  static const ConstString &StaticGetOperation() {
+    static ConstString s_operation("match");
+    return s_operation;
+  }
+
+  ExactMatchFilterRule(bool accept, size_t attribute_index,
+                       const std::string &match_text)
+      : FilterRule(accept, attribute_index, StaticGetOperation()),
+        m_match_text(match_text) {}
+
+  const std::string m_match_text;
+};
+
+static void RegisterFilterOperations() {
+  ExactMatchFilterRule::RegisterOperation();
+  RegexFilterRule::RegisterOperation();
+}
+
+// =========================================================================
+// Commands
+// =========================================================================
+
+// -------------------------------------------------------------------------
+/// Provides the main on-off switch for enabling darwin logging.
+///
+/// It is valid to run the enable command when logging is already enabled.
+/// This resets the logging with whatever settings are currently set.
+// -------------------------------------------------------------------------
+class EnableOptions : public Options {
+public:
+  EnableOptions()
+      : Options(), m_include_debug_level(false), m_include_info_level(false),
+        m_include_any_process(false),
+        m_filter_fall_through_accepts(DEFAULT_FILTER_FALLTHROUGH_ACCEPTS),
+        m_echo_to_stderr(false), m_display_timestamp_relative(false),
+        m_display_subsystem(false), m_display_category(false),
+        m_display_activity_chain(false), m_broadcast_events(true),
+        m_live_stream(true), m_filter_rules() {}
+
+  void OptionParsingStarting(ExecutionContext *execution_context) override {
+    m_include_debug_level = false;
+    m_include_info_level = false;
+    m_include_any_process = false;
+    m_filter_fall_through_accepts = DEFAULT_FILTER_FALLTHROUGH_ACCEPTS;
+    m_echo_to_stderr = false;
+    m_display_timestamp_relative = false;
+    m_display_subsystem = false;
+    m_display_category = false;
+    m_display_activity_chain = false;
+    m_broadcast_events = true;
+    m_live_stream = true;
+    m_filter_rules.clear();
+  }
 
-    const char *const s_filter_attributes[] =
-    {
-        "activity",       // current activity
-        "activity-chain", // entire activity chain, each level separated by ':'
-        "category",       // category of the log message
-        "message",        // message contents, fully expanded
-        "subsystem"       // subsystem of the log message
-
-        // Consider impelmenting this action as it would be cheaper to filter.
-        // "message" requires always formatting the message, which is a waste
-        // of cycles if it ends up being rejected.
-        // "format",      // format string used to format message text
-    };
+  Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+                       ExecutionContext *execution_context) override {
+    Error error;
 
-    static const ConstString&
-    GetDarwinLogTypeName()
-    {
-        static const ConstString s_key_name("DarwinLog");
-        return s_key_name;
-    }
+    const int short_option = m_getopt_table[option_idx].val;
+    switch (short_option) {
+    case 'a':
+      m_include_any_process = true;
+      break;
+
+    case 'A':
+      m_display_timestamp_relative = true;
+      m_display_category = true;
+      m_display_subsystem = true;
+      m_display_activity_chain = true;
+      break;
+
+    case 'b':
+      m_broadcast_events = Args::StringToBoolean(option_arg, true, nullptr);
+      break;
+
+    case 'c':
+      m_display_category = true;
+      break;
+
+    case 'C':
+      m_display_activity_chain = true;
+      break;
+
+    case 'd':
+      m_include_debug_level = true;
+      break;
+
+    case 'e':
+      m_echo_to_stderr = Args::StringToBoolean(option_arg, false, nullptr);
+      break;
+
+    case 'f':
+      return ParseFilterRule(option_arg);
+
+    case 'i':
+      m_include_info_level = true;
+      break;
+
+    case 'l':
+      m_live_stream = Args::StringToBoolean(option_arg, false, nullptr);
+      break;
+
+    case 'n':
+      m_filter_fall_through_accepts =
+          Args::StringToBoolean(option_arg, true, nullptr);
+      break;
+
+    case 'r':
+      m_display_timestamp_relative = true;
+      break;
+
+    case 's':
+      m_display_subsystem = true;
+      break;
 
-    static const ConstString&
-    GetLogEventType()
-    {
-        static const ConstString s_event_type("log");
-        return s_event_type;
+    default:
+      error.SetErrorStringWithFormat("unsupported option '%c'", short_option);
     }
+    return error;
+  }
 
-    class FilterRule;
-    using FilterRuleSP = std::shared_ptr<FilterRule>;
-
-    class FilterRule
-    {
-    public:
-
-        virtual
-        ~FilterRule()
-        {
-        }
-
-        using OperationCreationFunc =
-            std::function<FilterRuleSP(bool accept,
-                                       size_t attribute_index,
-                                       const std::string &op_arg,
-                                       Error &error)>;
-
-        static void
-        RegisterOperation(const ConstString &operation,
-                          const OperationCreationFunc &creation_func)
-        {
-            GetCreationFuncMap().insert(std::make_pair(operation,
-                                                       creation_func));
-        }
-
-        static
-        FilterRuleSP CreateRule(bool match_accepts, size_t attribute,
-                                const ConstString &operation,
-                                const std::string &op_arg, Error &error)
-        {
-            // Find the creation func for this type of filter rule.
-            auto map = GetCreationFuncMap();
-            auto find_it = map.find(operation);
-            if (find_it == map.end())
-            {
-                error.SetErrorStringWithFormat("unknown filter operation \""
-                                               "%s\"",
-                                               operation.GetCString());
-                return FilterRuleSP();
-            }
-
-            return find_it->second(match_accepts, attribute, op_arg, error);
-        }
-
-        StructuredData::ObjectSP Serialize() const
-        {
-            StructuredData::Dictionary *dict_p =
-                new StructuredData::Dictionary();
-
-            // Indicate whether this is an accept or reject rule.
-            dict_p->AddBooleanItem("accept", m_accept);
-
-            // Indicate which attribute of the message this filter references.
-            // This can drop into the rule-specific DoSerialization if we get
-            // to the point where not all FilterRule derived classes work on
-            // an attribute.  (e.g. logical and/or and other compound
-            // operations).
-            dict_p->AddStringItem("attribute",
-                                  s_filter_attributes[m_attribute_index]);
-
-            // Indicate the type of the rule.
-            dict_p->AddStringItem("type", GetOperationType().GetCString());
-
-            // Let the rule add its own specific details here.
-            DoSerialization(*dict_p);
-
-            return StructuredData::ObjectSP(dict_p);
-        }
-
-        virtual void
-        Dump(Stream &stream) const = 0;
-
-        const ConstString&
-        GetOperationType() const
-        {
-            return m_operation;
-        }
-
-    protected:
-
-        FilterRule(bool accept, size_t attribute_index,
-                   const ConstString &operation) :
-            m_accept(accept),
-            m_attribute_index(attribute_index),
-            m_operation(operation)
-        {
-        }
-
-        virtual void
-        DoSerialization(StructuredData::Dictionary &dict) const = 0;
-
-        bool
-        GetMatchAccepts() const
-        {
-            return m_accept;
-        }
-
-        const char*
-        GetFilterAttribute() const
-        {
-            return s_filter_attributes[m_attribute_index];
-        }
-
-    private:
-
-        using CreationFuncMap = std::map<ConstString, OperationCreationFunc>;
-
-        static CreationFuncMap&
-        GetCreationFuncMap()
-        {
-            static CreationFuncMap s_map;
-            return s_map;
-        }
-
-        const bool m_accept;
-        const size_t m_attribute_index;
-        const ConstString m_operation;
-
-    };
-
-    using FilterRules = std::vector<FilterRuleSP>;
-
-    class RegexFilterRule : public FilterRule
-    {
-    public:
-
-        static void
-        RegisterOperation()
-        {
-            FilterRule::RegisterOperation(StaticGetOperation(),
-                                          CreateOperation);
-        }
-
-        void
-        Dump(Stream &stream) const override
-        {
-            stream.Printf("%s %s regex %s",
-                          GetMatchAccepts() ? "accept" : "reject",
-                          GetFilterAttribute(), m_regex_text.c_str());
-        }
-
-    protected:
-
-        void
-        DoSerialization(StructuredData::Dictionary &dict) const override
-        {
-            dict.AddStringItem("regex", m_regex_text);
-        }
-
-    private:
-
-        static FilterRuleSP
-        CreateOperation(bool accept, size_t attribute_index,
-                        const std::string &op_arg, Error &error)
-        {
-            // We treat the op_arg as a regex.  Validate it.
-            if (op_arg.empty())
-            {
-                error.SetErrorString("regex filter type requires a regex "
-                                     "argument");
-                return FilterRuleSP();
-            }
-
-            // Instantiate the regex so we can report any errors.
-            auto regex = RegularExpression(op_arg.c_str());
-            if (!regex.IsValid())
-            {
-                char error_text[256];
-                error_text[0] = '\0';
-                regex.GetErrorAsCString(error_text, sizeof(error_text));
-                error.SetErrorString(error_text);
-                return FilterRuleSP();
-            }
-
-            // We passed all our checks, this appears fine.
-            error.Clear();
-            return FilterRuleSP(new RegexFilterRule(accept, attribute_index,
-                                                    op_arg));
-        }
-
-        static const ConstString &
-        StaticGetOperation()
-        {
-            static ConstString s_operation("regex");
-            return s_operation;
-        }
-
-        RegexFilterRule(bool accept, size_t attribute_index,
-                        const std::string &regex_text) :
-            FilterRule(accept, attribute_index, StaticGetOperation()),
-            m_regex_text(regex_text)
-        {
-        }
-
-        const std::string m_regex_text;
-    };
-
-    class ExactMatchFilterRule : public FilterRule
-    {
-    public:
-
-        static void
-        RegisterOperation()
-        {
-            FilterRule::RegisterOperation(StaticGetOperation(),
-                                          CreateOperation);
-        }
-
-        void
-        Dump(Stream &stream) const override
-        {
-            stream.Printf("%s %s match %s",
-                          GetMatchAccepts() ? "accept" : "reject",
-                          GetFilterAttribute(), m_match_text.c_str());
-        }
-
-    protected:
-
-        void
-        DoSerialization(StructuredData::Dictionary &dict) const override
-        {
-            dict.AddStringItem("exact_text", m_match_text);
-        }
+  const OptionDefinition *GetDefinitions() override {
+    return g_enable_option_table;
+  }
+
+  StructuredData::DictionarySP BuildConfigurationData(bool enabled) {
+    StructuredData::DictionarySP config_sp(new StructuredData::Dictionary());
+
+    // Set the basic enabled state.
+    config_sp->AddBooleanItem("enabled", enabled);
+
+    // If we're disabled, there's nothing more to add.
+    if (!enabled)
+      return config_sp;
+
+    // Handle source stream flags.
+    auto source_flags_sp =
+        StructuredData::DictionarySP(new StructuredData::Dictionary());
+    config_sp->AddItem("source-flags", source_flags_sp);
+
+    source_flags_sp->AddBooleanItem("any-process", m_include_any_process);
+    source_flags_sp->AddBooleanItem("debug-level", m_include_debug_level);
+    // The debug-level flag, if set, implies info-level.
+    source_flags_sp->AddBooleanItem("info-level", m_include_info_level ||
+                                                      m_include_debug_level);
+    source_flags_sp->AddBooleanItem("live-stream", m_live_stream);
+
+    // Specify default filter rule (the fall-through)
+    config_sp->AddBooleanItem("filter-fall-through-accepts",
+                              m_filter_fall_through_accepts);
+
+    // Handle filter rules
+    if (!m_filter_rules.empty()) {
+      auto json_filter_rules_sp =
+          StructuredData::ArraySP(new StructuredData::Array);
+      config_sp->AddItem("filter-rules", json_filter_rules_sp);
+      for (auto &rule_sp : m_filter_rules) {
+        if (!rule_sp)
+          continue;
+        json_filter_rules_sp->AddItem(rule_sp->Serialize());
+      }
+    }
+    return config_sp;
+  }
+
+  bool GetIncludeDebugLevel() const { return m_include_debug_level; }
+
+  bool GetIncludeInfoLevel() const {
+    // Specifying debug level implies info level.
+    return m_include_info_level || m_include_debug_level;
+  }
+
+  const FilterRules &GetFilterRules() const { return m_filter_rules; }
+
+  bool GetFallthroughAccepts() const { return m_filter_fall_through_accepts; }
+
+  bool GetEchoToStdErr() const { return m_echo_to_stderr; }
+
+  bool GetDisplayTimestampRelative() const {
+    return m_display_timestamp_relative;
+  }
+
+  bool GetDisplaySubsystem() const { return m_display_subsystem; }
+  bool GetDisplayCategory() const { return m_display_category; }
+  bool GetDisplayActivityChain() const { return m_display_activity_chain; }
+
+  bool GetDisplayAnyHeaderFields() const {
+    return m_display_timestamp_relative || m_display_activity_chain ||
+           m_display_subsystem || m_display_category;
+  }
 
-    private:
+  bool GetBroadcastEvents() const { return m_broadcast_events; }
 
-        static FilterRuleSP
-        CreateOperation(bool accept, size_t attribute_index,
-                        const std::string &op_arg, Error &error)
-        {
-            if (op_arg.empty())
-            {
-                error.SetErrorString("exact match filter type requires an "
-                                     "argument containing the text that must "
-                                     "match the specified message attribute.");
-                return FilterRuleSP();
-            }
-
-            error.Clear();
-            return FilterRuleSP(new ExactMatchFilterRule(accept,
-                                                         attribute_index,
-                                                         op_arg));
-        }
+private:
+  Error ParseFilterRule(const char *rule_text_cstr) {
+    Error error;
 
-        static const ConstString &
-        StaticGetOperation()
-        {
-            static ConstString s_operation("match");
-            return s_operation;
-        }
+    if (!rule_text_cstr || !rule_text_cstr[0]) {
+      error.SetErrorString("invalid rule_text");
+      return error;
+    }
+
+    // filter spec format:
+    //
+    // {action} {attribute} {op}
+    //
+    // {action} :=
+    //   accept |
+    //   reject
+    //
+    // {attribute} :=
+    //   category       |
+    //   subsystem      |
+    //   activity       |
+    //   activity-chain |
+    //   message        |
+    //   format
+    //
+    // {op} :=
+    //   match {exact-match-text} |
+    //   regex {search-regex}
+
+    const std::string rule_text(rule_text_cstr);
+
+    // Parse action.
+    auto action_end_pos = rule_text.find(" ");
+    if (action_end_pos == std::string::npos) {
+      error.SetErrorStringWithFormat("could not parse filter rule "
+                                     "action from \"%s\"",
+                                     rule_text_cstr);
+      return error;
+    }
+    auto action = rule_text.substr(0, action_end_pos);
+    bool accept;
+    if (action == "accept")
+      accept = true;
+    else if (action == "reject")
+      accept = false;
+    else {
+      error.SetErrorString("filter action must be \"accept\" or "
+                           "\"deny\"");
+      return error;
+    }
+
+    // parse attribute
+    auto attribute_end_pos = rule_text.find(" ", action_end_pos + 1);
+    if (attribute_end_pos == std::string::npos) {
+      error.SetErrorStringWithFormat("could not parse filter rule "
+                                     "attribute from \"%s\"",
+                                     rule_text_cstr);
+      return error;
+    }
+    auto attribute = rule_text.substr(action_end_pos + 1,
+                                      attribute_end_pos - (action_end_pos + 1));
+    auto attribute_index = MatchAttributeIndex(attribute);
+    if (attribute_index < 0) {
+      error.SetErrorStringWithFormat("filter rule attribute unknown: "
+                                     "%s",
+                                     attribute.c_str());
+      return error;
+    }
+
+    // parse operation
+    auto operation_end_pos = rule_text.find(" ", attribute_end_pos + 1);
+    auto operation = rule_text.substr(
+        attribute_end_pos + 1, operation_end_pos - (attribute_end_pos + 1));
+
+    // add filter spec
+    auto rule_sp =
+        FilterRule::CreateRule(accept, attribute_index, ConstString(operation),
+                               rule_text.substr(operation_end_pos + 1), error);
 
-        ExactMatchFilterRule(bool accept, size_t attribute_index,
-                             const std::string &match_text) :
-            FilterRule(accept, attribute_index, StaticGetOperation()),
-            m_match_text(match_text)
-        {
-        }
+    if (rule_sp && error.Success())
+      m_filter_rules.push_back(rule_sp);
 
-        const std::string m_match_text;
-    };
+    return error;
+  }
 
-    static void
-    RegisterFilterOperations()
-    {
-        ExactMatchFilterRule::RegisterOperation();
-        RegexFilterRule::RegisterOperation();
+  int MatchAttributeIndex(const std::string &attribute_name) {
+    auto attribute_count =
+        sizeof(s_filter_attributes) / sizeof(s_filter_attributes[0]);
+    for (size_t i = 0; i < attribute_count; ++i) {
+      if (attribute_name == s_filter_attributes[i])
+        return static_cast<int>(i);
+    }
+
+    // We didn't match anything.
+    return -1;
+  }
+
+  static OptionDefinition g_enable_option_table[];
+
+  bool m_include_debug_level;
+  bool m_include_info_level;
+  bool m_include_any_process;
+  bool m_filter_fall_through_accepts;
+  bool m_echo_to_stderr;
+  bool m_display_timestamp_relative;
+  bool m_display_subsystem;
+  bool m_display_category;
+  bool m_display_activity_chain;
+  bool m_broadcast_events;
+  bool m_live_stream;
+  FilterRules m_filter_rules;
+};
+
+OptionDefinition EnableOptions::g_enable_option_table[] = {
+    // Source stream include/exclude options (the first-level filter).
+    // This one should be made as small as possible as everything that
+    // goes through here must be processed by the process monitor.
+    {LLDB_OPT_SET_ALL, false, "any-process", 'a', OptionParser::eNoArgument,
+     nullptr, nullptr, 0, eArgTypeNone,
+     "Specifies log messages from other related processes should be "
+     "included."},
+    {LLDB_OPT_SET_ALL, false, "debug", 'd', OptionParser::eNoArgument, nullptr,
+     nullptr, 0, eArgTypeNone,
+     "Specifies debug-level log messages should be included.  Specifying"
+     " --debug implies --info."},
+    {LLDB_OPT_SET_ALL, false, "info", 'i', OptionParser::eNoArgument, nullptr,
+     nullptr, 0, eArgTypeNone,
+     "Specifies info-level log messages should be included."},
+    {LLDB_OPT_SET_ALL, false, "filter", 'f', OptionParser::eRequiredArgument,
+     nullptr, nullptr, 0, eArgRawInput,
+     // There doesn't appear to be a great way for me to have these
+     // multi-line, formatted tables in help.  This looks mostly right
+     // but there are extra linefeeds added at seemingly random spots,
+     // and indentation isn't handled properly on those lines.
+     "Appends a filter rule to the log message filter chain.  Multiple "
+     "rules may be added by specifying this option multiple times, "
+     "once per filter rule.  Filter rules are processed in the order "
+     "they are specified, with the --no-match-accepts setting used "
+     "for any message that doesn't match one of the rules.\n"
+     "\n"
+     "    Filter spec format:\n"
+     "\n"
+     "    --filter \"{action} {attribute} {op}\"\n"
+     "\n"
+     "    {action} :=\n"
+     "      accept |\n"
+     "      reject\n"
+     "\n"
+     "    {attribute} :=\n"
+     "       activity       |  // message's most-derived activity\n"
+     "       activity-chain |  // message's {parent}:{child} activity\n"
+     "       category       |  // message's category\n"
+     "       message        |  // message's expanded contents\n"
+     "       subsystem      |  // message's subsystem\n"
+     "\n"
+     "    {op} :=\n"
+     "      match {exact-match-text} |\n"
+     "      regex {search-regex}\n"
+     "\n"
+     "The regex flavor used is the C++ std::regex ECMAScript format.  "
+     "Prefer character classes like [[:digit:]] to \\d and the like, as "
+     "getting the backslashes escaped through properly is error-prone."},
+    {LLDB_OPT_SET_ALL, false, "live-stream", 'l',
+     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
+     "Specify whether logging events are live-streamed or buffered.  "
+     "True indicates live streaming, false indicates buffered.  The "
+     "default is true (live streaming).  Live streaming will deliver "
+     "log messages with less delay, but buffered capture mode has less "
+     "of an observer effect."},
+    {LLDB_OPT_SET_ALL, false, "no-match-accepts", 'n',
+     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
+     "Specify whether a log message that doesn't match any filter rule "
+     "is accepted or rejected, where true indicates accept.  The "
+     "default is true."},
+    {LLDB_OPT_SET_ALL, false, "echo-to-stderr", 'e',
+     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
+     "Specify whether os_log()/NSLog() messages are echoed to the "
+     "target program's stderr.  When DarwinLog is enabled, we shut off "
+     "the mirroring of os_log()/NSLog() to the program's stderr.  "
+     "Setting this flag to true will restore the stderr mirroring."
+     "The default is false."},
+    {LLDB_OPT_SET_ALL, false, "broadcast-events", 'b',
+     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
+     "Specify if the plugin should broadcast events.  Broadcasting "
+     "log events is a requirement for displaying the log entries in "
+     "LLDB command-line.  It is also required if LLDB clients want to "
+     "process log events.  The default is true."},
+    // Message formatting options
+    {LLDB_OPT_SET_ALL, false, "timestamp-relative", 'r',
+     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+     "Include timestamp in the message header when printing a log "
+     "message.  The timestamp is relative to the first displayed "
+     "message."},
+    {LLDB_OPT_SET_ALL, false, "subsystem", 's', OptionParser::eNoArgument,
+     nullptr, nullptr, 0, eArgTypeNone,
+     "Include the subsystem in the the message header when displaying "
+     "a log message."},
+    {LLDB_OPT_SET_ALL, false, "category", 'c', OptionParser::eNoArgument,
+     nullptr, nullptr, 0, eArgTypeNone,
+     "Include the category in the the message header when displaying "
+     "a log message."},
+    {LLDB_OPT_SET_ALL, false, "activity-chain", 'C', OptionParser::eNoArgument,
+     nullptr, nullptr, 0, eArgTypeNone,
+     "Include the activity parent-child chain in the the message header "
+     "when displaying a log message.  The activity hierarchy is "
+     "displayed as {grandparent-activity}:"
+     "{parent-activity}:{activity}[:...]."},
+    {LLDB_OPT_SET_ALL, false, "all-fields", 'A', OptionParser::eNoArgument,
+     nullptr, nullptr, 0, eArgTypeNone,
+     "Shortcut to specify that all header fields should be displayed."},
+
+    // Tail sentinel entry
+    {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}};
+
+class EnableCommand : public CommandObjectParsed {
+public:
+  EnableCommand(CommandInterpreter &interpreter, bool enable, const char *name,
+                const char *help, const char *syntax)
+      : CommandObjectParsed(interpreter, name, help, syntax), m_enable(enable),
+        m_options_sp(enable ? new EnableOptions() : nullptr) {}
+
+protected:
+  void AppendStrictSourcesWarning(CommandReturnObject &result,
+                                  const char *source_name) {
+    if (!source_name)
+      return;
+
+    // Check if we're *not* using strict sources.  If not,
+    // then the user is going to get debug-level info
+    // anyways, probably not what they're expecting.
+    // Unfortunately we can only fix this by adding an
+    // env var, which would have had to have happened
+    // already.  Thus, a warning is the best we can do here.
+    StreamString stream;
+    stream.Printf("darwin-log source settings specify to exclude "
+                  "%s messages, but setting "
+                  "'plugin.structured-data.darwin-log."
+                  "strict-sources' is disabled.  This process will "
+                  "automatically have %s messages included.  Enable"
+                  " the property and relaunch the target binary to have"
+                  " these messages excluded.",
+                  source_name, source_name);
+    result.AppendWarning(stream.GetString().c_str());
+  }
+
+  bool DoExecute(Args &command, CommandReturnObject &result) override {
+    // First off, set the global sticky state of enable/disable
+    // based on this command execution.
+    s_is_explicitly_enabled = m_enable;
+
+    // Next, if this is an enable, save off the option data.
+    // We will need it later if a process hasn't been launched or
+    // attached yet.
+    if (m_enable) {
+      // Save off enabled configuration so we can apply these parsed
+      // options the next time an attach or launch occurs.
+      DebuggerSP debugger_sp =
+          GetCommandInterpreter().GetDebugger().shared_from_this();
+      SetGlobalEnableOptions(debugger_sp, m_options_sp);
+    }
+
+    // Now check if we have a running process.  If so, we should
+    // instruct the process monitor to enable/disable DarwinLog support
+    // now.
+    Target *target = GetSelectedOrDummyTarget();
+    if (!target) {
+      // No target, so there is nothing more to do right now.
+      result.SetStatus(eReturnStatusSuccessFinishNoResult);
+      return true;
+    }
+
+    // Grab the active process.
+    auto process_sp = target->GetProcessSP();
+    if (!process_sp) {
+      // No active process, so there is nothing more to do right
+      // now.
+      result.SetStatus(eReturnStatusSuccessFinishNoResult);
+      return true;
+    }
+
+    // If the process is no longer alive, we can't do this now.
+    // We'll catch it the next time the process is started up.
+    if (!process_sp->IsAlive()) {
+      result.SetStatus(eReturnStatusSuccessFinishNoResult);
+      return true;
     }
 
-    // =========================================================================
-    // Commands
-    // =========================================================================
-
-    // -------------------------------------------------------------------------
-    /// Provides the main on-off switch for enabling darwin logging.
-    ///
-    /// It is valid to run the enable command when logging is already enabled.
-    /// This resets the logging with whatever settings are currently set.
-    // -------------------------------------------------------------------------
-    class EnableOptions : public Options
-    {
-    public:
-
-        EnableOptions() :
-            Options(),
-            m_include_debug_level(false),
-            m_include_info_level(false),
-            m_include_any_process(false),
-            m_filter_fall_through_accepts(DEFAULT_FILTER_FALLTHROUGH_ACCEPTS),
-            m_echo_to_stderr(false),
-            m_display_timestamp_relative(false),
-            m_display_subsystem(false),
-            m_display_category(false),
-            m_display_activity_chain(false),
-            m_broadcast_events(true),
-            m_live_stream(true),
-            m_filter_rules()
-        {
-        }
-
-        void
-        OptionParsingStarting (ExecutionContext *execution_context) override
-        {
-            m_include_debug_level = false;
-            m_include_info_level = false;
-            m_include_any_process = false;
-            m_filter_fall_through_accepts = DEFAULT_FILTER_FALLTHROUGH_ACCEPTS;
-            m_echo_to_stderr = false;
-            m_display_timestamp_relative = false;
-            m_display_subsystem = false;
-            m_display_category = false;
-            m_display_activity_chain = false;
-            m_broadcast_events = true;
-            m_live_stream = true;
-            m_filter_rules.clear();
-        }
-
-        Error
-        SetOptionValue (uint32_t option_idx, const char *option_arg,
-                        ExecutionContext *execution_context) override
-        {
-            Error error;
-
-            const int short_option = m_getopt_table[option_idx].val;
-            switch (short_option)
-            {
-                case 'a':
-                    m_include_any_process = true;
-                    break;
-
-                case 'A':
-                    m_display_timestamp_relative = true;
-                    m_display_category = true;
-                    m_display_subsystem = true;
-                    m_display_activity_chain = true;
-                    break;
-
-                case 'b':
-                    m_broadcast_events =
-                        Args::StringToBoolean(option_arg, true, nullptr);
-                    break;
-
-                case 'c':
-                    m_display_category = true;
-                    break;
-
-                case 'C':
-                    m_display_activity_chain = true;
-                    break;
-
-                case 'd':
-                    m_include_debug_level = true;
-                    break;
-
-                case 'e':
-                    m_echo_to_stderr =
-                        Args::StringToBoolean(option_arg, false, nullptr);
-                    break;
-
-                case 'f':
-                    return ParseFilterRule(option_arg);
-
-                case 'i':
-                    m_include_info_level = true;
-                    break;
-
-                case 'l':
-                    m_live_stream =
-                        Args::StringToBoolean(option_arg, false, nullptr);
-                    break;
-
-                case 'n':
-                    m_filter_fall_through_accepts =
-                        Args::StringToBoolean(option_arg, true, nullptr);
-                    break;
-
-                case 'r':
-                    m_display_timestamp_relative = true;
-                    break;
-
-                case 's':
-                    m_display_subsystem = true;
-                    break;
-
-                default:
-                    error.SetErrorStringWithFormat("unsupported option '%c'",
-                                                   short_option);
-            }
-            return error;
-        }
-
-        const OptionDefinition*
-        GetDefinitions () override
-        {
-            return g_enable_option_table;
-        }
-
-        StructuredData::DictionarySP
-        BuildConfigurationData(bool enabled)
-        {
-            StructuredData::DictionarySP config_sp(new StructuredData::
-                                                   Dictionary());
-
-            // Set the basic enabled state.
-            config_sp->AddBooleanItem("enabled", enabled);
-
-            // If we're disabled, there's nothing more to add.
-            if (!enabled)
-                return config_sp;
-
-            // Handle source stream flags.
-            auto source_flags_sp =
-                StructuredData::DictionarySP(new StructuredData::Dictionary());
-            config_sp->AddItem("source-flags", source_flags_sp);
-
-            source_flags_sp->AddBooleanItem("any-process",
-                                            m_include_any_process);
-            source_flags_sp->AddBooleanItem("debug-level",
-                                            m_include_debug_level);
-            // The debug-level flag, if set, implies info-level.
-            source_flags_sp->AddBooleanItem("info-level",
-                                            m_include_info_level ||
-                                            m_include_debug_level);
-            source_flags_sp->AddBooleanItem("live-stream",
-                                            m_live_stream);
-
-            // Specify default filter rule (the fall-through)
-            config_sp->AddBooleanItem("filter-fall-through-accepts",
-                                      m_filter_fall_through_accepts);
-
-
-            // Handle filter rules
-            if (!m_filter_rules.empty())
-            {
-                auto json_filter_rules_sp =
-                    StructuredData::ArraySP(new StructuredData::Array);
-                config_sp->AddItem("filter-rules",
-                                   json_filter_rules_sp);
-                for (auto &rule_sp : m_filter_rules)
-                {
-                    if (!rule_sp)
-                        continue;
-                    json_filter_rules_sp->AddItem(rule_sp->Serialize());
-                }
-            }
-            return config_sp;
-        }
-
-        bool
-        GetIncludeDebugLevel() const
-        {
-            return m_include_debug_level;
-        }
-
-        bool
-        GetIncludeInfoLevel() const
-        {
-            // Specifying debug level implies info level.
-            return m_include_info_level || m_include_debug_level;
-        }
-
-        const FilterRules&
-        GetFilterRules() const
-        {
-            return m_filter_rules;
-        }
-
-        bool
-        GetFallthroughAccepts() const
-        {
-            return m_filter_fall_through_accepts;
-        }
-
-        bool
-        GetEchoToStdErr() const
-        {
-            return m_echo_to_stderr;
-        }
-
-        bool
-        GetDisplayTimestampRelative() const
-        {
-            return m_display_timestamp_relative;
-        }
-
-        bool
-        GetDisplaySubsystem() const
-        {
-            return m_display_subsystem;
-        }
-        bool
-        GetDisplayCategory() const
-        {
-            return m_display_category;
-        }
-        bool
-        GetDisplayActivityChain() const
-        {
-            return m_display_activity_chain;
-        }
-
-        bool
-        GetDisplayAnyHeaderFields() const
-        {
-            return
-                m_display_timestamp_relative ||
-                m_display_activity_chain ||
-                m_display_subsystem ||
-                m_display_category;
-        }
-
-        bool
-        GetBroadcastEvents() const
-        {
-            return m_broadcast_events;
-        }
-
-    private:
-
-        Error
-        ParseFilterRule(const char *rule_text_cstr)
-        {
-            Error error;
-
-            if (!rule_text_cstr || !rule_text_cstr[0])
-            {
-                error.SetErrorString("invalid rule_text");
-                return error;
-            }
-
-            // filter spec format:
-            //
-            // {action} {attribute} {op}
-            //
-            // {action} :=
-            //   accept |
-            //   reject
-            //
-            // {attribute} :=
-            //   category       |
-            //   subsystem      |
-            //   activity       |
-            //   activity-chain |
-            //   message        |
-            //   format
-            //
-            // {op} :=
-            //   match {exact-match-text} |
-            //   regex {search-regex}
-
-            const std::string rule_text(rule_text_cstr);
-
-            // Parse action.
-            auto action_end_pos = rule_text.find(" ");
-            if (action_end_pos == std::string::npos)
-            {
-                error.SetErrorStringWithFormat("could not parse filter rule "
-                                               "action from \"%s\"",
-                                               rule_text_cstr);
-                return error;
-            }
-            auto action = rule_text.substr(0, action_end_pos);
-            bool accept;
-            if (action == "accept")
-                accept = true;
-            else if (action == "reject")
-                accept = false;
-            else
-            {
-                error.SetErrorString("filter action must be \"accept\" or "
-                                     "\"deny\"");
-                return error;
-            }
-
-            // parse attribute
-            auto attribute_end_pos = rule_text.find(" ", action_end_pos + 1);
-            if (attribute_end_pos == std::string::npos)
-            {
-                error.SetErrorStringWithFormat("could not parse filter rule "
-                                               "attribute from \"%s\"",
-                                               rule_text_cstr);
-                return error;
-            }
-            auto attribute =
-                rule_text.substr(action_end_pos + 1,
-                                 attribute_end_pos - (action_end_pos + 1));
-            auto attribute_index = MatchAttributeIndex(attribute);
-            if (attribute_index < 0)
-            {
-                error.SetErrorStringWithFormat("filter rule attribute unknown: "
-                                               "%s", attribute.c_str());
-                return error;
-            }
-
-            // parse operation
-            auto operation_end_pos = rule_text.find(" ", attribute_end_pos + 1);
-            auto operation =
-                rule_text.substr(attribute_end_pos + 1,
-                                 operation_end_pos - (attribute_end_pos + 1));
-
-            // add filter spec
-            auto rule_sp =
-            FilterRule::CreateRule(accept, attribute_index,
-                                   ConstString(operation),
-                                   rule_text.substr(operation_end_pos + 1),
-                                   error);
-
-            if (rule_sp && error.Success())
-                m_filter_rules.push_back(rule_sp);
-
-            return error;
-        }
-
-        int
-        MatchAttributeIndex(const std::string &attribute_name)
-        {
-            auto attribute_count =
-                sizeof(s_filter_attributes) / sizeof(s_filter_attributes[0]);
-            for (size_t i = 0; i < attribute_count; ++i)
-            {
-                if (attribute_name == s_filter_attributes[i])
-                    return static_cast<int>(i);
-            }
-
-            // We didn't match anything.
-            return -1;
-        }
-
-        static OptionDefinition g_enable_option_table[];
-
-        bool         m_include_debug_level;
-        bool         m_include_info_level;
-        bool         m_include_any_process;
-        bool         m_filter_fall_through_accepts;
-        bool         m_echo_to_stderr;
-        bool         m_display_timestamp_relative;
-        bool         m_display_subsystem;
-        bool         m_display_category;
-        bool         m_display_activity_chain;
-        bool         m_broadcast_events;
-        bool         m_live_stream;
-        FilterRules  m_filter_rules;
-    };
-
-    OptionDefinition
-    EnableOptions::g_enable_option_table[] =
-    {
-        // Source stream include/exclude options (the first-level filter).
-        // This one should be made as small as possible as everything that
-        // goes through here must be processed by the process monitor.
-        { LLDB_OPT_SET_ALL, false, "any-process", 'a',
-            OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
-            "Specifies log messages from other related processes should be "
-            "included." },
-        { LLDB_OPT_SET_ALL, false, "debug", 'd', OptionParser::eNoArgument,
-            nullptr, nullptr, 0, eArgTypeNone,
-            "Specifies debug-level log messages should be included.  Specifying"
-            " --debug implies --info."},
-        { LLDB_OPT_SET_ALL, false, "info", 'i', OptionParser::eNoArgument,
-            nullptr, nullptr, 0, eArgTypeNone,
-            "Specifies info-level log messages should be included." },
-        { LLDB_OPT_SET_ALL, false, "filter", 'f',
-            OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgRawInput,
-            // There doesn't appear to be a great way for me to have these
-            // multi-line, formatted tables in help.  This looks mostly right
-            // but there are extra linefeeds added at seemingly random spots,
-            // and indentation isn't handled properly on those lines.
-            "Appends a filter rule to the log message filter chain.  Multiple "
-            "rules may be added by specifying this option multiple times, "
-            "once per filter rule.  Filter rules are processed in the order "
-            "they are specified, with the --no-match-accepts setting used "
-            "for any message that doesn't match one of the rules.\n"
-            "\n"
-            "    Filter spec format:\n"
-            "\n"
-            "    --filter \"{action} {attribute} {op}\"\n"
-            "\n"
-            "    {action} :=\n"
-            "      accept |\n"
-            "      reject\n"
-            "\n"
-            "    {attribute} :=\n"
-            "       activity       |  // message's most-derived activity\n"
-            "       activity-chain |  // message's {parent}:{child} activity\n"
-            "       category       |  // message's category\n"
-            "       message        |  // message's expanded contents\n"
-            "       subsystem      |  // message's subsystem\n"
-            "\n"
-            "    {op} :=\n"
-            "      match {exact-match-text} |\n"
-            "      regex {search-regex}\n"
-            "\n"
-            "The regex flavor used is the C++ std::regex ECMAScript format.  "
-            "Prefer character classes like [[:digit:]] to \\d and the like, as "
-            "getting the backslashes escaped through properly is error-prone."
-        },
-        { LLDB_OPT_SET_ALL, false, "live-stream", 'l',
-            OptionParser::eRequiredArgument, nullptr, nullptr, 0,
-            eArgTypeBoolean,
-            "Specify whether logging events are live-streamed or buffered.  "
-            "True indicates live streaming, false indicates buffered.  The "
-            "default is true (live streaming).  Live streaming will deliver "
-            "log messages with less delay, but buffered capture mode has less "
-            "of an observer effect." },
-        { LLDB_OPT_SET_ALL, false, "no-match-accepts", 'n',
-            OptionParser::eRequiredArgument, nullptr, nullptr, 0,
-            eArgTypeBoolean,
-            "Specify whether a log message that doesn't match any filter rule "
-            "is accepted or rejected, where true indicates accept.  The "
-            "default is true." },
-        { LLDB_OPT_SET_ALL, false, "echo-to-stderr", 'e',
-            OptionParser::eRequiredArgument, nullptr, nullptr, 0,
-            eArgTypeBoolean,
-            "Specify whether os_log()/NSLog() messages are echoed to the "
-            "target program's stderr.  When DarwinLog is enabled, we shut off "
-            "the mirroring of os_log()/NSLog() to the program's stderr.  "
-            "Setting this flag to true will restore the stderr mirroring."
-            "The default is false." },
-        { LLDB_OPT_SET_ALL, false, "broadcast-events", 'b',
-            OptionParser::eRequiredArgument, nullptr, nullptr, 0,
-            eArgTypeBoolean,
-            "Specify if the plugin should broadcast events.  Broadcasting "
-            "log events is a requirement for displaying the log entries in "
-            "LLDB command-line.  It is also required if LLDB clients want to "
-            "process log events.  The default is true." },
-        // Message formatting options
-        { LLDB_OPT_SET_ALL, false, "timestamp-relative", 'r',
-            OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
-            "Include timestamp in the message header when printing a log "
-            "message.  The timestamp is relative to the first displayed "
-            "message." },
-        { LLDB_OPT_SET_ALL, false, "subsystem", 's',
-            OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
-            "Include the subsystem in the the message header when displaying "
-            "a log message." },
-        { LLDB_OPT_SET_ALL, false, "category", 'c',
-            OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
-            "Include the category in the the message header when displaying "
-            "a log message." },
-        { LLDB_OPT_SET_ALL, false, "activity-chain", 'C',
-            OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
-            "Include the activity parent-child chain in the the message header "
-            "when displaying a log message.  The activity hierarchy is "
-            "displayed as {grandparent-activity}:"
-            "{parent-activity}:{activity}[:...]."},
-        { LLDB_OPT_SET_ALL, false, "all-fields", 'A',
-            OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
-            "Shortcut to specify that all header fields should be displayed." },
-
-        // Tail sentinel entry
-        { 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr }
-    };
-
-    class EnableCommand : public CommandObjectParsed
-    {
-    public:
-
-        EnableCommand(CommandInterpreter &interpreter, bool enable,
-                               const char *name, const char *help,
-                               const char *syntax) :
-            CommandObjectParsed(interpreter, name, help, syntax),
-            m_enable(enable),
-            m_options_sp(enable ? new EnableOptions() : nullptr)
-        {
-        }
-
-    protected:
-
-        void
-        AppendStrictSourcesWarning(CommandReturnObject &result,
-                                   const char *source_name)
-        {
-            if (!source_name)
-                return;
-
-            // Check if we're *not* using strict sources.  If not,
-            // then the user is going to get debug-level info
-            // anyways, probably not what they're expecting.
-            // Unfortunately we can only fix this by adding an
-            // env var, which would have had to have happened
-            // already.  Thus, a warning is the best we can do here.
-            StreamString stream;
-            stream.Printf("darwin-log source settings specify to exclude "
-                          "%s messages, but setting "
-                          "'plugin.structured-data.darwin-log."
-                          "strict-sources' is disabled.  This process will "
-                          "automatically have %s messages included.  Enable"
-                          " the property and relaunch the target binary to have"
-                          " these messages excluded.", source_name,
-                          source_name);
-            result.AppendWarning(stream.GetString().c_str());
-        }
-
-        bool
-        DoExecute (Args& command, CommandReturnObject &result) override
-        {
-            // First off, set the global sticky state of enable/disable
-            // based on this command execution.
-            s_is_explicitly_enabled = m_enable;
-
-            // Next, if this is an enable, save off the option data.
-            // We will need it later if a process hasn't been launched or
-            // attached yet.
-            if (m_enable)
-            {
-                // Save off enabled configuration so we can apply these parsed
-                // options the next time an attach or launch occurs.
-                DebuggerSP debugger_sp =
-                    GetCommandInterpreter().GetDebugger().shared_from_this();
-                SetGlobalEnableOptions(debugger_sp, m_options_sp);
-            }
-
-            // Now check if we have a running process.  If so, we should
-            // instruct the process monitor to enable/disable DarwinLog support
-            // now.
-            Target *target = GetSelectedOrDummyTarget();
-            if (!target)
-            {
-                // No target, so there is nothing more to do right now.
-                result.SetStatus(eReturnStatusSuccessFinishNoResult);
-                return true;
-            }
-
-            // Grab the active process.
-            auto process_sp = target->GetProcessSP();
-            if (!process_sp)
-            {
-                // No active process, so there is nothing more to do right
-                // now.
-                result.SetStatus(eReturnStatusSuccessFinishNoResult);
-                return true;
-            }
-
-            // If the process is no longer alive, we can't do this now.
-            // We'll catch it the next time the process is started up.
-            if (!process_sp->IsAlive())
-            {
-                result.SetStatus(eReturnStatusSuccessFinishNoResult);
-                return true;
-            }
-
-            // Get the plugin for the process.
-            auto plugin_sp =
-                process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
-            if (!plugin_sp ||
-                (plugin_sp->GetPluginName() !=
-                 StructuredDataDarwinLog::GetStaticPluginName()))
-            {
-                result.AppendError("failed to get StructuredDataPlugin for "
-                                   "the process");
-                result.SetStatus(eReturnStatusFailed);
-            }
-            StructuredDataDarwinLog &plugin =
-                *static_cast<StructuredDataDarwinLog*>(plugin_sp.get());
-
-            if (m_enable)
-            {
-                // To do this next part right, we need to track whether we
-                // added the proper environment variable at launch time.
-                // It is incorrect to assume that we're enabling after launch,
-                // and that therefore if we needed the env var set to properly
-                // handle the options, that it is set incorrectly.  The env var
-                // could have been added if this is a re-enable using different
-                // arguments.  This is a bit tricky as the point where we
-                // have to set the env var, we don't yet have a process or the
-                // associated darwin-log plugin instance, and thus don't have a
-                // great place to stick this knowledge.
+    // Get the plugin for the process.
+    auto plugin_sp =
+        process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
+    if (!plugin_sp || (plugin_sp->GetPluginName() !=
+                       StructuredDataDarwinLog::GetStaticPluginName())) {
+      result.AppendError("failed to get StructuredDataPlugin for "
+                         "the process");
+      result.SetStatus(eReturnStatusFailed);
+    }
+    StructuredDataDarwinLog &plugin =
+        *static_cast<StructuredDataDarwinLog *>(plugin_sp.get());
+
+    if (m_enable) {
+// To do this next part right, we need to track whether we
+// added the proper environment variable at launch time.
+// It is incorrect to assume that we're enabling after launch,
+// and that therefore if we needed the env var set to properly
+// handle the options, that it is set incorrectly.  The env var
+// could have been added if this is a re-enable using different
+// arguments.  This is a bit tricky as the point where we
+// have to set the env var, we don't yet have a process or the
+// associated darwin-log plugin instance, and thus don't have a
+// great place to stick this knowledge.
 #if 0
                 // Check if we're attempting to disable debug-level or
                 // info-level content but we haven't launched with the magic
@@ -1133,273 +893,233 @@ namespace sddarwinlog_private
                 }
 #endif
 
-                // Hook up the breakpoint for the process that detects when
-                // libtrace has been sufficiently initialized to really start
-                // the os_log stream.  This is insurance to assure us that
-                // logging is really enabled.  Requesting that logging be
-                // enabled for a process before libtrace is initialized
-                // results in a scenario where no errors occur, but no logging
-                // is captured, either.  This step is to eliminate that
-                // possibility.
-                plugin.AddInitCompletionHook(*process_sp.get());
-            }
-
-            // Send configuration to the feature by way of the process.
-            // Construct the options we will use.
-            auto config_sp = m_options_sp->BuildConfigurationData(m_enable);
-            const Error error =
-                process_sp->ConfigureStructuredData(GetDarwinLogTypeName(),
-                                                    config_sp);
-
-            // Report results.
-            if (!error.Success())
-            {
-                result.AppendError(error.AsCString());
-                result.SetStatus(eReturnStatusFailed);
-                // Our configuration failed, so we're definitely disabled.
-                plugin.SetEnabled(false);
-            }
-            else
-            {
-                result.SetStatus(eReturnStatusSuccessFinishNoResult);
-                // Our configuration succeeeded, so we're enabled/disabled
-                // per whichever one this command is setup to do.
-                plugin.SetEnabled(m_enable);
-            }
-            return result.Succeeded();
-        }
-
-        Options*
-        GetOptions () override
-        {
-            // We don't have options when this represents disable.
-            return m_enable ? m_options_sp.get() : nullptr;
-        }
+      // Hook up the breakpoint for the process that detects when
+      // libtrace has been sufficiently initialized to really start
+      // the os_log stream.  This is insurance to assure us that
+      // logging is really enabled.  Requesting that logging be
+      // enabled for a process before libtrace is initialized
+      // results in a scenario where no errors occur, but no logging
+      // is captured, either.  This step is to eliminate that
+      // possibility.
+      plugin.AddInitCompletionHook(*process_sp.get());
+    }
 
-    private:
-        const bool       m_enable;
-        EnableOptionsSP  m_options_sp;
-    };
-
-    // -------------------------------------------------------------------------
-    /// Provides the status command.
-    // -------------------------------------------------------------------------
-    class StatusCommand : public CommandObjectParsed
-    {
-    public:
+    // Send configuration to the feature by way of the process.
+    // Construct the options we will use.
+    auto config_sp = m_options_sp->BuildConfigurationData(m_enable);
+    const Error error =
+        process_sp->ConfigureStructuredData(GetDarwinLogTypeName(), config_sp);
 
-        StatusCommand(CommandInterpreter &interpreter) :
-        CommandObjectParsed(interpreter, "status",
+    // Report results.
+    if (!error.Success()) {
+      result.AppendError(error.AsCString());
+      result.SetStatus(eReturnStatusFailed);
+      // Our configuration failed, so we're definitely disabled.
+      plugin.SetEnabled(false);
+    } else {
+      result.SetStatus(eReturnStatusSuccessFinishNoResult);
+      // Our configuration succeeeded, so we're enabled/disabled
+      // per whichever one this command is setup to do.
+      plugin.SetEnabled(m_enable);
+    }
+    return result.Succeeded();
+  }
+
+  Options *GetOptions() override {
+    // We don't have options when this represents disable.
+    return m_enable ? m_options_sp.get() : nullptr;
+  }
+
+private:
+  const bool m_enable;
+  EnableOptionsSP m_options_sp;
+};
+
+// -------------------------------------------------------------------------
+/// Provides the status command.
+// -------------------------------------------------------------------------
+class StatusCommand : public CommandObjectParsed {
+public:
+  StatusCommand(CommandInterpreter &interpreter)
+      : CommandObjectParsed(interpreter, "status",
                             "Show whether Darwin log supported is available"
                             " and enabled.",
-                            "plugin structured-data darwin-log status")
-        {
-        }
-
-    protected:
-
-        bool
-        DoExecute (Args& command, CommandReturnObject &result) override
-        {
-            auto &stream = result.GetOutputStream();
-
-            // Figure out if we've got a process.  If so, we can tell if
-            // DarwinLog is available for that process.
-            Target *target = GetSelectedOrDummyTarget();
-            auto process_sp = target ? target->GetProcessSP() : ProcessSP();
-            if (!target || !process_sp)
-            {
-                stream.PutCString("Availability: unknown (requires process)\n");
-                stream.PutCString("Enabled: not applicable "
-                                  "(requires process)\n");
-            }
-            else
-            {
-                auto plugin_sp =
-                    process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
-                stream.Printf("Availability: %s\n", plugin_sp ? "available" :
-                              "unavailable");
-                auto &plugin_name =
-                    StructuredDataDarwinLog::GetStaticPluginName();
-                const bool enabled = plugin_sp ?
-                    plugin_sp->GetEnabled(plugin_name) : false;
-                stream.Printf("Enabled: %s\n", enabled ? "true" :
-                              "false");
-            }
-
-            // Display filter settings.
-            DebuggerSP debugger_sp =
-                GetCommandInterpreter().GetDebugger().shared_from_this();
-            auto options_sp = GetGlobalEnableOptions(debugger_sp);
-            if (!options_sp)
-            {
-                // Nothing more to do.
-                result.SetStatus(eReturnStatusSuccessFinishResult);
-                return true;
-            }
-
-            // Print filter rules
-            stream.PutCString("DarwinLog filter rules:\n");
-
-            stream.IndentMore();
-
-            if (options_sp->GetFilterRules().empty())
-            {
-                stream.Indent();
-                stream.PutCString("none\n");
-            }
-            else
-            {
-                // Print each of the filter rules.
-                int rule_number = 0;
-                for (auto rule_sp : options_sp->GetFilterRules())
-                {
-                    ++rule_number;
-                    if (!rule_sp)
-                        continue;
-
-                    stream.Indent();
-                    stream.Printf("%02d: ", rule_number);
-                    rule_sp->Dump(stream);
-                    stream.PutChar('\n');
-                }
-            }
-            stream.IndentLess();
-
-            // Print no-match handling.
-            stream.Indent();
-            stream.Printf("no-match behavior: %s\n",
-                          options_sp->GetFallthroughAccepts() ? "accept" :
-                          "reject");
-
-            result.SetStatus(eReturnStatusSuccessFinishResult);
-            return true;
-        }
-    };
-
-    // -------------------------------------------------------------------------
-    /// Provides the darwin-log base command
-    // -------------------------------------------------------------------------
-    class BaseCommand : public CommandObjectMultiword
-    {
-    public:
-        BaseCommand(CommandInterpreter &interpreter) :
-            CommandObjectMultiword(interpreter,
-                                   "plugin structured-data darwin-log",
-                                   "Commands for configuring Darwin os_log "
-                                   "support.",
-                                   "")
-        {
-            // enable
-            auto enable_help = "Enable Darwin log collection, or re-enable "
-                               "with modified configuration.";
-            auto enable_syntax = "plugin structured-data darwin-log enable";
-            auto enable_cmd_sp =
-                CommandObjectSP(new EnableCommand(interpreter,
-                                                  true, // enable
-                                                  "enable",
-                                                  enable_help,
-                                                  enable_syntax));
-            LoadSubCommand("enable", enable_cmd_sp);
-
-            // disable
-            auto disable_help = "Disable Darwin log collection.";
-            auto disable_syntax = "plugin structured-data darwin-log disable";
-            auto disable_cmd_sp =
-                CommandObjectSP(new EnableCommand(interpreter,
-                                                  false, // disable
-                                                  "disable",
-                                                  disable_help,
-                                                  disable_syntax));
-            LoadSubCommand("disable", disable_cmd_sp);
-
-            // status
-            auto status_cmd_sp =
-                CommandObjectSP(new StatusCommand(interpreter));
-            LoadSubCommand("status", status_cmd_sp);
-        }
-    };
-
-    EnableOptionsSP
-    ParseAutoEnableOptions(Error &error, Debugger &debugger)
-    {
-        // We are abusing the options data model here so that we can parse
-        // options without requiring the Debugger instance.
+                            "plugin structured-data darwin-log status") {}
 
-        // We have an empty execution context at this point.  We only want
-        // to parse options, and we don't need any context to do this here.
-        // In fact, we want to be able to parse the enable options before having
-        // any context.
-        ExecutionContext exe_ctx;
-
-        EnableOptionsSP options_sp(new EnableOptions());
-        options_sp->NotifyOptionParsingStarting(&exe_ctx);
-
-        CommandReturnObject result;
-
-        // Parse the arguments.
-        auto options_property_sp =
-            debugger.GetPropertyValue(nullptr,
-                                      "plugin.structured-data.darwin-log."
-                                      "auto-enable-options",
-                                      false,
-                                      error);
-        if (!error.Success())
-            return EnableOptionsSP();
-        if (!options_property_sp)
-        {
-            error.SetErrorString("failed to find option setting for "
-                                 "plugin.structured-data.darwin-log.");
-            return EnableOptionsSP();
-        }
-
-        const char *enable_options = options_property_sp->GetAsString()->GetCurrentValue();
-        Args args(enable_options);
-        if (args.GetArgumentCount() > 0)
-        {
-            // Eliminate the initial '--' that would be required to set the
-            // settings that themselves include '-' and/or '--'.
-            const char *first_arg = args.GetArgumentAtIndex(0);
-            if (first_arg && (strcmp(first_arg, "--") == 0))
-                args.Shift();
-        }
-
-        // ParseOptions calls getopt_long_only, which always skips the zero'th item in the array and starts at position 1,
-        // so we need to push a dummy value into position zero.
-        args.Unshift("dummy_string");
-        bool require_validation = false;
-        error = args.ParseOptions(*options_sp.get(), &exe_ctx, PlatformSP(),
-                                  require_validation);
-        if (!error.Success())
-            return EnableOptionsSP();
-
-        if (!options_sp->VerifyOptions(result))
-            return EnableOptionsSP();
-
-        // We successfully parsed and validated the options.
-        return options_sp;
+protected:
+  bool DoExecute(Args &command, CommandReturnObject &result) override {
+    auto &stream = result.GetOutputStream();
+
+    // Figure out if we've got a process.  If so, we can tell if
+    // DarwinLog is available for that process.
+    Target *target = GetSelectedOrDummyTarget();
+    auto process_sp = target ? target->GetProcessSP() : ProcessSP();
+    if (!target || !process_sp) {
+      stream.PutCString("Availability: unknown (requires process)\n");
+      stream.PutCString("Enabled: not applicable "
+                        "(requires process)\n");
+    } else {
+      auto plugin_sp =
+          process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
+      stream.Printf("Availability: %s\n",
+                    plugin_sp ? "available" : "unavailable");
+      auto &plugin_name = StructuredDataDarwinLog::GetStaticPluginName();
+      const bool enabled =
+          plugin_sp ? plugin_sp->GetEnabled(plugin_name) : false;
+      stream.Printf("Enabled: %s\n", enabled ? "true" : "false");
     }
 
-    bool
-    RunEnableCommand(CommandInterpreter &interpreter)
-    {
-        StreamString command_stream;
-
-        command_stream << "plugin structured-data darwin-log enable";
-        auto enable_options = GetGlobalProperties()->GetAutoEnableOptions();
-        if (enable_options && (strlen(enable_options) > 0))
-        {
-            command_stream << ' ';
-            command_stream << enable_options;
-        }
-
-        // Run the command.
-        CommandReturnObject return_object;
-        interpreter.HandleCommand(command_stream.GetString().c_str(),
-                                  eLazyBoolNo,
-                                  return_object);
-        return return_object.Succeeded();
-    }
+    // Display filter settings.
+    DebuggerSP debugger_sp =
+        GetCommandInterpreter().GetDebugger().shared_from_this();
+    auto options_sp = GetGlobalEnableOptions(debugger_sp);
+    if (!options_sp) {
+      // Nothing more to do.
+      result.SetStatus(eReturnStatusSuccessFinishResult);
+      return true;
+    }
+
+    // Print filter rules
+    stream.PutCString("DarwinLog filter rules:\n");
+
+    stream.IndentMore();
+
+    if (options_sp->GetFilterRules().empty()) {
+      stream.Indent();
+      stream.PutCString("none\n");
+    } else {
+      // Print each of the filter rules.
+      int rule_number = 0;
+      for (auto rule_sp : options_sp->GetFilterRules()) {
+        ++rule_number;
+        if (!rule_sp)
+          continue;
+
+        stream.Indent();
+        stream.Printf("%02d: ", rule_number);
+        rule_sp->Dump(stream);
+        stream.PutChar('\n');
+      }
+    }
+    stream.IndentLess();
+
+    // Print no-match handling.
+    stream.Indent();
+    stream.Printf("no-match behavior: %s\n",
+                  options_sp->GetFallthroughAccepts() ? "accept" : "reject");
+
+    result.SetStatus(eReturnStatusSuccessFinishResult);
+    return true;
+  }
+};
+
+// -------------------------------------------------------------------------
+/// Provides the darwin-log base command
+// -------------------------------------------------------------------------
+class BaseCommand : public CommandObjectMultiword {
+public:
+  BaseCommand(CommandInterpreter &interpreter)
+      : CommandObjectMultiword(interpreter, "plugin structured-data darwin-log",
+                               "Commands for configuring Darwin os_log "
+                               "support.",
+                               "") {
+    // enable
+    auto enable_help = "Enable Darwin log collection, or re-enable "
+                       "with modified configuration.";
+    auto enable_syntax = "plugin structured-data darwin-log enable";
+    auto enable_cmd_sp = CommandObjectSP(
+        new EnableCommand(interpreter,
+                          true, // enable
+                          "enable", enable_help, enable_syntax));
+    LoadSubCommand("enable", enable_cmd_sp);
+
+    // disable
+    auto disable_help = "Disable Darwin log collection.";
+    auto disable_syntax = "plugin structured-data darwin-log disable";
+    auto disable_cmd_sp = CommandObjectSP(
+        new EnableCommand(interpreter,
+                          false, // disable
+                          "disable", disable_help, disable_syntax));
+    LoadSubCommand("disable", disable_cmd_sp);
+
+    // status
+    auto status_cmd_sp = CommandObjectSP(new StatusCommand(interpreter));
+    LoadSubCommand("status", status_cmd_sp);
+  }
+};
+
+EnableOptionsSP ParseAutoEnableOptions(Error &error, Debugger &debugger) {
+  // We are abusing the options data model here so that we can parse
+  // options without requiring the Debugger instance.
+
+  // We have an empty execution context at this point.  We only want
+  // to parse options, and we don't need any context to do this here.
+  // In fact, we want to be able to parse the enable options before having
+  // any context.
+  ExecutionContext exe_ctx;
+
+  EnableOptionsSP options_sp(new EnableOptions());
+  options_sp->NotifyOptionParsingStarting(&exe_ctx);
+
+  CommandReturnObject result;
+
+  // Parse the arguments.
+  auto options_property_sp =
+      debugger.GetPropertyValue(nullptr, "plugin.structured-data.darwin-log."
+                                         "auto-enable-options",
+                                false, error);
+  if (!error.Success())
+    return EnableOptionsSP();
+  if (!options_property_sp) {
+    error.SetErrorString("failed to find option setting for "
+                         "plugin.structured-data.darwin-log.");
+    return EnableOptionsSP();
+  }
+
+  const char *enable_options =
+      options_property_sp->GetAsString()->GetCurrentValue();
+  Args args(enable_options);
+  if (args.GetArgumentCount() > 0) {
+    // Eliminate the initial '--' that would be required to set the
+    // settings that themselves include '-' and/or '--'.
+    const char *first_arg = args.GetArgumentAtIndex(0);
+    if (first_arg && (strcmp(first_arg, "--") == 0))
+      args.Shift();
+  }
+
+  // ParseOptions calls getopt_long_only, which always skips the zero'th item in
+  // the array and starts at position 1,
+  // so we need to push a dummy value into position zero.
+  args.Unshift("dummy_string");
+  bool require_validation = false;
+  error = args.ParseOptions(*options_sp.get(), &exe_ctx, PlatformSP(),
+                            require_validation);
+  if (!error.Success())
+    return EnableOptionsSP();
+
+  if (!options_sp->VerifyOptions(result))
+    return EnableOptionsSP();
+
+  // We successfully parsed and validated the options.
+  return options_sp;
+}
+
+bool RunEnableCommand(CommandInterpreter &interpreter) {
+  StreamString command_stream;
+
+  command_stream << "plugin structured-data darwin-log enable";
+  auto enable_options = GetGlobalProperties()->GetAutoEnableOptions();
+  if (enable_options && (strlen(enable_options) > 0)) {
+    command_stream << ' ';
+    command_stream << enable_options;
+  }
+
+  // Run the command.
+  CommandReturnObject return_object;
+  interpreter.HandleCommand(command_stream.GetString().c_str(), eLazyBoolNo,
+                            return_object);
+  return return_object.Succeeded();
+}
 }
 using namespace sddarwinlog_private;
 
@@ -1410,28 +1130,20 @@ using namespace sddarwinlog_private;
 // Public static API
 // -----------------------------------------------------------------------------
 
-void
-StructuredDataDarwinLog::Initialize()
-{
-    RegisterFilterOperations();
-    PluginManager::RegisterPlugin(GetStaticPluginName(),
-                                  "Darwin os_log() and os_activity() support",
-                                  &CreateInstance,
-                                  &DebuggerInitialize,
-                                  &FilterLaunchInfo);
-}
-
-void
-StructuredDataDarwinLog::Terminate()
-{
-    PluginManager::UnregisterPlugin(&CreateInstance);
-}
-
-const ConstString&
-StructuredDataDarwinLog::GetStaticPluginName()
-{
-    static ConstString s_plugin_name("darwin-log");
-    return s_plugin_name;
+void StructuredDataDarwinLog::Initialize() {
+  RegisterFilterOperations();
+  PluginManager::RegisterPlugin(
+      GetStaticPluginName(), "Darwin os_log() and os_activity() support",
+      &CreateInstance, &DebuggerInitialize, &FilterLaunchInfo);
+}
+
+void StructuredDataDarwinLog::Terminate() {
+  PluginManager::UnregisterPlugin(&CreateInstance);
+}
+
+const ConstString &StructuredDataDarwinLog::GetStaticPluginName() {
+  static ConstString s_plugin_name("darwin-log");
+  return s_plugin_name;
 }
 
 #pragma mark -
@@ -1441,17 +1153,11 @@ StructuredDataDarwinLog::GetStaticPlugin
 // PluginInterface API
 // -----------------------------------------------------------------------------
 
-ConstString
-StructuredDataDarwinLog::GetPluginName()
-{
-    return GetStaticPluginName();
+ConstString StructuredDataDarwinLog::GetPluginName() {
+  return GetStaticPluginName();
 }
 
-uint32_t
-StructuredDataDarwinLog::GetPluginVersion()
-{
-    return 1;
-}
+uint32_t StructuredDataDarwinLog::GetPluginVersion() { return 1; }
 
 #pragma mark -
 #pragma mark StructuredDataPlugin API
@@ -1460,292 +1166,253 @@ StructuredDataDarwinLog::GetPluginVersio
 // StructuredDataPlugin API
 // -----------------------------------------------------------------------------
 
-bool
-StructuredDataDarwinLog::SupportsStructuredDataType(
-    const ConstString &type_name)
-{
-    return type_name == GetDarwinLogTypeName();
-}
-
-void
-StructuredDataDarwinLog::HandleArrivalOfStructuredData(Process &process,
-                                                       const ConstString
-                                                       &type_name,
-                                                       const
-                                                       StructuredData::ObjectSP
-                                                       &object_sp)
-{
-    Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    if (log)
-    {
-        StreamString json_stream;
-        if (object_sp)
-            object_sp->Dump(json_stream);
-        else
-            json_stream.PutCString("<null>");
-        log->Printf("StructuredDataDarwinLog::%s() called with json: %s",
-                    __FUNCTION__, json_stream.GetString().c_str());
-    }
+bool StructuredDataDarwinLog::SupportsStructuredDataType(
+    const ConstString &type_name) {
+  return type_name == GetDarwinLogTypeName();
+}
 
-    // Ignore empty structured data.
-    if (!object_sp)
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() StructuredData object "
-                        "is null", __FUNCTION__);
-        return;
-    }
+void StructuredDataDarwinLog::HandleArrivalOfStructuredData(
+    Process &process, const ConstString &type_name,
+    const StructuredData::ObjectSP &object_sp) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log) {
+    StreamString json_stream;
+    if (object_sp)
+      object_sp->Dump(json_stream);
+    else
+      json_stream.PutCString("<null>");
+    log->Printf("StructuredDataDarwinLog::%s() called with json: %s",
+                __FUNCTION__, json_stream.GetString().c_str());
+  }
 
-    // Ignore any data that isn't for us.
-    if (type_name != GetDarwinLogTypeName())
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() StructuredData type "
-                        "expected to be %s but was %s, ignoring", __FUNCTION__,
-                        GetDarwinLogTypeName().AsCString(),
-                        type_name.AsCString());
-        return;
-    }
+  // Ignore empty structured data.
+  if (!object_sp) {
+    if (log)
+      log->Printf("StructuredDataDarwinLog::%s() StructuredData object "
+                  "is null",
+                  __FUNCTION__);
+    return;
+  }
 
-    // Broadcast the structured data event if we have that enabled.
-    // This is the way that the outside world (all clients) get access
-    // to this data.  This plugin sets policy as to whether we do that.
-    DebuggerSP debugger_sp =
-        process.GetTarget().GetDebugger().shared_from_this();
-    auto options_sp = GetGlobalEnableOptions(debugger_sp);
-    if (options_sp && options_sp->GetBroadcastEvents())
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() broadcasting event",
-                        __FUNCTION__);
-        process.BroadcastStructuredData(object_sp, shared_from_this());
-    }
+  // Ignore any data that isn't for us.
+  if (type_name != GetDarwinLogTypeName()) {
+    if (log)
+      log->Printf("StructuredDataDarwinLog::%s() StructuredData type "
+                  "expected to be %s but was %s, ignoring",
+                  __FUNCTION__, GetDarwinLogTypeName().AsCString(),
+                  type_name.AsCString());
+    return;
+  }
+
+  // Broadcast the structured data event if we have that enabled.
+  // This is the way that the outside world (all clients) get access
+  // to this data.  This plugin sets policy as to whether we do that.
+  DebuggerSP debugger_sp = process.GetTarget().GetDebugger().shared_from_this();
+  auto options_sp = GetGlobalEnableOptions(debugger_sp);
+  if (options_sp && options_sp->GetBroadcastEvents()) {
+    if (log)
+      log->Printf("StructuredDataDarwinLog::%s() broadcasting event",
+                  __FUNCTION__);
+    process.BroadcastStructuredData(object_sp, shared_from_this());
+  }
 
-    // Later, hang on to a configurable amount of these and allow commands
-    // to inspect, including showing backtraces.
+  // Later, hang on to a configurable amount of these and allow commands
+  // to inspect, including showing backtraces.
 }
 
-static void
-SetErrorWithJSON(Error &error, const char *message,
-                 StructuredData::Object &object)
-{
-    if (!message)
-    {
-        error.SetErrorString("Internal error: message not set.");
-        return;
-    }
+static void SetErrorWithJSON(Error &error, const char *message,
+                             StructuredData::Object &object) {
+  if (!message) {
+    error.SetErrorString("Internal error: message not set.");
+    return;
+  }
 
-    StreamString object_stream;
-    object.Dump(object_stream);
-    object_stream.Flush();
+  StreamString object_stream;
+  object.Dump(object_stream);
+  object_stream.Flush();
 
-    error.SetErrorStringWithFormat("%s: %s", message,
-                                   object_stream.GetString().c_str());
+  error.SetErrorStringWithFormat("%s: %s", message,
+                                 object_stream.GetString().c_str());
 }
 
-Error
-StructuredDataDarwinLog::GetDescription(const StructuredData::ObjectSP
-                                        &object_sp,
-                                        lldb_private::Stream &stream)
-{
-    Error error;
+Error StructuredDataDarwinLog::GetDescription(
+    const StructuredData::ObjectSP &object_sp, lldb_private::Stream &stream) {
+  Error error;
 
-    if (!object_sp)
-    {
-        error.SetErrorString("No structured data.");
-        return error;
-    }
+  if (!object_sp) {
+    error.SetErrorString("No structured data.");
+    return error;
+  }
 
-    // Log message payload objects will be dictionaries.
-    const StructuredData::Dictionary *dictionary = object_sp->GetAsDictionary();
-    if (!dictionary)
-    {
-        SetErrorWithJSON(error, "Structured data should have been a dictionary "
-                         "but wasn't", *object_sp);
-        return error;
-    }
+  // Log message payload objects will be dictionaries.
+  const StructuredData::Dictionary *dictionary = object_sp->GetAsDictionary();
+  if (!dictionary) {
+    SetErrorWithJSON(error, "Structured data should have been a dictionary "
+                            "but wasn't",
+                     *object_sp);
+    return error;
+  }
 
-    // Validate this is really a message for our plugin.
-    ConstString type_name;
-    if (!dictionary->GetValueForKeyAsString("type", type_name))
-    {
-        SetErrorWithJSON(error, "Structured data doesn't contain mandatory "
-                         "type field", *object_sp);
-        return error;
-    }
+  // Validate this is really a message for our plugin.
+  ConstString type_name;
+  if (!dictionary->GetValueForKeyAsString("type", type_name)) {
+    SetErrorWithJSON(error, "Structured data doesn't contain mandatory "
+                            "type field",
+                     *object_sp);
+    return error;
+  }
 
-    if (type_name != GetDarwinLogTypeName())
-    {
-        // This is okay - it simply means the data we received is not a log
-        // message.  We'll just format it as is.
-        object_sp->Dump(stream);
-        return error;
-    }
+  if (type_name != GetDarwinLogTypeName()) {
+    // This is okay - it simply means the data we received is not a log
+    // message.  We'll just format it as is.
+    object_sp->Dump(stream);
+    return error;
+  }
 
-    // DarwinLog dictionaries store their data
-    // in an array with key name "events".
-    StructuredData::Array *events = nullptr;
-    if (!dictionary->GetValueForKeyAsArray("events", events) ||
-        !events)
-    {
-        SetErrorWithJSON(error, "Log structured data is missing mandatory "
-                         "'events' field, expected to be an array", *object_sp);
-        return error;
-    }
+  // DarwinLog dictionaries store their data
+  // in an array with key name "events".
+  StructuredData::Array *events = nullptr;
+  if (!dictionary->GetValueForKeyAsArray("events", events) || !events) {
+    SetErrorWithJSON(error, "Log structured data is missing mandatory "
+                            "'events' field, expected to be an array",
+                     *object_sp);
+    return error;
+  }
 
-    events->ForEach([&stream, &error, &object_sp, this]
-                    (StructuredData::Object *object)
-    {
-        if (!object)
-        {
-            // Invalid.  Stop iterating.
-            SetErrorWithJSON(error, "Log event entry is null", *object_sp);
-            return false;
+  events->ForEach(
+      [&stream, &error, &object_sp, this](StructuredData::Object *object) {
+        if (!object) {
+          // Invalid.  Stop iterating.
+          SetErrorWithJSON(error, "Log event entry is null", *object_sp);
+          return false;
         }
 
         auto event = object->GetAsDictionary();
-        if (!event)
-        {
-            // Invalid, stop iterating.
-            SetErrorWithJSON(error, "Log event is not a dictionary",
-                             *object_sp);
-            return false;
+        if (!event) {
+          // Invalid, stop iterating.
+          SetErrorWithJSON(error, "Log event is not a dictionary", *object_sp);
+          return false;
         }
 
         // If we haven't already grabbed the first timestamp
         // value, do that now.
-        if (!m_recorded_first_timestamp)
-        {
-            uint64_t timestamp = 0;
-            if (event->GetValueForKeyAsInteger("timestamp",
-                                        timestamp))
-            {
-                m_first_timestamp_seen = timestamp;
-                m_recorded_first_timestamp = true;
-            }
+        if (!m_recorded_first_timestamp) {
+          uint64_t timestamp = 0;
+          if (event->GetValueForKeyAsInteger("timestamp", timestamp)) {
+            m_first_timestamp_seen = timestamp;
+            m_recorded_first_timestamp = true;
+          }
         }
 
         HandleDisplayOfEvent(*event, stream);
         return true;
-    });
+      });
 
-    stream.Flush();
-    return error;
+  stream.Flush();
+  return error;
 }
 
-bool
-StructuredDataDarwinLog::GetEnabled(const ConstString &type_name) const
-{
-    if (type_name == GetStaticPluginName())
-        return m_is_enabled;
-    else
-        return false;
+bool StructuredDataDarwinLog::GetEnabled(const ConstString &type_name) const {
+  if (type_name == GetStaticPluginName())
+    return m_is_enabled;
+  else
+    return false;
 }
 
-void
-StructuredDataDarwinLog::SetEnabled(bool enabled)
-{
-    m_is_enabled = enabled;
+void StructuredDataDarwinLog::SetEnabled(bool enabled) {
+  m_is_enabled = enabled;
 }
 
-void
-StructuredDataDarwinLog::ModulesDidLoad(Process &process,
-                                        ModuleList &module_list)
-{
-    Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+void StructuredDataDarwinLog::ModulesDidLoad(Process &process,
+                                             ModuleList &module_list) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log)
+    log->Printf("StructuredDataDarwinLog::%s called (process uid %u)",
+                __FUNCTION__, process.GetUniqueID());
+
+  // Check if we should enable the darwin log support on startup/attach.
+  if (!GetGlobalProperties()->GetEnableOnStartup() &&
+      !s_is_explicitly_enabled) {
+    // We're neither auto-enabled or explicitly enabled, so we shouldn't
+    // try to enable here.
     if (log)
-        log->Printf("StructuredDataDarwinLog::%s called (process uid %u)",
+      log->Printf("StructuredDataDarwinLog::%s not applicable, we're not "
+                  "enabled (process uid %u)",
+                  __FUNCTION__, process.GetUniqueID());
+    return;
+  }
+
+  // If we already added the breakpoint, we've got nothing left to do.
+  {
+    std::lock_guard<std::mutex> locker(m_added_breakpoint_mutex);
+    if (m_added_breakpoint) {
+      if (log)
+        log->Printf("StructuredDataDarwinLog::%s process uid %u's "
+                    "post-libtrace-init breakpoint is already set",
                     __FUNCTION__, process.GetUniqueID());
-
-    // Check if we should enable the darwin log support on startup/attach.
-    if (!GetGlobalProperties()->GetEnableOnStartup() &&
-        !s_is_explicitly_enabled)
-    {
-        // We're neither auto-enabled or explicitly enabled, so we shouldn't
-        // try to enable here.
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s not applicable, we're not "
-                        "enabled (process uid %u)", __FUNCTION__,
-                        process.GetUniqueID());
-        return;
-    }
-
-    // If we already added the breakpoint, we've got nothing left to do.
-    {
-        std::lock_guard<std::mutex> locker(m_added_breakpoint_mutex);
-        if (m_added_breakpoint)
-        {
-            if (log)
-                log->Printf("StructuredDataDarwinLog::%s process uid %u's "
-                            "post-libtrace-init breakpoint is already set",
-                            __FUNCTION__, process.GetUniqueID());
-            return;
-        }
-    }
-
-    // The logging support module name, specifies the name of
-    // the image name that must be loaded into the debugged process before
-    // we can try to enable logging.
-    const char *logging_module_cstr =
-        GetGlobalProperties()->GetLoggingModuleName();
-    if (!logging_module_cstr || (logging_module_cstr[0] == 0))
-    {
-        // We need this.  Bail.
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s no logging module name "
-                        "specified, we don't know where to set a breakpoint "
-                        "(process uid %u)", __FUNCTION__,
-                        process.GetUniqueID());
-        return;
-    }
-
-    const ConstString logging_module_name =
-        ConstString(logging_module_cstr);
-
-    // We need to see libtrace in the list of modules before we can enable
-    // tracing for the target process.
-    bool found_logging_support_module = false;
-    for (size_t i = 0; i < module_list.GetSize(); ++i)
-    {
-        auto module_sp = module_list.GetModuleAtIndex(i);
-        if (!module_sp)
-            continue;
-
-        auto &file_spec = module_sp->GetFileSpec();
-        found_logging_support_module =
-            (file_spec.GetLastPathComponent() == logging_module_name);
-        if (found_logging_support_module)
-            break;
+      return;
     }
+  }
 
-    if (!found_logging_support_module)
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s logging module %s "
-                        "has not yet been loaded, can't set a breakpoint "
-                        "yet (process uid %u)", __FUNCTION__,
-                        logging_module_name.AsCString(),
-                        process.GetUniqueID());
-        return;
-    }
+  // The logging support module name, specifies the name of
+  // the image name that must be loaded into the debugged process before
+  // we can try to enable logging.
+  const char *logging_module_cstr =
+      GetGlobalProperties()->GetLoggingModuleName();
+  if (!logging_module_cstr || (logging_module_cstr[0] == 0)) {
+    // We need this.  Bail.
+    if (log)
+      log->Printf("StructuredDataDarwinLog::%s no logging module name "
+                  "specified, we don't know where to set a breakpoint "
+                  "(process uid %u)",
+                  __FUNCTION__, process.GetUniqueID());
+    return;
+  }
+
+  const ConstString logging_module_name = ConstString(logging_module_cstr);
+
+  // We need to see libtrace in the list of modules before we can enable
+  // tracing for the target process.
+  bool found_logging_support_module = false;
+  for (size_t i = 0; i < module_list.GetSize(); ++i) {
+    auto module_sp = module_list.GetModuleAtIndex(i);
+    if (!module_sp)
+      continue;
+
+    auto &file_spec = module_sp->GetFileSpec();
+    found_logging_support_module =
+        (file_spec.GetLastPathComponent() == logging_module_name);
+    if (found_logging_support_module)
+      break;
+  }
 
-    // Time to enqueue the breakpoint so we can wait for logging support
-    // to be initialized before we try to tap the libtrace stream.
-    AddInitCompletionHook(process);
+  if (!found_logging_support_module) {
     if (log)
-        log->Printf("StructuredDataDarwinLog::%s post-init hook breakpoint "
-                    "set for logging module %s (process uid %u)", __FUNCTION__,
-                    logging_module_name.AsCString(),
-                    process.GetUniqueID());
-
-    // We need to try the enable here as well, which will succeed
-    // in the event that we're attaching to (rather than launching) the
-    // process and the process is already past initialization time.  In that
-    // case, the completion breakpoint will never get hit and therefore won't
-    // start that way.  It doesn't hurt much beyond a bit of bandwidth
-    // if we end up doing this twice.  It hurts much more if we don't get
-    // the logging enabled when the user expects it.
-    EnableNow();
+      log->Printf("StructuredDataDarwinLog::%s logging module %s "
+                  "has not yet been loaded, can't set a breakpoint "
+                  "yet (process uid %u)",
+                  __FUNCTION__, logging_module_name.AsCString(),
+                  process.GetUniqueID());
+    return;
+  }
+
+  // Time to enqueue the breakpoint so we can wait for logging support
+  // to be initialized before we try to tap the libtrace stream.
+  AddInitCompletionHook(process);
+  if (log)
+    log->Printf("StructuredDataDarwinLog::%s post-init hook breakpoint "
+                "set for logging module %s (process uid %u)",
+                __FUNCTION__, logging_module_name.AsCString(),
+                process.GetUniqueID());
+
+  // We need to try the enable here as well, which will succeed
+  // in the event that we're attaching to (rather than launching) the
+  // process and the process is already past initialization time.  In that
+  // case, the completion breakpoint will never get hit and therefore won't
+  // start that way.  It doesn't hurt much beyond a bit of bandwidth
+  // if we end up doing this twice.  It hurts much more if we don't get
+  // the logging enabled when the user expects it.
+  EnableNow();
 }
 
 #pragma mark -
@@ -1755,666 +1422,592 @@ StructuredDataDarwinLog::ModulesDidLoad(
 // Private constructors
 // -----------------------------------------------------------------------------
 
-StructuredDataDarwinLog::StructuredDataDarwinLog(const ProcessWP &process_wp) :
-    StructuredDataPlugin(process_wp),
-    m_recorded_first_timestamp(false),
-    m_first_timestamp_seen(0),
-    m_is_enabled(false),
-    m_added_breakpoint_mutex(),
-    m_added_breakpoint()
-{
-}
+StructuredDataDarwinLog::StructuredDataDarwinLog(const ProcessWP &process_wp)
+    : StructuredDataPlugin(process_wp), m_recorded_first_timestamp(false),
+      m_first_timestamp_seen(0), m_is_enabled(false),
+      m_added_breakpoint_mutex(), m_added_breakpoint() {}
 
 // -----------------------------------------------------------------------------
 // Private static methods
 // -----------------------------------------------------------------------------
 
 StructuredDataPluginSP
-StructuredDataDarwinLog::CreateInstance(Process &process)
-{
-    // Currently only Apple targets support the os_log/os_activity
-    // protocol.
-    if (process.GetTarget().GetArchitecture().GetTriple().getVendor() ==
-        llvm::Triple::VendorType::Apple)
-    {
-        auto process_wp = ProcessWP(process.shared_from_this());
-        return StructuredDataPluginSP(new StructuredDataDarwinLog(process_wp));
-    }
-    else
-    {
-        return StructuredDataPluginSP();
-    }
-}
-
-void
-StructuredDataDarwinLog::DebuggerInitialize(Debugger &debugger)
-{
-    // Setup parent class first.
-    StructuredDataPlugin::InitializeBasePluginForDebugger(debugger);
-
-    // Get parent command.
-    auto &interpreter = debugger.GetCommandInterpreter();
-    std::string parent_command_text = "plugin structured-data";
-    auto parent_command =
-        interpreter.GetCommandObjectForCommand(parent_command_text);
-    if (!parent_command)
-    {
-        // Ut oh, parent failed to create parent command.
-        // TODO log
-        return;
-    }
-
-    auto command_name = "darwin-log";
-    auto command_sp = CommandObjectSP(new BaseCommand(interpreter));
-    bool result = parent_command->LoadSubCommand(command_name, command_sp);
-    if (!result)
-    {
-        // TODO log it once we setup structured data logging
-    }
-
-    if (!PluginManager::GetSettingForPlatformPlugin(debugger,
-                          StructuredDataDarwinLogProperties::GetSettingName()))
-    {
-        const bool is_global_setting = true;
-        PluginManager::CreateSettingForStructuredDataPlugin(debugger,
-                                    GetGlobalProperties()->GetValueProperties(),
-                                    ConstString ("Properties for the darwin-log"
-                                                 " plug-in."),
-                                    is_global_setting);
-    }
-
-}
-
-Error
-StructuredDataDarwinLog::FilterLaunchInfo(ProcessLaunchInfo &launch_info,
-                                          Target *target)
-{
-    Error error;
-
-    // If we're not debugging this launched process, there's nothing for us
-    // to do here.
-    if (!launch_info.GetFlags().AnySet(eLaunchFlagDebug))
-        return error;
-
-    // Darwin os_log() support automatically adds debug-level and info-level
-    // messages when a debugger is attached to a process.  However, with
-    // integrated suppport for debugging built into the command-line LLDB,
-    // the user may specifically set to *not* include debug-level and info-level
-    // content.  When the user is using the integrated log support, we want
-    // to put the kabosh on that automatic adding of info and debug level.
-    // This is done by adding an environment variable to the process on launch.
-    // (This also means it is not possible to suppress this behavior if
-    // attaching to an already-running app).
-    // Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
-
-    // If the target architecture is not one that supports DarwinLog, we have
-    // nothing to do here.
-    auto &triple = target ? target->GetArchitecture().GetTriple() :
-        launch_info.GetArchitecture().GetTriple();
-    if (triple.getVendor() !=
-        llvm::Triple::Apple)
-    {
-        return error;
-    }
-
-    // If DarwinLog is not enabled (either by explicit user command or via
-    // the auto-enable option), then we have nothing to do.
-    if (!GetGlobalProperties()->GetEnableOnStartup() &&
-        !s_is_explicitly_enabled)
-    {
-        // Nothing to do, DarwinLog is not enabled.
-        return error;
-    }
-
-    // If we don't have parsed configuration info, that implies we have
-    // enable-on-startup set up, but we haven't yet attempted to run the
-    // enable command.
-    if (!target)
-    {
-        // We really can't do this without a target.  We need to be able
-        // to get to the debugger to get the proper options to do this right.
-        // TODO log.
-        error.SetErrorString("requires a target to auto-enable DarwinLog.");
-        return error;
-    }
-
-    DebuggerSP debugger_sp = target->GetDebugger().shared_from_this();
-    auto options_sp = GetGlobalEnableOptions(debugger_sp);
-    if (!options_sp && debugger_sp)
-    {
-        options_sp = ParseAutoEnableOptions(error, *debugger_sp.get());
-        if (!options_sp || !error.Success())
-            return error;
-
-        // We already parsed the options, save them now so we don't generate
-        // them again until the user runs the command manually.
-        SetGlobalEnableOptions(debugger_sp, options_sp);
-    }
+StructuredDataDarwinLog::CreateInstance(Process &process) {
+  // Currently only Apple targets support the os_log/os_activity
+  // protocol.
+  if (process.GetTarget().GetArchitecture().GetTriple().getVendor() ==
+      llvm::Triple::VendorType::Apple) {
+    auto process_wp = ProcessWP(process.shared_from_this());
+    return StructuredDataPluginSP(new StructuredDataDarwinLog(process_wp));
+  } else {
+    return StructuredDataPluginSP();
+  }
+}
+
+void StructuredDataDarwinLog::DebuggerInitialize(Debugger &debugger) {
+  // Setup parent class first.
+  StructuredDataPlugin::InitializeBasePluginForDebugger(debugger);
+
+  // Get parent command.
+  auto &interpreter = debugger.GetCommandInterpreter();
+  std::string parent_command_text = "plugin structured-data";
+  auto parent_command =
+      interpreter.GetCommandObjectForCommand(parent_command_text);
+  if (!parent_command) {
+    // Ut oh, parent failed to create parent command.
+    // TODO log
+    return;
+  }
+
+  auto command_name = "darwin-log";
+  auto command_sp = CommandObjectSP(new BaseCommand(interpreter));
+  bool result = parent_command->LoadSubCommand(command_name, command_sp);
+  if (!result) {
+    // TODO log it once we setup structured data logging
+  }
+
+  if (!PluginManager::GetSettingForPlatformPlugin(
+          debugger, StructuredDataDarwinLogProperties::GetSettingName())) {
+    const bool is_global_setting = true;
+    PluginManager::CreateSettingForStructuredDataPlugin(
+        debugger, GetGlobalProperties()->GetValueProperties(),
+        ConstString("Properties for the darwin-log"
+                    " plug-in."),
+        is_global_setting);
+  }
+}
+
+Error StructuredDataDarwinLog::FilterLaunchInfo(ProcessLaunchInfo &launch_info,
+                                                Target *target) {
+  Error error;
+
+  // If we're not debugging this launched process, there's nothing for us
+  // to do here.
+  if (!launch_info.GetFlags().AnySet(eLaunchFlagDebug))
+    return error;
 
-    auto &env_vars = launch_info.GetEnvironmentEntries();
-    if (!options_sp->GetEchoToStdErr())
-    {
-        // The user doesn't want to see os_log/NSLog messages echo to stderr.
-        // That mechanism is entirely separate from the DarwinLog support.
-        // By default we don't want to get it via stderr, because that would
-        // be in duplicate of the explicit log support here.
-
-        // Here we need to strip out any OS_ACTIVITY_DT_MODE setting to prevent
-        // echoing of os_log()/NSLog() to stderr in the target program.
-        size_t argument_index;
-        if (env_vars.ContainsEnvironmentVariable("OS_ACTIVITY_DT_MODE",
-                                                 &argument_index))
-            env_vars.DeleteArgumentAtIndex(argument_index);
-
-        // We will also set the env var that tells any downstream launcher
-        // from adding OS_ACTIVITY_DT_MODE.
-        env_vars.AddOrReplaceEnvironmentVariable(
-                                       "IDE_DISABLED_OS_ACTIVITY_DT_MODE", "1");
-    }
-
-    // Set the OS_ACTIVITY_MODE env var appropriately to enable/disable
-    // debug and info level messages.
-    const char *env_var_value;
-    if (options_sp->GetIncludeDebugLevel())
-        env_var_value = "debug";
-    else if (options_sp->GetIncludeInfoLevel())
-        env_var_value = "info";
-    else
-        env_var_value = "";
+  // Darwin os_log() support automatically adds debug-level and info-level
+  // messages when a debugger is attached to a process.  However, with
+  // integrated suppport for debugging built into the command-line LLDB,
+  // the user may specifically set to *not* include debug-level and info-level
+  // content.  When the user is using the integrated log support, we want
+  // to put the kabosh on that automatic adding of info and debug level.
+  // This is done by adding an environment variable to the process on launch.
+  // (This also means it is not possible to suppress this behavior if
+  // attaching to an already-running app).
+  // Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
+
+  // If the target architecture is not one that supports DarwinLog, we have
+  // nothing to do here.
+  auto &triple = target ? target->GetArchitecture().GetTriple()
+                        : launch_info.GetArchitecture().GetTriple();
+  if (triple.getVendor() != llvm::Triple::Apple) {
+    return error;
+  }
 
-    if (env_var_value)
-    {
-        const char *env_var_name = "OS_ACTIVITY_MODE";
-        launch_info.GetEnvironmentEntries()
-            .AddOrReplaceEnvironmentVariable(env_var_name, env_var_value);
-    }
+  // If DarwinLog is not enabled (either by explicit user command or via
+  // the auto-enable option), then we have nothing to do.
+  if (!GetGlobalProperties()->GetEnableOnStartup() &&
+      !s_is_explicitly_enabled) {
+    // Nothing to do, DarwinLog is not enabled.
+    return error;
+  }
 
+  // If we don't have parsed configuration info, that implies we have
+  // enable-on-startup set up, but we haven't yet attempted to run the
+  // enable command.
+  if (!target) {
+    // We really can't do this without a target.  We need to be able
+    // to get to the debugger to get the proper options to do this right.
+    // TODO log.
+    error.SetErrorString("requires a target to auto-enable DarwinLog.");
     return error;
-}
+  }
 
-bool
-StructuredDataDarwinLog::InitCompletionHookCallback(void *baton,
-                                              StoppointCallbackContext *context,
-                                              lldb::user_id_t break_id,
-                                              lldb::user_id_t break_loc_id)
-{
-    // We hit the init function.  We now want to enqueue our new thread plan,
-    // which will in turn enqueue a StepOut thread plan. When the StepOut
-    // finishes and control returns to our new thread plan, that is the time
-    // when we can execute our logic to enable the logging support.
+  DebuggerSP debugger_sp = target->GetDebugger().shared_from_this();
+  auto options_sp = GetGlobalEnableOptions(debugger_sp);
+  if (!options_sp && debugger_sp) {
+    options_sp = ParseAutoEnableOptions(error, *debugger_sp.get());
+    if (!options_sp || !error.Success())
+      return error;
+
+    // We already parsed the options, save them now so we don't generate
+    // them again until the user runs the command manually.
+    SetGlobalEnableOptions(debugger_sp, options_sp);
+  }
+
+  auto &env_vars = launch_info.GetEnvironmentEntries();
+  if (!options_sp->GetEchoToStdErr()) {
+    // The user doesn't want to see os_log/NSLog messages echo to stderr.
+    // That mechanism is entirely separate from the DarwinLog support.
+    // By default we don't want to get it via stderr, because that would
+    // be in duplicate of the explicit log support here.
+
+    // Here we need to strip out any OS_ACTIVITY_DT_MODE setting to prevent
+    // echoing of os_log()/NSLog() to stderr in the target program.
+    size_t argument_index;
+    if (env_vars.ContainsEnvironmentVariable("OS_ACTIVITY_DT_MODE",
+                                             &argument_index))
+      env_vars.DeleteArgumentAtIndex(argument_index);
+
+    // We will also set the env var that tells any downstream launcher
+    // from adding OS_ACTIVITY_DT_MODE.
+    env_vars.AddOrReplaceEnvironmentVariable("IDE_DISABLED_OS_ACTIVITY_DT_MODE",
+                                             "1");
+  }
+
+  // Set the OS_ACTIVITY_MODE env var appropriately to enable/disable
+  // debug and info level messages.
+  const char *env_var_value;
+  if (options_sp->GetIncludeDebugLevel())
+    env_var_value = "debug";
+  else if (options_sp->GetIncludeInfoLevel())
+    env_var_value = "info";
+  else
+    env_var_value = "";
+
+  if (env_var_value) {
+    const char *env_var_name = "OS_ACTIVITY_MODE";
+    launch_info.GetEnvironmentEntries().AddOrReplaceEnvironmentVariable(
+        env_var_name, env_var_value);
+  }
+
+  return error;
+}
+
+bool StructuredDataDarwinLog::InitCompletionHookCallback(
+    void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id,
+    lldb::user_id_t break_loc_id) {
+  // We hit the init function.  We now want to enqueue our new thread plan,
+  // which will in turn enqueue a StepOut thread plan. When the StepOut
+  // finishes and control returns to our new thread plan, that is the time
+  // when we can execute our logic to enable the logging support.
+
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log)
+    log->Printf("StructuredDataDarwinLog::%s() called", __FUNCTION__);
 
-    Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
+  // Get the current thread.
+  if (!context) {
     if (log)
-        log->Printf("StructuredDataDarwinLog::%s() called", __FUNCTION__);
+      log->Printf("StructuredDataDarwinLog::%s() warning: no context, "
+                  "ignoring",
+                  __FUNCTION__);
+    return false;
+  }
 
-    // Get the current thread.
-    if (!context)
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() warning: no context, "
-                        "ignoring", __FUNCTION__);
-        return false;
-    }
+  // Get the plugin from the process.
+  auto process_sp = context->exe_ctx_ref.GetProcessSP();
+  if (!process_sp) {
+    if (log)
+      log->Printf("StructuredDataDarwinLog::%s() warning: invalid "
+                  "process in context, ignoring",
+                  __FUNCTION__);
+    return false;
+  }
+  if (log)
+    log->Printf("StructuredDataDarwinLog::%s() call is for process uid %d",
+                __FUNCTION__, process_sp->GetUniqueID());
 
-    // Get the plugin from the process.
-    auto process_sp = context->exe_ctx_ref.GetProcessSP();
-    if (!process_sp)
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() warning: invalid "
-                        "process in context, ignoring", __FUNCTION__);
-        return false;
-    }
+  auto plugin_sp = process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
+  if (!plugin_sp) {
     if (log)
-        log->Printf("StructuredDataDarwinLog::%s() call is for process uid %d",
-                    __FUNCTION__, process_sp->GetUniqueID());
+      log->Printf("StructuredDataDarwinLog::%s() warning: no plugin for "
+                  "feature %s in process uid %u",
+                  __FUNCTION__, GetDarwinLogTypeName().AsCString(),
+                  process_sp->GetUniqueID());
+    return false;
+  }
 
-    auto plugin_sp =
-        process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
-    if (!plugin_sp)
-    {
+  // Create the callback for when the thread plan completes.
+  bool called_enable_method = false;
+  const auto process_uid = process_sp->GetUniqueID();
+
+  std::weak_ptr<StructuredDataPlugin> plugin_wp(plugin_sp);
+  ThreadPlanCallOnFunctionExit::Callback callback =
+      [plugin_wp, &called_enable_method, log, process_uid]() {
         if (log)
-            log->Printf("StructuredDataDarwinLog::%s() warning: no plugin for "
-                        "feature %s in process uid %u",
-                        __FUNCTION__, GetDarwinLogTypeName().AsCString(),
-                        process_sp->GetUniqueID());
-        return false;
-    }
-
-    // Create the callback for when the thread plan completes.
-    bool called_enable_method = false;
-    const auto process_uid = process_sp->GetUniqueID();
-
-    std::weak_ptr<StructuredDataPlugin> plugin_wp(plugin_sp);
-    ThreadPlanCallOnFunctionExit::Callback callback =
-        [plugin_wp, &called_enable_method, log, process_uid]() {
-            if (log)
-                log->Printf("StructuredDataDarwinLog::post-init callback: "
-                            "called (process uid %u)", process_uid);
-
-            auto strong_plugin_sp = plugin_wp.lock();
-            if (!strong_plugin_sp)
-            {
-                if (log)
-                    log->Printf("StructuredDataDarwinLog::post-init callback: "
-                                "plugin no longer exists, ignoring (process "
-                                "uid %u)", process_uid);
-                return;
-            }
-            // Make sure we only call it once, just in case the
-            // thread plan hits the breakpoint twice.
-            if (!called_enable_method)
-            {
-                if (log)
-                    log->Printf("StructuredDataDarwinLog::post-init callback: "
-                                "calling EnableNow() (process uid %u)",
-                                process_uid);
-                static_cast<StructuredDataDarwinLog*>(strong_plugin_sp.get())
-                    ->EnableNow();
-                called_enable_method = true;
-            }
-            else
-            {
-                // Our breakpoint was hit more than once.  Unexpected but
-                // no harm done.  Log it.
-                if (log)
-                    log->Printf("StructuredDataDarwinLog::post-init callback: "
-                                "skipping EnableNow(), already called by "
-                                "callback [we hit this more than once] "
-                                "(process uid %u)", process_uid);
-            }
-        };
-
-    // Grab the current thread.
-    auto thread_sp = context->exe_ctx_ref.GetThreadSP();
-    if (!thread_sp)
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() warning: failed to "
-                        "retrieve the current thread from the execution "
-                        "context, nowhere to run the thread plan (process uid "
-                        "%u)", __FUNCTION__, process_sp->GetUniqueID());
-        return false;
-    }
-
-    // Queue the thread plan.
-    auto thread_plan_sp
-        = ThreadPlanSP(new ThreadPlanCallOnFunctionExit(*thread_sp.get(),
-                                                        callback));
-    const bool abort_other_plans = false;
-    thread_sp->QueueThreadPlan(thread_plan_sp, abort_other_plans);
+          log->Printf("StructuredDataDarwinLog::post-init callback: "
+                      "called (process uid %u)",
+                      process_uid);
+
+        auto strong_plugin_sp = plugin_wp.lock();
+        if (!strong_plugin_sp) {
+          if (log)
+            log->Printf("StructuredDataDarwinLog::post-init callback: "
+                        "plugin no longer exists, ignoring (process "
+                        "uid %u)",
+                        process_uid);
+          return;
+        }
+        // Make sure we only call it once, just in case the
+        // thread plan hits the breakpoint twice.
+        if (!called_enable_method) {
+          if (log)
+            log->Printf("StructuredDataDarwinLog::post-init callback: "
+                        "calling EnableNow() (process uid %u)",
+                        process_uid);
+          static_cast<StructuredDataDarwinLog *>(strong_plugin_sp.get())
+              ->EnableNow();
+          called_enable_method = true;
+        } else {
+          // Our breakpoint was hit more than once.  Unexpected but
+          // no harm done.  Log it.
+          if (log)
+            log->Printf("StructuredDataDarwinLog::post-init callback: "
+                        "skipping EnableNow(), already called by "
+                        "callback [we hit this more than once] "
+                        "(process uid %u)",
+                        process_uid);
+        }
+      };
+
+  // Grab the current thread.
+  auto thread_sp = context->exe_ctx_ref.GetThreadSP();
+  if (!thread_sp) {
     if (log)
-        log->Printf("StructuredDataDarwinLog::%s() queuing thread plan on "
-                    "trace library init method entry (process uid %u)",
-                    __FUNCTION__, process_sp->GetUniqueID());
-
-    // We return false here to indicate that it isn't a public stop.
+      log->Printf("StructuredDataDarwinLog::%s() warning: failed to "
+                  "retrieve the current thread from the execution "
+                  "context, nowhere to run the thread plan (process uid "
+                  "%u)",
+                  __FUNCTION__, process_sp->GetUniqueID());
     return false;
-}
+  }
 
-void
-StructuredDataDarwinLog::AddInitCompletionHook(Process &process)
-{
-    Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    if (log)
-        log->Printf("StructuredDataDarwinLog::%s() called (process uid %u)",
+  // Queue the thread plan.
+  auto thread_plan_sp = ThreadPlanSP(
+      new ThreadPlanCallOnFunctionExit(*thread_sp.get(), callback));
+  const bool abort_other_plans = false;
+  thread_sp->QueueThreadPlan(thread_plan_sp, abort_other_plans);
+  if (log)
+    log->Printf("StructuredDataDarwinLog::%s() queuing thread plan on "
+                "trace library init method entry (process uid %u)",
+                __FUNCTION__, process_sp->GetUniqueID());
+
+  // We return false here to indicate that it isn't a public stop.
+  return false;
+}
+
+void StructuredDataDarwinLog::AddInitCompletionHook(Process &process) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log)
+    log->Printf("StructuredDataDarwinLog::%s() called (process uid %u)",
+                __FUNCTION__, process.GetUniqueID());
+
+  // Make sure we haven't already done this.
+  {
+    std::lock_guard<std::mutex> locker(m_added_breakpoint_mutex);
+    if (m_added_breakpoint) {
+      if (log)
+        log->Printf("StructuredDataDarwinLog::%s() ignoring request, "
+                    "breakpoint already set (process uid %u)",
                     __FUNCTION__, process.GetUniqueID());
-
-    // Make sure we haven't already done this.
-    {
-        std::lock_guard<std::mutex> locker(m_added_breakpoint_mutex);
-        if (m_added_breakpoint)
-        {
-            if (log)
-                log->Printf("StructuredDataDarwinLog::%s() ignoring request, "
-                            "breakpoint already set (process uid %u)",
-                            __FUNCTION__, process.GetUniqueID());
-            return;
-        }
-
-        // We're about to do this, don't let anybody else try to do it.
-        m_added_breakpoint = true;
-    }
-
-    // Set a breakpoint for the process that will kick in when libtrace
-    // has finished its initialization.
-    Target &target = process.GetTarget();
-
-    // Build up the module list.
-    FileSpecList module_spec_list;
-    auto module_file_spec =
-        FileSpec(GetGlobalProperties()->GetLoggingModuleName(), false);
-    module_spec_list.Append(module_file_spec);
-
-    // We aren't specifying a source file set.
-    FileSpecList *source_spec_list = nullptr;
-
-    const char *func_name = "_libtrace_init";
-    const lldb::addr_t offset = 0;
-    const LazyBool skip_prologue = eLazyBoolCalculate;
-    // This is an internal breakpoint - the user shouldn't see it.
-    const bool internal = true;
-    const bool hardware = false;
-
-    auto breakpoint_sp =
-        target.CreateBreakpoint(&module_spec_list, source_spec_list, func_name,
-                                eFunctionNameTypeFull, eLanguageTypeC, offset,
-                                skip_prologue, internal, hardware);
-    if (!breakpoint_sp)
-    {
-        // Huh?  Bail here.
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() failed to set "
-                        "breakpoint in module %s, function %s (process uid %u)",
-                        __FUNCTION__,
-                        GetGlobalProperties()->GetLoggingModuleName(),
-                        func_name, process.GetUniqueID());
-        return;
+      return;
     }
 
-    // Set our callback.
-    breakpoint_sp->SetCallback(InitCompletionHookCallback, nullptr);
+    // We're about to do this, don't let anybody else try to do it.
+    m_added_breakpoint = true;
+  }
+
+  // Set a breakpoint for the process that will kick in when libtrace
+  // has finished its initialization.
+  Target &target = process.GetTarget();
+
+  // Build up the module list.
+  FileSpecList module_spec_list;
+  auto module_file_spec =
+      FileSpec(GetGlobalProperties()->GetLoggingModuleName(), false);
+  module_spec_list.Append(module_file_spec);
+
+  // We aren't specifying a source file set.
+  FileSpecList *source_spec_list = nullptr;
+
+  const char *func_name = "_libtrace_init";
+  const lldb::addr_t offset = 0;
+  const LazyBool skip_prologue = eLazyBoolCalculate;
+  // This is an internal breakpoint - the user shouldn't see it.
+  const bool internal = true;
+  const bool hardware = false;
+
+  auto breakpoint_sp = target.CreateBreakpoint(
+      &module_spec_list, source_spec_list, func_name, eFunctionNameTypeFull,
+      eLanguageTypeC, offset, skip_prologue, internal, hardware);
+  if (!breakpoint_sp) {
+    // Huh?  Bail here.
     if (log)
-        log->Printf("StructuredDataDarwinLog::%s() breakpoint set in module %s,"
-                    "function %s (process uid %u)",
-                    __FUNCTION__,
-                    GetGlobalProperties()->GetLoggingModuleName(),
-                    func_name, process.GetUniqueID());
-}
+      log->Printf("StructuredDataDarwinLog::%s() failed to set "
+                  "breakpoint in module %s, function %s (process uid %u)",
+                  __FUNCTION__, GetGlobalProperties()->GetLoggingModuleName(),
+                  func_name, process.GetUniqueID());
+    return;
+  }
+
+  // Set our callback.
+  breakpoint_sp->SetCallback(InitCompletionHookCallback, nullptr);
+  if (log)
+    log->Printf("StructuredDataDarwinLog::%s() breakpoint set in module %s,"
+                "function %s (process uid %u)",
+                __FUNCTION__, GetGlobalProperties()->GetLoggingModuleName(),
+                func_name, process.GetUniqueID());
+}
+
+void StructuredDataDarwinLog::DumpTimestamp(Stream &stream,
+                                            uint64_t timestamp) {
+  const uint64_t delta_nanos = timestamp - m_first_timestamp_seen;
+
+  const uint64_t hours = delta_nanos / NANOS_PER_HOUR;
+  uint64_t nanos_remaining = delta_nanos % NANOS_PER_HOUR;
 
-void
-StructuredDataDarwinLog::DumpTimestamp(Stream &stream, uint64_t timestamp)
-{
-    const uint64_t delta_nanos = timestamp - m_first_timestamp_seen;
+  const uint64_t minutes = nanos_remaining / NANOS_PER_MINUTE;
+  nanos_remaining = nanos_remaining % NANOS_PER_MINUTE;
 
-    const uint64_t hours = delta_nanos / NANOS_PER_HOUR;
-    uint64_t nanos_remaining = delta_nanos % NANOS_PER_HOUR;
+  const uint64_t seconds = nanos_remaining / NANOS_PER_SECOND;
+  nanos_remaining = nanos_remaining % NANOS_PER_SECOND;
 
-    const uint64_t minutes = nanos_remaining / NANOS_PER_MINUTE;
-    nanos_remaining = nanos_remaining % NANOS_PER_MINUTE;
-
-    const uint64_t seconds = nanos_remaining / NANOS_PER_SECOND;
-    nanos_remaining = nanos_remaining % NANOS_PER_SECOND;
-
-    stream.Printf("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64 ".%09" PRIu64,
-                  hours, minutes, seconds, nanos_remaining);
+  stream.Printf("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64 ".%09" PRIu64, hours,
+                minutes, seconds, nanos_remaining);
 }
 
 size_t
 StructuredDataDarwinLog::DumpHeader(Stream &output_stream,
-                                    const StructuredData::Dictionary &event)
-{
-    StreamString stream;
+                                    const StructuredData::Dictionary &event) {
+  StreamString stream;
 
-    ProcessSP process_sp = GetProcess();
-    if (!process_sp)
-    {
-        // TODO log
-        return 0;
-    }
-
-    DebuggerSP debugger_sp =
-        process_sp->GetTarget().GetDebugger().shared_from_this();
-    if (!debugger_sp)
-    {
-        // TODO log
-        return 0;
-    }
-
-    auto options_sp = GetGlobalEnableOptions(debugger_sp);
-    if (!options_sp)
-    {
-        // TODO log
-        return 0;
-    }
-
-    // Check if we should even display a header.
-    if (!options_sp->GetDisplayAnyHeaderFields())
-        return 0;
-
-    stream.PutChar('[');
-
-    int header_count = 0;
-    if (options_sp->GetDisplayTimestampRelative())
-    {
-        uint64_t timestamp = 0;
-        if (event.GetValueForKeyAsInteger("timestamp", timestamp))
-        {
-            DumpTimestamp(stream, timestamp);
-            ++header_count;
-        }
-    }
-
-    if (options_sp->GetDisplayActivityChain())
-    {
-        std::string activity_chain;
-        if (event.GetValueForKeyAsString("activity-chain", activity_chain) &&
-            !activity_chain.empty())
-        {
-            if (header_count > 0)
-                stream.PutChar(',');
-
-            // Switch over to the #if 0 branch once we figure out
-            // how we want to present settings for the tri-state of
-            // no-activity, activity (most derived only), or activity-chain.
+  ProcessSP process_sp = GetProcess();
+  if (!process_sp) {
+    // TODO log
+    return 0;
+  }
+
+  DebuggerSP debugger_sp =
+      process_sp->GetTarget().GetDebugger().shared_from_this();
+  if (!debugger_sp) {
+    // TODO log
+    return 0;
+  }
+
+  auto options_sp = GetGlobalEnableOptions(debugger_sp);
+  if (!options_sp) {
+    // TODO log
+    return 0;
+  }
+
+  // Check if we should even display a header.
+  if (!options_sp->GetDisplayAnyHeaderFields())
+    return 0;
+
+  stream.PutChar('[');
+
+  int header_count = 0;
+  if (options_sp->GetDisplayTimestampRelative()) {
+    uint64_t timestamp = 0;
+    if (event.GetValueForKeyAsInteger("timestamp", timestamp)) {
+      DumpTimestamp(stream, timestamp);
+      ++header_count;
+    }
+  }
+
+  if (options_sp->GetDisplayActivityChain()) {
+    std::string activity_chain;
+    if (event.GetValueForKeyAsString("activity-chain", activity_chain) &&
+        !activity_chain.empty()) {
+      if (header_count > 0)
+        stream.PutChar(',');
+
+// Switch over to the #if 0 branch once we figure out
+// how we want to present settings for the tri-state of
+// no-activity, activity (most derived only), or activity-chain.
 #if 1
-            // Display the activity chain, from parent-most to child-most
-            // activity, separated by a colon (:).
-            stream.PutCString("activity-chain=");
-            stream.PutCString(activity_chain.c_str());
+      // Display the activity chain, from parent-most to child-most
+      // activity, separated by a colon (:).
+      stream.PutCString("activity-chain=");
+      stream.PutCString(activity_chain.c_str());
 #else
-            if (GetGlobalProperties()->GetDisplayActivityChain())
-            {
-                // Display the activity chain, from parent-most to child-most
-                // activity, separated by a colon (:).
-                stream.PutCString("activity-chain=");
-                stream.PutCString(activity_chain.c_str());
-            }
-            else
-            {
-                // We're only displaying the child-most activity.
-                stream.PutCString("activity=");
-                auto pos = activity_chain.find_last_of(':');
-                if (pos == std::string::npos)
-                {
-                    // The activity chain only has one level, use the whole
-                    // thing.
-                    stream.PutCString(activity_chain.c_str());
-                }
-                else
-                {
-                    // Display everything after the final ':'.
-                    stream.PutCString(activity_chain.substr(pos+1).c_str());
-                }
-            }
-#endif
-            ++header_count;
+      if (GetGlobalProperties()->GetDisplayActivityChain()) {
+        // Display the activity chain, from parent-most to child-most
+        // activity, separated by a colon (:).
+        stream.PutCString("activity-chain=");
+        stream.PutCString(activity_chain.c_str());
+      } else {
+        // We're only displaying the child-most activity.
+        stream.PutCString("activity=");
+        auto pos = activity_chain.find_last_of(':');
+        if (pos == std::string::npos) {
+          // The activity chain only has one level, use the whole
+          // thing.
+          stream.PutCString(activity_chain.c_str());
+        } else {
+          // Display everything after the final ':'.
+          stream.PutCString(activity_chain.substr(pos + 1).c_str());
         }
+      }
+#endif
+      ++header_count;
     }
+  }
 
-    if (options_sp->GetDisplaySubsystem())
-    {
-        std::string subsystem;
-        if (event.GetValueForKeyAsString("subsystem",
-                                         subsystem) &&
-            !subsystem.empty())
-        {
-            if (header_count > 0)
-                stream.PutChar(',');
-            stream.PutCString("subsystem=");
-            stream.PutCString(subsystem.c_str());
-            ++header_count;
-        }
+  if (options_sp->GetDisplaySubsystem()) {
+    std::string subsystem;
+    if (event.GetValueForKeyAsString("subsystem", subsystem) &&
+        !subsystem.empty()) {
+      if (header_count > 0)
+        stream.PutChar(',');
+      stream.PutCString("subsystem=");
+      stream.PutCString(subsystem.c_str());
+      ++header_count;
     }
+  }
 
-    if (options_sp->GetDisplayCategory())
-    {
-        std::string category;
-        if (event.GetValueForKeyAsString("category",
-                                         category) &&
-            !category.empty())
-        {
-            if (header_count > 0)
-                stream.PutChar(',');
-            stream.PutCString("category=");
-            stream.PutCString(category.c_str());
-            ++header_count;
-        }
+  if (options_sp->GetDisplayCategory()) {
+    std::string category;
+    if (event.GetValueForKeyAsString("category", category) &&
+        !category.empty()) {
+      if (header_count > 0)
+        stream.PutChar(',');
+      stream.PutCString("category=");
+      stream.PutCString(category.c_str());
+      ++header_count;
     }
-    stream.PutCString("] ");
+  }
+  stream.PutCString("] ");
 
-    auto &result = stream.GetString();
-    output_stream.PutCString(result.c_str());
+  auto &result = stream.GetString();
+  output_stream.PutCString(result.c_str());
 
-    return result.size();
+  return result.size();
 }
 
-size_t
-StructuredDataDarwinLog::HandleDisplayOfEvent(const StructuredData::Dictionary
-                                              &event, Stream &stream)
-{
-    // Check the type of the event.
-    ConstString event_type;
-    if (!event.GetValueForKeyAsString("type", event_type))
-    {
-        // Hmm, we expected to get events that describe
-        // what they are.  Continue anyway.
-        return 0;
-    }
+size_t StructuredDataDarwinLog::HandleDisplayOfEvent(
+    const StructuredData::Dictionary &event, Stream &stream) {
+  // Check the type of the event.
+  ConstString event_type;
+  if (!event.GetValueForKeyAsString("type", event_type)) {
+    // Hmm, we expected to get events that describe
+    // what they are.  Continue anyway.
+    return 0;
+  }
 
-    if (event_type != GetLogEventType())
-        return 0;
+  if (event_type != GetLogEventType())
+    return 0;
 
-    size_t total_bytes = 0;
+  size_t total_bytes = 0;
 
-    // Grab the message content.
-    std::string message;
-    if (!event.GetValueForKeyAsString("message", message))
-        return true;
+  // Grab the message content.
+  std::string message;
+  if (!event.GetValueForKeyAsString("message", message))
+    return true;
 
-    // Display the log entry.
-    const auto len = message.length();
+  // Display the log entry.
+  const auto len = message.length();
 
-    total_bytes += DumpHeader(stream, event);
+  total_bytes += DumpHeader(stream, event);
 
-    stream.Write(message.c_str(), len);
-    total_bytes += len;
+  stream.Write(message.c_str(), len);
+  total_bytes += len;
 
-    // Add an end of line.
-    stream.PutChar('\n');
-    total_bytes += sizeof(char);
+  // Add an end of line.
+  stream.PutChar('\n');
+  total_bytes += sizeof(char);
 
-    return total_bytes;
+  return total_bytes;
 }
 
-void
-StructuredDataDarwinLog::EnableNow()
-{
-    Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
-    if (log)
-        log->Printf("StructuredDataDarwinLog::%s() called", __FUNCTION__);
+void StructuredDataDarwinLog::EnableNow() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+  if (log)
+    log->Printf("StructuredDataDarwinLog::%s() called", __FUNCTION__);
 
-    // Run the enable command.
-    auto process_sp = GetProcess();
-    if (!process_sp)
-    {
-        // Nothing to do.
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() warning: failed to get "
-                        "valid process, skipping", __FUNCTION__);
-        return;
-    }
+  // Run the enable command.
+  auto process_sp = GetProcess();
+  if (!process_sp) {
+    // Nothing to do.
+    if (log)
+      log->Printf("StructuredDataDarwinLog::%s() warning: failed to get "
+                  "valid process, skipping",
+                  __FUNCTION__);
+    return;
+  }
+  if (log)
+    log->Printf("StructuredDataDarwinLog::%s() call is for process uid %u",
+                __FUNCTION__, process_sp->GetUniqueID());
+
+  // If we have configuration data, we can directly enable it now.
+  // Otherwise, we need to run through the command interpreter to parse
+  // the auto-run options (which is the only way we get here without having
+  // already-parsed configuration data).
+  DebuggerSP debugger_sp =
+      process_sp->GetTarget().GetDebugger().shared_from_this();
+  if (!debugger_sp) {
     if (log)
-        log->Printf("StructuredDataDarwinLog::%s() call is for process uid %u",
+      log->Printf("StructuredDataDarwinLog::%s() warning: failed to get "
+                  "debugger shared pointer, skipping (process uid %u)",
+                  __FUNCTION__, process_sp->GetUniqueID());
+    return;
+  }
+
+  auto options_sp = GetGlobalEnableOptions(debugger_sp);
+  if (!options_sp) {
+    // We haven't run the enable command yet.  Just do that now, it'll
+    // take care of the rest.
+    auto &interpreter = debugger_sp->GetCommandInterpreter();
+    const bool success = RunEnableCommand(interpreter);
+    if (log) {
+      if (success)
+        log->Printf("StructuredDataDarwinLog::%s() ran enable command "
+                    "successfully for (process uid %u)",
+                    __FUNCTION__, process_sp->GetUniqueID());
+      else
+        log->Printf("StructuredDataDarwinLog::%s() error: running "
+                    "enable command failed (process uid %u)",
                     __FUNCTION__, process_sp->GetUniqueID());
-
-    // If we have configuration data, we can directly enable it now.
-    // Otherwise, we need to run through the command interpreter to parse
-    // the auto-run options (which is the only way we get here without having
-    // already-parsed configuration data).
-    DebuggerSP debugger_sp =
-    process_sp->GetTarget().GetDebugger().shared_from_this();
-    if (!debugger_sp)
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() warning: failed to get "
-                        "debugger shared pointer, skipping (process uid %u)",
-                        __FUNCTION__, process_sp->GetUniqueID());
-        return;
-    }
-
-    auto options_sp = GetGlobalEnableOptions(debugger_sp);
-    if (!options_sp)
-    {
-        // We haven't run the enable command yet.  Just do that now, it'll
-        // take care of the rest.
-        auto &interpreter = debugger_sp->GetCommandInterpreter();
-        const bool success = RunEnableCommand(interpreter);
-        if (log)
-        {
-            if (success)
-                log->Printf("StructuredDataDarwinLog::%s() ran enable command "
-                            "successfully for (process uid %u)",
-                            __FUNCTION__, process_sp->GetUniqueID());
-            else
-                log->Printf("StructuredDataDarwinLog::%s() error: running "
-                            "enable command failed (process uid %u)",
-                            __FUNCTION__, process_sp->GetUniqueID());
-        }
-        // Report failures to the debugger error stream.
-        auto error_stream_sp = debugger_sp->GetAsyncErrorStream();
-        if (error_stream_sp)
-        {
-            error_stream_sp->Printf("failed to configure DarwinLog "
-                                    "support\n");
-            error_stream_sp->Flush();
-        }
-        return;
-    }
-
-    // We've previously been enabled. We will re-enable now with the
-    // previously specified options.
-    auto config_sp = options_sp->BuildConfigurationData(true);
-    if (!config_sp)
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() warning: failed to "
-                        "build configuration data for enable options, skipping "
-                        "(process uid %u)", __FUNCTION__,
-                        process_sp->GetUniqueID());
-        return;
     }
+    // Report failures to the debugger error stream.
+    auto error_stream_sp = debugger_sp->GetAsyncErrorStream();
+    if (error_stream_sp) {
+      error_stream_sp->Printf("failed to configure DarwinLog "
+                              "support\n");
+      error_stream_sp->Flush();
+    }
+    return;
+  }
+
+  // We've previously been enabled. We will re-enable now with the
+  // previously specified options.
+  auto config_sp = options_sp->BuildConfigurationData(true);
+  if (!config_sp) {
+    if (log)
+      log->Printf("StructuredDataDarwinLog::%s() warning: failed to "
+                  "build configuration data for enable options, skipping "
+                  "(process uid %u)",
+                  __FUNCTION__, process_sp->GetUniqueID());
+    return;
+  }
+
+  // We can run it directly.
+  // Send configuration to the feature by way of the process.
+  const Error error =
+      process_sp->ConfigureStructuredData(GetDarwinLogTypeName(), config_sp);
 
-    // We can run it directly.
-    // Send configuration to the feature by way of the process.
-    const Error error =
-        process_sp->ConfigureStructuredData(GetDarwinLogTypeName(),
-                                            config_sp);
-
-    // Report results.
-    if (!error.Success())
-    {
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() "
-                        "ConfigureStructuredData() call failed "
-                        "(process uid %u): %s",
-                        __FUNCTION__, process_sp->GetUniqueID(),
-                        error.AsCString());
-        auto error_stream_sp = debugger_sp->GetAsyncErrorStream();
-        if (error_stream_sp)
-        {
-            error_stream_sp->Printf("failed to configure DarwinLog "
-                                    "support: %s\n", error.AsCString());
-            error_stream_sp->Flush();
-        }
-        m_is_enabled = false;
-    }
-    else
-    {
-        m_is_enabled = true;
-        if (log)
-            log->Printf("StructuredDataDarwinLog::%s() success via direct "
-                        "configuration (process uid %u)", __FUNCTION__,
-                        process_sp->GetUniqueID());
-    }
+  // Report results.
+  if (!error.Success()) {
+    if (log)
+      log->Printf("StructuredDataDarwinLog::%s() "
+                  "ConfigureStructuredData() call failed "
+                  "(process uid %u): %s",
+                  __FUNCTION__, process_sp->GetUniqueID(), error.AsCString());
+    auto error_stream_sp = debugger_sp->GetAsyncErrorStream();
+    if (error_stream_sp) {
+      error_stream_sp->Printf("failed to configure DarwinLog "
+                              "support: %s\n",
+                              error.AsCString());
+      error_stream_sp->Flush();
+    }
+    m_is_enabled = false;
+  } else {
+    m_is_enabled = true;
+    if (log)
+      log->Printf("StructuredDataDarwinLog::%s() success via direct "
+                  "configuration (process uid %u)",
+                  __FUNCTION__, process_sp->GetUniqueID());
+  }
 }

Modified: lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h (original)
+++ lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h Tue Sep  6 15:57:50 2016
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 #ifndef StructuredDataDarwinLog_h
 #define StructuredDataDarwinLog_h
 
@@ -16,149 +15,121 @@
 #include <mutex>
 
 // Forward declarations
-namespace sddarwinlog_private
-{
-    class EnableCommand;
+namespace sddarwinlog_private {
+class EnableCommand;
 }
 
-namespace lldb_private
-{
+namespace lldb_private {
 
-class StructuredDataDarwinLog : public StructuredDataPlugin
-{
-    friend sddarwinlog_private::EnableCommand;
+class StructuredDataDarwinLog : public StructuredDataPlugin {
+  friend sddarwinlog_private::EnableCommand;
 
 public:
+  // -------------------------------------------------------------------------
+  // Public static API
+  // -------------------------------------------------------------------------
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static const ConstString &GetStaticPluginName();
+
+  // -------------------------------------------------------------------------
+  /// Return whether the DarwinLog functionality is enabled.
+  ///
+  /// The DarwinLog functionality is enabled if the user expicitly enabled
+  /// it with the enable command, or if the user has the setting set
+  /// that controls if we always enable it for newly created/attached
+  /// processes.
+  ///
+  /// @return
+  ///      True if DarwinLog support is/will be enabled for existing or
+  ///      newly launched/attached processes.
+  // -------------------------------------------------------------------------
+  static bool IsEnabled();
+
+  // -------------------------------------------------------------------------
+  // PluginInterface API
+  // -------------------------------------------------------------------------
+
+  ConstString GetPluginName() override;
 
-    // -------------------------------------------------------------------------
-    // Public static API
-    // -------------------------------------------------------------------------
-
-    static void
-    Initialize();
-
-    static void
-    Terminate();
-
-    static const ConstString&
-    GetStaticPluginName();
-
-    // -------------------------------------------------------------------------
-    /// Return whether the DarwinLog functionality is enabled.
-    ///
-    /// The DarwinLog functionality is enabled if the user expicitly enabled
-    /// it with the enable command, or if the user has the setting set
-    /// that controls if we always enable it for newly created/attached
-    /// processes.
-    ///
-    /// @return
-    ///      True if DarwinLog support is/will be enabled for existing or
-    ///      newly launched/attached processes.
-    // -------------------------------------------------------------------------
-    static bool
-    IsEnabled();
-
-    // -------------------------------------------------------------------------
-    // PluginInterface API
-    // -------------------------------------------------------------------------
-
-    ConstString
-    GetPluginName() override;
-
-    uint32_t
-    GetPluginVersion() override;
-
-    // -------------------------------------------------------------------------
-    // StructuredDataPlugin API
-    // -------------------------------------------------------------------------
-
-    bool
-    SupportsStructuredDataType(const ConstString &type_name) override;
-
-    void
-    HandleArrivalOfStructuredData(Process &process,
-                                  const ConstString &type_name,
-                                  const StructuredData::ObjectSP
-                                  &object_sp) override;
-
-    Error
-    GetDescription(const StructuredData::ObjectSP &object_sp,
-                   lldb_private::Stream &stream) override;
+  uint32_t GetPluginVersion() override;
 
+  // -------------------------------------------------------------------------
+  // StructuredDataPlugin API
+  // -------------------------------------------------------------------------
 
-    bool
-    GetEnabled(const ConstString &type_name) const override;
+  bool SupportsStructuredDataType(const ConstString &type_name) override;
 
-    void
-    ModulesDidLoad(Process &process, ModuleList &module_list) override;
+  void HandleArrivalOfStructuredData(
+      Process &process, const ConstString &type_name,
+      const StructuredData::ObjectSP &object_sp) override;
+
+  Error GetDescription(const StructuredData::ObjectSP &object_sp,
+                       lldb_private::Stream &stream) override;
+
+  bool GetEnabled(const ConstString &type_name) const override;
+
+  void ModulesDidLoad(Process &process, ModuleList &module_list) override;
 
 private:
+  // -------------------------------------------------------------------------
+  // Private constructors
+  // -------------------------------------------------------------------------
 
-    // -------------------------------------------------------------------------
-    // Private constructors
-    // -------------------------------------------------------------------------
-
-    StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);
-
-    // -------------------------------------------------------------------------
-    // Private static methods
-    // -------------------------------------------------------------------------
-
-    static lldb::StructuredDataPluginSP
-    CreateInstance(Process &process);
-
-    static void
-    DebuggerInitialize(Debugger &debugger);
-
-    static bool
-    InitCompletionHookCallback(void *baton, StoppointCallbackContext *context,
-                               lldb::user_id_t break_id,
-                               lldb::user_id_t break_loc_id);
-
-    static Error
-    FilterLaunchInfo(ProcessLaunchInfo &launch_info, Target *target);
-
-    // -------------------------------------------------------------------------
-    // Internal helper methods used by friend classes
-    // -------------------------------------------------------------------------
-    void
-    SetEnabled(bool enabled);
-
-    void
-    AddInitCompletionHook(Process &process);
-
-    // -------------------------------------------------------------------------
-    // Private methods
-    // -------------------------------------------------------------------------
-
-    void
-    DumpTimestamp(Stream &stream, uint64_t timestamp);
-
-    size_t
-    DumpHeader(Stream &stream, const StructuredData::Dictionary &event);
-
-    size_t
-    HandleDisplayOfEvent(const StructuredData::Dictionary &event,
-                         Stream &stream);
-
-    // -------------------------------------------------------------------------
-    /// Call the enable command again, using whatever settings were initially
-    /// made.
-    // -------------------------------------------------------------------------
-
-    void
-    EnableNow();
-
-    // -------------------------------------------------------------------------
-    // Private data
-    // -------------------------------------------------------------------------
-    bool        m_recorded_first_timestamp;
-    uint64_t    m_first_timestamp_seen;
-    bool        m_is_enabled;
-    std::mutex  m_added_breakpoint_mutex;
-    bool        m_added_breakpoint;
-};
+  StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);
+
+  // -------------------------------------------------------------------------
+  // Private static methods
+  // -------------------------------------------------------------------------
+
+  static lldb::StructuredDataPluginSP CreateInstance(Process &process);
 
+  static void DebuggerInitialize(Debugger &debugger);
+
+  static bool InitCompletionHookCallback(void *baton,
+                                         StoppointCallbackContext *context,
+                                         lldb::user_id_t break_id,
+                                         lldb::user_id_t break_loc_id);
+
+  static Error FilterLaunchInfo(ProcessLaunchInfo &launch_info, Target *target);
+
+  // -------------------------------------------------------------------------
+  // Internal helper methods used by friend classes
+  // -------------------------------------------------------------------------
+  void SetEnabled(bool enabled);
+
+  void AddInitCompletionHook(Process &process);
+
+  // -------------------------------------------------------------------------
+  // Private methods
+  // -------------------------------------------------------------------------
+
+  void DumpTimestamp(Stream &stream, uint64_t timestamp);
+
+  size_t DumpHeader(Stream &stream, const StructuredData::Dictionary &event);
+
+  size_t HandleDisplayOfEvent(const StructuredData::Dictionary &event,
+                              Stream &stream);
+
+  // -------------------------------------------------------------------------
+  /// Call the enable command again, using whatever settings were initially
+  /// made.
+  // -------------------------------------------------------------------------
+
+  void EnableNow();
+
+  // -------------------------------------------------------------------------
+  // Private data
+  // -------------------------------------------------------------------------
+  bool m_recorded_first_timestamp;
+  uint64_t m_first_timestamp_seen;
+  bool m_is_enabled;
+  std::mutex m_added_breakpoint_mutex;
+  bool m_added_breakpoint;
+};
 }
 
 #endif /* StructuredDataPluginDarwinLog_hpp */

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.cpp Tue Sep  6 15:57:50 2016
@@ -9,83 +9,64 @@
 
 #include "DIERef.h"
 #include "DWARFCompileUnit.h"
-#include "DWARFFormValue.h"
 #include "DWARFDebugInfo.h"
+#include "DWARFFormValue.h"
 #include "SymbolFileDWARF.h"
 #include "SymbolFileDWARFDebugMap.h"
 
-DIERef::DIERef() :
-    cu_offset(DW_INVALID_OFFSET),
-    die_offset(DW_INVALID_OFFSET)
-{}
-
-DIERef::DIERef(dw_offset_t c, dw_offset_t d) :
-    cu_offset(c),
-    die_offset(d)
-{}
-
-DIERef::DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf) :
-    cu_offset(DW_INVALID_OFFSET),
-    die_offset(uid&0xffffffff)
-{
-    SymbolFileDWARFDebugMap *debug_map = dwarf->GetDebugMapSymfile();
-    if (debug_map)
-    {
-        const uint32_t oso_idx = debug_map->GetOSOIndexFromUserID(uid);
-        SymbolFileDWARF *actual_dwarf = debug_map->GetSymbolFileByOSOIndex(oso_idx);
-        if (actual_dwarf)
-        {
-            DWARFDebugInfo *debug_info = actual_dwarf->DebugInfo();
-            if (debug_info)
-            {
-                DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitContainingDIEOffset(die_offset);
-                if (dwarf_cu)
-                {
-                    cu_offset = dwarf_cu->GetOffset();
-                    return;
-                }
-            }
+DIERef::DIERef()
+    : cu_offset(DW_INVALID_OFFSET), die_offset(DW_INVALID_OFFSET) {}
+
+DIERef::DIERef(dw_offset_t c, dw_offset_t d) : cu_offset(c), die_offset(d) {}
+
+DIERef::DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf)
+    : cu_offset(DW_INVALID_OFFSET), die_offset(uid & 0xffffffff) {
+  SymbolFileDWARFDebugMap *debug_map = dwarf->GetDebugMapSymfile();
+  if (debug_map) {
+    const uint32_t oso_idx = debug_map->GetOSOIndexFromUserID(uid);
+    SymbolFileDWARF *actual_dwarf = debug_map->GetSymbolFileByOSOIndex(oso_idx);
+    if (actual_dwarf) {
+      DWARFDebugInfo *debug_info = actual_dwarf->DebugInfo();
+      if (debug_info) {
+        DWARFCompileUnit *dwarf_cu =
+            debug_info->GetCompileUnitContainingDIEOffset(die_offset);
+        if (dwarf_cu) {
+          cu_offset = dwarf_cu->GetOffset();
+          return;
         }
-        die_offset = DW_INVALID_OFFSET;
-    }
-    else
-    {
-        cu_offset = uid>>32;
+      }
     }
+    die_offset = DW_INVALID_OFFSET;
+  } else {
+    cu_offset = uid >> 32;
+  }
 }
 
-DIERef::DIERef(const DWARFFormValue& form_value) :
-    cu_offset(DW_INVALID_OFFSET),
-    die_offset(DW_INVALID_OFFSET)
-{
-    if (form_value.IsValid())
-    {
-        const DWARFCompileUnit* dwarf_cu = form_value.GetCompileUnit();
-        if (dwarf_cu)
-        {
-            if (dwarf_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
-                cu_offset = dwarf_cu->GetBaseObjOffset();
-            else
-                cu_offset = dwarf_cu->GetOffset();
-        }
-        die_offset = form_value.Reference();
+DIERef::DIERef(const DWARFFormValue &form_value)
+    : cu_offset(DW_INVALID_OFFSET), die_offset(DW_INVALID_OFFSET) {
+  if (form_value.IsValid()) {
+    const DWARFCompileUnit *dwarf_cu = form_value.GetCompileUnit();
+    if (dwarf_cu) {
+      if (dwarf_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
+        cu_offset = dwarf_cu->GetBaseObjOffset();
+      else
+        cu_offset = dwarf_cu->GetOffset();
     }
+    die_offset = form_value.Reference();
+  }
 }
 
-lldb::user_id_t
-DIERef::GetUID(SymbolFileDWARF *dwarf) const
-{
-    //----------------------------------------------------------------------
-    // Each SymbolFileDWARF will set its ID to what is expected.
-    //
-    // SymbolFileDWARF, when used for DWARF with .o files on MacOSX, has the
-    // ID set to the compile unit index.
-    //
-    // SymbolFileDWARFDwo sets the ID to the compile unit offset.
-    //----------------------------------------------------------------------
-    if (dwarf)
-        return dwarf->GetID() | die_offset;
-    else
-        return LLDB_INVALID_UID;
+lldb::user_id_t DIERef::GetUID(SymbolFileDWARF *dwarf) const {
+  //----------------------------------------------------------------------
+  // Each SymbolFileDWARF will set its ID to what is expected.
+  //
+  // SymbolFileDWARF, when used for DWARF with .o files on MacOSX, has the
+  // ID set to the compile unit index.
+  //
+  // SymbolFileDWARFDwo sets the ID to the compile unit offset.
+  //----------------------------------------------------------------------
+  if (dwarf)
+    return dwarf->GetID() | die_offset;
+  else
+    return LLDB_INVALID_UID;
 }
-

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DIERef.h Tue Sep  6 15:57:50 2016
@@ -16,49 +16,39 @@
 class DWARFFormValue;
 class SymbolFileDWARF;
 
-struct DIERef
-{
-    DIERef();
-
-    DIERef(dw_offset_t c, dw_offset_t d);
-
-    //----------------------------------------------------------------------
-    // In order to properly decode a lldb::user_id_t back into a DIERef we
-    // need the DWARF file since it knows if DWARF in .o files is being used
-    // (MacOSX) or if DWO files are being used. The encoding of the user ID
-    // differs between the two types of DWARF.
-    //----------------------------------------------------------------------
-    explicit
-    DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf);
-
-    explicit
-    DIERef(const DWARFFormValue& form_value);
-
-    //----------------------------------------------------------------------
-    // In order to properly encode a DIERef unto a lldb::user_id_t we need
-    // the DWARF file since it knows if DWARF in .o files is being used
-    // (MacOSX) or if DWO files are being used. The encoding of the user ID
-    // differs between the two types of DWARF.
-    //----------------------------------------------------------------------
-    lldb::user_id_t
-    GetUID(SymbolFileDWARF *dwarf) const;
-
-    bool
-    operator< (const DIERef &ref) const
-    {
-        return die_offset < ref.die_offset;
-    }
-
-    bool
-    operator< (const DIERef &ref)
-    {
-        return die_offset < ref.die_offset;
-    }
+struct DIERef {
+  DIERef();
 
-    dw_offset_t cu_offset;
-    dw_offset_t die_offset;
+  DIERef(dw_offset_t c, dw_offset_t d);
+
+  //----------------------------------------------------------------------
+  // In order to properly decode a lldb::user_id_t back into a DIERef we
+  // need the DWARF file since it knows if DWARF in .o files is being used
+  // (MacOSX) or if DWO files are being used. The encoding of the user ID
+  // differs between the two types of DWARF.
+  //----------------------------------------------------------------------
+  explicit DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf);
+
+  explicit DIERef(const DWARFFormValue &form_value);
+
+  //----------------------------------------------------------------------
+  // In order to properly encode a DIERef unto a lldb::user_id_t we need
+  // the DWARF file since it knows if DWARF in .o files is being used
+  // (MacOSX) or if DWO files are being used. The encoding of the user ID
+  // differs between the two types of DWARF.
+  //----------------------------------------------------------------------
+  lldb::user_id_t GetUID(SymbolFileDWARF *dwarf) const;
+
+  bool operator<(const DIERef &ref) const {
+    return die_offset < ref.die_offset;
+  }
+
+  bool operator<(const DIERef &ref) { return die_offset < ref.die_offset; }
+
+  dw_offset_t cu_offset;
+  dw_offset_t die_offset;
 };
 
 typedef std::vector<DIERef> DIEArray;
 
-#endif  // SymbolFileDWARF_DIERef_h_
+#endif // SymbolFileDWARF_DIERef_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h Tue Sep  6 15:57:50 2016
@@ -17,37 +17,34 @@
 
 class DWARFDIE;
 
-class DWARFASTParser
-{
+class DWARFASTParser {
 public:
-    virtual ~DWARFASTParser() {}
+  virtual ~DWARFASTParser() {}
 
-    virtual lldb::TypeSP
-    ParseTypeFromDWARF (const lldb_private::SymbolContext& sc,
-                        const DWARFDIE &die,
-                        lldb_private::Log *log,
-                        bool *type_is_new_ptr) = 0;
-
-    virtual lldb_private::Function *
-    ParseFunctionFromDWARF (const lldb_private::SymbolContext& sc,
-                            const DWARFDIE &die) = 0;
-
-    virtual bool
-    CompleteTypeFromDWARF (const DWARFDIE &die,
-                           lldb_private::Type *type,
-                           lldb_private::CompilerType &compiler_type) = 0;
-
-    virtual lldb_private::CompilerDecl
-    GetDeclForUIDFromDWARF (const DWARFDIE &die) = 0;
+  virtual lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
+                                          const DWARFDIE &die,
+                                          lldb_private::Log *log,
+                                          bool *type_is_new_ptr) = 0;
 
-    virtual lldb_private::CompilerDeclContext
-    GetDeclContextForUIDFromDWARF (const DWARFDIE &die) = 0;
+  virtual lldb_private::Function *
+  ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc,
+                         const DWARFDIE &die) = 0;
 
-    virtual lldb_private::CompilerDeclContext
-    GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) = 0;
+  virtual bool
+  CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
+                        lldb_private::CompilerType &compiler_type) = 0;
 
-    virtual std::vector<DWARFDIE>
-    GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) = 0;
+  virtual lldb_private::CompilerDecl
+  GetDeclForUIDFromDWARF(const DWARFDIE &die) = 0;
+
+  virtual lldb_private::CompilerDeclContext
+  GetDeclContextForUIDFromDWARF(const DWARFDIE &die) = 0;
+
+  virtual lldb_private::CompilerDeclContext
+  GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) = 0;
+
+  virtual std::vector<DWARFDIE>
+  GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context) = 0;
 };
 
-#endif  // SymbolFileDWARF_DWARFASTParser_h_
+#endif // SymbolFileDWARF_DWARFASTParser_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Tue Sep  6 15:57:50 2016
@@ -11,11 +11,11 @@
 
 #include "DWARFASTParserClang.h"
 #include "DWARFCompileUnit.h"
+#include "DWARFDIE.h"
+#include "DWARFDIECollection.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
-#include "DWARFDIE.h"
-#include "DWARFDIECollection.h"
 #include "SymbolFileDWARF.h"
 #include "SymbolFileDWARFDebugMap.h"
 #include "UniqueDWARFASTType.h"
@@ -54,4206 +54,4038 @@
 #define DEBUG_PRINTF(fmt, ...)
 #endif
 
-
 using namespace lldb;
 using namespace lldb_private;
-DWARFASTParserClang::DWARFASTParserClang (ClangASTContext &ast) :
-    m_ast (ast),
-    m_die_to_decl_ctx (),
-    m_decl_ctx_to_die ()
-{
-}
-
-DWARFASTParserClang::~DWARFASTParserClang ()
-{
-}
+DWARFASTParserClang::DWARFASTParserClang(ClangASTContext &ast)
+    : m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {}
 
+DWARFASTParserClang::~DWARFASTParserClang() {}
 
-static AccessType
-DW_ACCESS_to_AccessType (uint32_t dwarf_accessibility)
-{
-    switch (dwarf_accessibility)
-    {
-        case DW_ACCESS_public:      return eAccessPublic;
-        case DW_ACCESS_private:     return eAccessPrivate;
-        case DW_ACCESS_protected:   return eAccessProtected;
-        default:                    break;
-    }
-    return eAccessNone;
-}
-
-static bool
-DeclKindIsCXXClass (clang::Decl::Kind decl_kind)
-{
-    switch (decl_kind)
-    {
-        case clang::Decl::CXXRecord:
-        case clang::Decl::ClassTemplateSpecialization:
-            return true;
-        default:
-            break;
-    }
-    return false;
-}
-
-struct BitfieldInfo
-{
-    uint64_t bit_size;
-    uint64_t bit_offset;
-
-    BitfieldInfo() :
-        bit_size(LLDB_INVALID_ADDRESS),
-        bit_offset(LLDB_INVALID_ADDRESS)
-    {
+static AccessType DW_ACCESS_to_AccessType(uint32_t dwarf_accessibility) {
+  switch (dwarf_accessibility) {
+  case DW_ACCESS_public:
+    return eAccessPublic;
+  case DW_ACCESS_private:
+    return eAccessPrivate;
+  case DW_ACCESS_protected:
+    return eAccessProtected;
+  default:
+    break;
+  }
+  return eAccessNone;
+}
+
+static bool DeclKindIsCXXClass(clang::Decl::Kind decl_kind) {
+  switch (decl_kind) {
+  case clang::Decl::CXXRecord:
+  case clang::Decl::ClassTemplateSpecialization:
+    return true;
+  default:
+    break;
+  }
+  return false;
+}
+
+struct BitfieldInfo {
+  uint64_t bit_size;
+  uint64_t bit_offset;
+
+  BitfieldInfo()
+      : bit_size(LLDB_INVALID_ADDRESS), bit_offset(LLDB_INVALID_ADDRESS) {}
+
+  void Clear() {
+    bit_size = LLDB_INVALID_ADDRESS;
+    bit_offset = LLDB_INVALID_ADDRESS;
+  }
+
+  bool IsValid() const {
+    return (bit_size != LLDB_INVALID_ADDRESS) &&
+           (bit_offset != LLDB_INVALID_ADDRESS);
+  }
+
+  bool NextBitfieldOffsetIsValid(const uint64_t next_bit_offset) const {
+    if (IsValid()) {
+      // This bitfield info is valid, so any subsequent bitfields
+      // must not overlap and must be at a higher bit offset than
+      // any previous bitfield + size.
+      return (bit_size + bit_offset) <= next_bit_offset;
+    } else {
+      // If the this BitfieldInfo is not valid, then any offset isOK
+      return true;
     }
+  }
+};
 
-    void
-    Clear()
-    {
-        bit_size = LLDB_INVALID_ADDRESS;
-        bit_offset = LLDB_INVALID_ADDRESS;
-    }
+ClangASTImporter &DWARFASTParserClang::GetClangASTImporter() {
+  if (!m_clang_ast_importer_ap) {
+    m_clang_ast_importer_ap.reset(new ClangASTImporter);
+  }
+  return *m_clang_ast_importer_ap;
+}
+
+TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) {
+  ModuleSP dwo_module_sp = die.GetContainingDWOModule();
+  if (dwo_module_sp) {
+    // This type comes from an external DWO module
+    std::vector<CompilerContext> dwo_context;
+    die.GetDWOContext(dwo_context);
+    TypeMap dwo_types;
+    if (dwo_module_sp->GetSymbolVendor()->FindTypes(dwo_context, true,
+                                                    dwo_types)) {
+      const size_t num_dwo_types = dwo_types.GetSize();
+      if (num_dwo_types == 1) {
+        // We found a real definition for this type elsewhere
+        // so lets use it and cache the fact that we found
+        // a complete type for this die
+        TypeSP dwo_type_sp = dwo_types.GetTypeAtIndex(0);
+        if (dwo_type_sp) {
+          lldb_private::CompilerType dwo_type =
+              dwo_type_sp->GetForwardCompilerType();
+
+          lldb_private::CompilerType type =
+              GetClangASTImporter().CopyType(m_ast, dwo_type);
+
+          // printf ("copied_qual_type: ast = %p, clang_type = %p, name =
+          // '%s'\n", m_ast, copied_qual_type.getAsOpaquePtr(),
+          // external_type->GetName().GetCString());
+          if (type) {
+            SymbolFileDWARF *dwarf = die.GetDWARF();
+            TypeSP type_sp(new Type(die.GetID(), dwarf, dwo_type_sp->GetName(),
+                                    dwo_type_sp->GetByteSize(), NULL,
+                                    LLDB_INVALID_UID, Type::eEncodingInvalid,
+                                    &dwo_type_sp->GetDeclaration(), type,
+                                    Type::eResolveStateForward));
+
+            dwarf->GetTypeList()->Insert(type_sp);
+            dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+            clang::TagDecl *tag_decl = ClangASTContext::GetAsTagDecl(type);
+            if (tag_decl)
+              LinkDeclContextToDIE(tag_decl, die);
+            else {
+              clang::DeclContext *defn_decl_ctx =
+                  GetCachedClangDeclContextForDIE(die);
+              if (defn_decl_ctx)
+                LinkDeclContextToDIE(defn_decl_ctx, die);
+            }
+            return type_sp;
+          }
+        }
+      }
+    }
+  }
+  return TypeSP();
+}
+
+TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
+                                               const DWARFDIE &die, Log *log,
+                                               bool *type_is_new_ptr) {
+  TypeSP type_sp;
 
-    bool
-    IsValid() const
-    {
-        return (bit_size != LLDB_INVALID_ADDRESS) &&
-               (bit_offset != LLDB_INVALID_ADDRESS);
-    }
+  if (type_is_new_ptr)
+    *type_is_new_ptr = false;
 
-    bool
-    NextBitfieldOffsetIsValid(const uint64_t next_bit_offset) const
-    {
-        if (IsValid())
-        {
-            // This bitfield info is valid, so any subsequent bitfields
-            // must not overlap and must be at a higher bit offset than
-            // any previous bitfield + size.
-            return (bit_size + bit_offset) <= next_bit_offset;
-        }
-        else
-        {
-            // If the this BitfieldInfo is not valid, then any offset isOK
-            return true;
-        }
+  AccessType accessibility = eAccessNone;
+  if (die) {
+    SymbolFileDWARF *dwarf = die.GetDWARF();
+    if (log) {
+      DWARFDIE context_die;
+      clang::DeclContext *context =
+          GetClangDeclContextContainingDIE(die, &context_die);
+
+      dwarf->GetObjectFile()->GetModule()->LogMessage(
+          log, "SymbolFileDWARF::ParseType (die = 0x%8.8x, decl_ctx = %p (die "
+               "0x%8.8x)) %s name = '%s')",
+          die.GetOffset(), static_cast<void *>(context),
+          context_die.GetOffset(), die.GetTagAsCString(), die.GetName());
     }
-};
+    //
+    //        Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
+    //        if (log && dwarf_cu)
+    //        {
+    //            StreamString s;
+    //            die->DumpLocation (this, dwarf_cu, s);
+    //            dwarf->GetObjectFile()->GetModule()->LogMessage (log,
+    //            "SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData());
+    //
+    //        }
 
+    Type *type_ptr = dwarf->GetDIEToType().lookup(die.GetDIE());
+    TypeList *type_list = dwarf->GetTypeList();
+    if (type_ptr == NULL) {
+      if (type_is_new_ptr)
+        *type_is_new_ptr = true;
+
+      const dw_tag_t tag = die.Tag();
+
+      bool is_forward_declaration = false;
+      DWARFAttributes attributes;
+      const char *type_name_cstr = NULL;
+      ConstString type_name_const_str;
+      Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
+      uint64_t byte_size = 0;
+      Declaration decl;
+
+      Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
+      CompilerType clang_type;
+      DWARFFormValue form_value;
+
+      dw_attr_t attr;
+
+      switch (tag) {
+      case DW_TAG_typedef:
+      case DW_TAG_base_type:
+      case DW_TAG_pointer_type:
+      case DW_TAG_reference_type:
+      case DW_TAG_rvalue_reference_type:
+      case DW_TAG_const_type:
+      case DW_TAG_restrict_type:
+      case DW_TAG_volatile_type:
+      case DW_TAG_unspecified_type: {
+        // Set a bit that lets us know that we are currently parsing this
+        dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
 
-ClangASTImporter &
-DWARFASTParserClang::GetClangASTImporter()
-{
-    if (!m_clang_ast_importer_ap)
-    {
-        m_clang_ast_importer_ap.reset (new ClangASTImporter);
-    }
-    return *m_clang_ast_importer_ap;
-}
+        const size_t num_attributes = die.GetAttributes(attributes);
+        uint32_t encoding = 0;
+        DWARFFormValue encoding_uid;
 
+        if (num_attributes > 0) {
+          uint32_t i;
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_decl_file:
+                decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+                    form_value.Unsigned()));
+                break;
+              case DW_AT_decl_line:
+                decl.SetLine(form_value.Unsigned());
+                break;
+              case DW_AT_decl_column:
+                decl.SetColumn(form_value.Unsigned());
+                break;
+              case DW_AT_name:
 
-TypeSP
-DWARFASTParserClang::ParseTypeFromDWO (const DWARFDIE &die, Log *log)
-{
-    ModuleSP dwo_module_sp = die.GetContainingDWOModule();
-    if (dwo_module_sp)
-    {
-        // This type comes from an external DWO module
-        std::vector<CompilerContext> dwo_context;
-        die.GetDWOContext(dwo_context);
-        TypeMap dwo_types;
-        if (dwo_module_sp->GetSymbolVendor()->FindTypes(dwo_context, true, dwo_types))
-        {
-            const size_t num_dwo_types = dwo_types.GetSize();
-            if (num_dwo_types == 1)
-            {
-                // We found a real definition for this type elsewhere
-                // so lets use it and cache the fact that we found
-                // a complete type for this die
-                TypeSP dwo_type_sp = dwo_types.GetTypeAtIndex(0);
-                if (dwo_type_sp)
-                {
-                    lldb_private::CompilerType dwo_type = dwo_type_sp->GetForwardCompilerType();
-
-                    lldb_private::CompilerType type = GetClangASTImporter().CopyType (m_ast, dwo_type);
-
-                    //printf ("copied_qual_type: ast = %p, clang_type = %p, name = '%s'\n", m_ast, copied_qual_type.getAsOpaquePtr(), external_type->GetName().GetCString());
-                    if (type)
-                    {
-                        SymbolFileDWARF *dwarf = die.GetDWARF();
-                        TypeSP type_sp (new Type (die.GetID(),
-                                                  dwarf,
-                                                  dwo_type_sp->GetName(),
-                                                  dwo_type_sp->GetByteSize(),
-                                                  NULL,
-                                                  LLDB_INVALID_UID,
-                                                  Type::eEncodingInvalid,
-                                                  &dwo_type_sp->GetDeclaration(),
-                                                  type,
-                                                  Type::eResolveStateForward));
-
-                        dwarf->GetTypeList()->Insert(type_sp);
-                        dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
-                        clang::TagDecl *tag_decl = ClangASTContext::GetAsTagDecl(type);
-                        if (tag_decl)
-                            LinkDeclContextToDIE(tag_decl, die);
-                        else
-                        {
-                            clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(die);
-                            if (defn_decl_ctx)
-                                LinkDeclContextToDIE(defn_decl_ctx, die);
-                        }
-                        return type_sp;
-                    }
+                type_name_cstr = form_value.AsCString();
+                // Work around a bug in llvm-gcc where they give a name to a
+                // reference type which doesn't
+                // include the "&"...
+                if (tag == DW_TAG_reference_type) {
+                  if (strchr(type_name_cstr, '&') == NULL)
+                    type_name_cstr = NULL;
                 }
+                if (type_name_cstr)
+                  type_name_const_str.SetCString(type_name_cstr);
+                break;
+              case DW_AT_byte_size:
+                byte_size = form_value.Unsigned();
+                break;
+              case DW_AT_encoding:
+                encoding = form_value.Unsigned();
+                break;
+              case DW_AT_type:
+                encoding_uid = form_value;
+                break;
+              default:
+              case DW_AT_sibling:
+                break;
+              }
             }
+          }
         }
-    }
-    return TypeSP();
-}
-
-TypeSP
-DWARFASTParserClang::ParseTypeFromDWARF (const SymbolContext& sc,
-                                         const DWARFDIE &die,
-                                         Log *log,
-                                         bool *type_is_new_ptr)
-{
-    TypeSP type_sp;
-
-    if (type_is_new_ptr)
-        *type_is_new_ptr = false;
-
-    AccessType accessibility = eAccessNone;
-    if (die)
-    {
-        SymbolFileDWARF *dwarf = die.GetDWARF();
-        if (log)
-        {
-            DWARFDIE context_die;
-            clang::DeclContext *context = GetClangDeclContextContainingDIE (die, &context_die);
-
-            dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDWARF::ParseType (die = 0x%8.8x, decl_ctx = %p (die 0x%8.8x)) %s name = '%s')",
-                                                             die.GetOffset(),
-                                                             static_cast<void*>(context),
-                                                             context_die.GetOffset(),
-                                                             die.GetTagAsCString(),
-                                                             die.GetName());
 
-        }
-        //
-        //        Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
-        //        if (log && dwarf_cu)
-        //        {
-        //            StreamString s;
-        //            die->DumpLocation (this, dwarf_cu, s);
-        //            dwarf->GetObjectFile()->GetModule()->LogMessage (log, "SymbolFileDwarf::%s %s", __FUNCTION__, s.GetData());
-        //
-        //        }
+        if (tag == DW_TAG_typedef && encoding_uid.IsValid()) {
+          // Try to parse a typedef from the DWO file first as modules
+          // can contain typedef'ed structures that have no names like:
+          //
+          //  typedef struct { int a; } Foo;
+          //
+          // In this case we will have a structure with no name and a
+          // typedef named "Foo" that points to this unnamed structure.
+          // The name in the typedef is the only identifier for the struct,
+          // so always try to get typedefs from DWO files if possible.
+          //
+          // The type_sp returned will be empty if the typedef doesn't exist
+          // in a DWO file, so it is cheap to call this function just to check.
+          //
+          // If we don't do this we end up creating a TypeSP that says this
+          // is a typedef to type 0x123 (the DW_AT_type value would be 0x123
+          // in the DW_TAG_typedef), and this is the unnamed structure type.
+          // We will have a hard time tracking down an unnammed structure
+          // type in the module DWO file, so we make sure we don't get into
+          // this situation by always resolving typedefs from the DWO file.
+          const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid));
+
+          // First make sure that the die that this is typedef'ed to _is_
+          // just a declaration (DW_AT_declaration == 1), not a full definition
+          // since template types can't be represented in modules since only
+          // concrete instances of templates are ever emitted and modules
+          // won't contain those
+          if (encoding_die &&
+              encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) ==
+                  1) {
+            type_sp = ParseTypeFromDWO(die, log);
+            if (type_sp)
+              return type_sp;
+          }
+        }
+
+        DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n",
+                     die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr,
+                     encoding_uid.Reference());
 
-        Type *type_ptr = dwarf->GetDIEToType().lookup (die.GetDIE());
-        TypeList* type_list = dwarf->GetTypeList();
-        if (type_ptr == NULL)
-        {
-            if (type_is_new_ptr)
-                *type_is_new_ptr = true;
-
-            const dw_tag_t tag = die.Tag();
-
-            bool is_forward_declaration = false;
-            DWARFAttributes attributes;
-            const char *type_name_cstr = NULL;
-            ConstString type_name_const_str;
-            Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
-            uint64_t byte_size = 0;
-            Declaration decl;
-
-            Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
-            CompilerType clang_type;
-            DWARFFormValue form_value;
+        switch (tag) {
+        default:
+          break;
 
-            dw_attr_t attr;
+        case DW_TAG_unspecified_type:
+          if (strcmp(type_name_cstr, "nullptr_t") == 0 ||
+              strcmp(type_name_cstr, "decltype(nullptr)") == 0) {
+            resolve_state = Type::eResolveStateFull;
+            clang_type = m_ast.GetBasicType(eBasicTypeNullPtr);
+            break;
+          }
+          // Fall through to base type below in case we can handle the type
+          // there...
+          LLVM_FALLTHROUGH;
+
+        case DW_TAG_base_type:
+          resolve_state = Type::eResolveStateFull;
+          clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
+              type_name_cstr, encoding, byte_size * 8);
+          break;
+
+        case DW_TAG_pointer_type:
+          encoding_data_type = Type::eEncodingIsPointerUID;
+          break;
+        case DW_TAG_reference_type:
+          encoding_data_type = Type::eEncodingIsLValueReferenceUID;
+          break;
+        case DW_TAG_rvalue_reference_type:
+          encoding_data_type = Type::eEncodingIsRValueReferenceUID;
+          break;
+        case DW_TAG_typedef:
+          encoding_data_type = Type::eEncodingIsTypedefUID;
+          break;
+        case DW_TAG_const_type:
+          encoding_data_type = Type::eEncodingIsConstUID;
+          break;
+        case DW_TAG_restrict_type:
+          encoding_data_type = Type::eEncodingIsRestrictUID;
+          break;
+        case DW_TAG_volatile_type:
+          encoding_data_type = Type::eEncodingIsVolatileUID;
+          break;
+        }
+
+        if (!clang_type &&
+            (encoding_data_type == Type::eEncodingIsPointerUID ||
+             encoding_data_type == Type::eEncodingIsTypedefUID) &&
+            sc.comp_unit != NULL) {
+          if (tag == DW_TAG_pointer_type) {
+            DWARFDIE target_die = die.GetReferencedDIE(DW_AT_type);
+
+            if (target_die.GetAttributeValueAsUnsigned(DW_AT_APPLE_block, 0)) {
+              // Blocks have a __FuncPtr inside them which is a pointer to a
+              // function of the proper type.
+
+              for (DWARFDIE child_die = target_die.GetFirstChild();
+                   child_die.IsValid(); child_die = child_die.GetSibling()) {
+                if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name, ""),
+                            "__FuncPtr")) {
+                  DWARFDIE function_pointer_type =
+                      child_die.GetReferencedDIE(DW_AT_type);
+
+                  if (function_pointer_type) {
+                    DWARFDIE function_type =
+                        function_pointer_type.GetReferencedDIE(DW_AT_type);
+
+                    bool function_type_is_new_pointer;
+                    TypeSP lldb_function_type_sp = ParseTypeFromDWARF(
+                        sc, function_type, log, &function_type_is_new_pointer);
+
+                    if (lldb_function_type_sp) {
+                      clang_type = m_ast.CreateBlockPointerType(
+                          lldb_function_type_sp->GetForwardCompilerType());
+                      encoding_data_type = Type::eEncodingIsUID;
+                      encoding_uid.Clear();
+                      resolve_state = Type::eResolveStateFull;
+                    }
+                  }
+
+                  break;
+                }
+              }
+            }
+          }
+
+          bool translation_unit_is_objc =
+              (sc.comp_unit->GetLanguage() == eLanguageTypeObjC ||
+               sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus);
+
+          if (translation_unit_is_objc) {
+            if (type_name_cstr != NULL) {
+              static ConstString g_objc_type_name_id("id");
+              static ConstString g_objc_type_name_Class("Class");
+              static ConstString g_objc_type_name_selector("SEL");
 
-            switch (tag)
-            {
-                case DW_TAG_typedef:
-                case DW_TAG_base_type:
-                case DW_TAG_pointer_type:
-                case DW_TAG_reference_type:
-                case DW_TAG_rvalue_reference_type:
-                case DW_TAG_const_type:
-                case DW_TAG_restrict_type:
-                case DW_TAG_volatile_type:
-                case DW_TAG_unspecified_type:
-                {
-                    // Set a bit that lets us know that we are currently parsing this
-                    dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-                    const size_t num_attributes = die.GetAttributes (attributes);
-                    uint32_t encoding = 0;
-                    DWARFFormValue encoding_uid;
-
-                    if (num_attributes > 0)
-                    {
-                        uint32_t i;
-                        for (i=0; i<num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_decl_file:   decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
-                                    case DW_AT_decl_line:   decl.SetLine(form_value.Unsigned()); break;
-                                    case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
-                                    case DW_AT_name:
-
-                                        type_name_cstr = form_value.AsCString();
-                                        // Work around a bug in llvm-gcc where they give a name to a reference type which doesn't
-                                        // include the "&"...
-                                        if (tag == DW_TAG_reference_type)
-                                        {
-                                            if (strchr (type_name_cstr, '&') == NULL)
-                                                type_name_cstr = NULL;
-                                        }
-                                        if (type_name_cstr)
-                                            type_name_const_str.SetCString(type_name_cstr);
-                                        break;
-                                    case DW_AT_byte_size:   byte_size = form_value.Unsigned(); break;
-                                    case DW_AT_encoding:    encoding = form_value.Unsigned(); break;
-                                    case DW_AT_type:        encoding_uid = form_value; break;
-                                    default:
-                                    case DW_AT_sibling:
-                                        break;
-                                }
-                            }
-                        }
-                    }
+              if (type_name_const_str == g_objc_type_name_id) {
+                if (log)
+                  dwarf->GetObjectFile()->GetModule()->LogMessage(
+                      log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+                           "is Objective C 'id' built-in type.",
+                      die.GetOffset(), die.GetTagAsCString(), die.GetName());
+                clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
+                encoding_data_type = Type::eEncodingIsUID;
+                encoding_uid.Clear();
+                resolve_state = Type::eResolveStateFull;
 
-                    if (tag == DW_TAG_typedef && encoding_uid.IsValid())
-                    {
-                        // Try to parse a typedef from the DWO file first as modules
-                        // can contain typedef'ed structures that have no names like:
-                        //
-                        //  typedef struct { int a; } Foo;
-                        //
-                        // In this case we will have a structure with no name and a
-                        // typedef named "Foo" that points to this unnamed structure.
-                        // The name in the typedef is the only identifier for the struct,
-                        // so always try to get typedefs from DWO files if possible.
-                        //
-                        // The type_sp returned will be empty if the typedef doesn't exist
-                        // in a DWO file, so it is cheap to call this function just to check.
-                        //
-                        // If we don't do this we end up creating a TypeSP that says this
-                        // is a typedef to type 0x123 (the DW_AT_type value would be 0x123
-                        // in the DW_TAG_typedef), and this is the unnamed structure type.
-                        // We will have a hard time tracking down an unnammed structure
-                        // type in the module DWO file, so we make sure we don't get into
-                        // this situation by always resolving typedefs from the DWO file.
-                        const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid));
-
-                        // First make sure that the die that this is typedef'ed to _is_
-                        // just a declaration (DW_AT_declaration == 1), not a full definition
-                        // since template types can't be represented in modules since only
-                        // concrete instances of templates are ever emitted and modules
-                        // won't contain those
-                        if (encoding_die && encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1)
-                        {
-                            type_sp = ParseTypeFromDWO(die, log);
-                            if (type_sp)
-                                return type_sp;
-                        }
-                    }
+              } else if (type_name_const_str == g_objc_type_name_Class) {
+                if (log)
+                  dwarf->GetObjectFile()->GetModule()->LogMessage(
+                      log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+                           "is Objective C 'Class' built-in type.",
+                      die.GetOffset(), die.GetTagAsCString(), die.GetName());
+                clang_type = m_ast.GetBasicType(eBasicTypeObjCClass);
+                encoding_data_type = Type::eEncodingIsUID;
+                encoding_uid.Clear();
+                resolve_state = Type::eResolveStateFull;
+              } else if (type_name_const_str == g_objc_type_name_selector) {
+                if (log)
+                  dwarf->GetObjectFile()->GetModule()->LogMessage(
+                      log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+                           "is Objective C 'selector' built-in type.",
+                      die.GetOffset(), die.GetTagAsCString(), die.GetName());
+                clang_type = m_ast.GetBasicType(eBasicTypeObjCSel);
+                encoding_data_type = Type::eEncodingIsUID;
+                encoding_uid.Clear();
+                resolve_state = Type::eResolveStateFull;
+              }
+            } else if (encoding_data_type == Type::eEncodingIsPointerUID &&
+                       encoding_uid.IsValid()) {
+              // Clang sometimes erroneously emits id as objc_object*.  In that
+              // case we fix up the type to "id".
+
+              const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid));
+
+              if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type) {
+                if (const char *struct_name = encoding_die.GetName()) {
+                  if (!strcmp(struct_name, "objc_object")) {
+                    if (log)
+                      dwarf->GetObjectFile()->GetModule()->LogMessage(
+                          log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s "
+                               "'%s' is 'objc_object*', which we overrode to "
+                               "'id'.",
+                          die.GetOffset(), die.GetTagAsCString(),
+                          die.GetName());
+                    clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
+                    encoding_data_type = Type::eEncodingIsUID;
+                    encoding_uid.Clear();
+                    resolve_state = Type::eResolveStateFull;
+                  }
+                }
+              }
+            }
+          }
+        }
+
+        type_sp.reset(
+            new Type(die.GetID(), dwarf, type_name_const_str, byte_size, NULL,
+                     DIERef(encoding_uid).GetUID(dwarf), encoding_data_type,
+                     &decl, clang_type, resolve_state));
+
+        dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+
+        //                  Type* encoding_type =
+        //                  GetUniquedTypeForDIEOffset(encoding_uid, type_sp,
+        //                  NULL, 0, 0, false);
+        //                  if (encoding_type != NULL)
+        //                  {
+        //                      if (encoding_type != DIE_IS_BEING_PARSED)
+        //                          type_sp->SetEncodingType(encoding_type);
+        //                      else
+        //                          m_indirect_fixups.push_back(type_sp.get());
+        //                  }
+      } break;
+
+      case DW_TAG_structure_type:
+      case DW_TAG_union_type:
+      case DW_TAG_class_type: {
+        // Set a bit that lets us know that we are currently parsing this
+        dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
+        bool byte_size_valid = false;
+
+        LanguageType class_language = eLanguageTypeUnknown;
+        bool is_complete_objc_class = false;
+        // bool struct_is_class = false;
+        const size_t num_attributes = die.GetAttributes(attributes);
+        if (num_attributes > 0) {
+          uint32_t i;
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_decl_file:
+                if (die.GetCU()->DW_AT_decl_file_attributes_are_invalid()) {
+                  // llvm-gcc outputs invalid DW_AT_decl_file attributes that
+                  // always
+                  // point to the compile unit file, so we clear this invalid
+                  // value
+                  // so that we can still unique types efficiently.
+                  decl.SetFile(FileSpec("<invalid>", false));
+                } else
+                  decl.SetFile(
+                      sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+                          form_value.Unsigned()));
+                break;
 
-                    DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid.Reference());
+              case DW_AT_decl_line:
+                decl.SetLine(form_value.Unsigned());
+                break;
 
-                    switch (tag)
-                    {
-                        default:
-                            break;
-
-                        case DW_TAG_unspecified_type:
-                            if (strcmp(type_name_cstr, "nullptr_t") == 0 ||
-                                strcmp(type_name_cstr, "decltype(nullptr)") == 0 )
-                            {
-                                resolve_state = Type::eResolveStateFull;
-                                clang_type = m_ast.GetBasicType(eBasicTypeNullPtr);
-                                break;
-                            }
-                            // Fall through to base type below in case we can handle the type there...
-                            LLVM_FALLTHROUGH;
+              case DW_AT_decl_column:
+                decl.SetColumn(form_value.Unsigned());
+                break;
 
-                        case DW_TAG_base_type:
-                            resolve_state = Type::eResolveStateFull;
-                            clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr,
-                                                                                         encoding,
-                                                                                         byte_size * 8);
-                            break;
-
-                        case DW_TAG_pointer_type:           encoding_data_type = Type::eEncodingIsPointerUID;           break;
-                        case DW_TAG_reference_type:         encoding_data_type = Type::eEncodingIsLValueReferenceUID;   break;
-                        case DW_TAG_rvalue_reference_type:  encoding_data_type = Type::eEncodingIsRValueReferenceUID;   break;
-                        case DW_TAG_typedef:                encoding_data_type = Type::eEncodingIsTypedefUID;           break;
-                        case DW_TAG_const_type:             encoding_data_type = Type::eEncodingIsConstUID;             break;
-                        case DW_TAG_restrict_type:          encoding_data_type = Type::eEncodingIsRestrictUID;          break;
-                        case DW_TAG_volatile_type:          encoding_data_type = Type::eEncodingIsVolatileUID;          break;
-                    }
+              case DW_AT_name:
+                type_name_cstr = form_value.AsCString();
+                type_name_const_str.SetCString(type_name_cstr);
+                break;
 
-                    if (!clang_type && (encoding_data_type == Type::eEncodingIsPointerUID || encoding_data_type == Type::eEncodingIsTypedefUID) && sc.comp_unit != NULL)
-                    {
-                        if (tag == DW_TAG_pointer_type)
-                        {
-                            DWARFDIE target_die = die.GetReferencedDIE(DW_AT_type);
-                            
-                            if (target_die.GetAttributeValueAsUnsigned(DW_AT_APPLE_block, 0))
-                            {
-                                // Blocks have a __FuncPtr inside them which is a pointer to a function of the proper type.
-                                
-                                for (DWARFDIE child_die = target_die.GetFirstChild();
-                                     child_die.IsValid();
-                                     child_die = child_die.GetSibling())
-                                {
-                                    if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name, ""), "__FuncPtr"))
-                                    {
-                                        DWARFDIE function_pointer_type = child_die.GetReferencedDIE(DW_AT_type);
-                                        
-                                        if (function_pointer_type)
-                                        {
-                                            DWARFDIE function_type = function_pointer_type.GetReferencedDIE(DW_AT_type);
-                                            
-                                            bool function_type_is_new_pointer;
-                                            TypeSP lldb_function_type_sp = ParseTypeFromDWARF(sc, function_type, log, &function_type_is_new_pointer);
-                                            
-                                            if (lldb_function_type_sp)
-                                            {
-                                                clang_type = m_ast.CreateBlockPointerType(lldb_function_type_sp->GetForwardCompilerType());
-                                                encoding_data_type = Type::eEncodingIsUID;
-                                                encoding_uid.Clear();
-                                                resolve_state = Type::eResolveStateFull;
-                                            }
-                                        }
-                                        
-                                        break;
-                                    }
-                                }
-                            }
-                        }
-                        
-                        bool translation_unit_is_objc = (sc.comp_unit->GetLanguage() == eLanguageTypeObjC || sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus);
+              case DW_AT_byte_size:
+                byte_size = form_value.Unsigned();
+                byte_size_valid = true;
+                break;
 
-                        if (translation_unit_is_objc)
-                        {
-                            if (type_name_cstr != NULL)
-                            {
-                                static ConstString g_objc_type_name_id("id");
-                                static ConstString g_objc_type_name_Class("Class");
-                                static ConstString g_objc_type_name_selector("SEL");
-
-                                if (type_name_const_str == g_objc_type_name_id)
-                                {
-                                    if (log)
-                                        dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                                         "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'id' built-in type.",
-                                                                                         die.GetOffset(),
-                                                                                         die.GetTagAsCString(),
-                                                                                         die.GetName());
-                                    clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
-                                    encoding_data_type = Type::eEncodingIsUID;
-                                    encoding_uid.Clear();
-                                    resolve_state = Type::eResolveStateFull;
+              case DW_AT_accessibility:
+                accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
+                break;
 
-                                }
-                                else if (type_name_const_str == g_objc_type_name_Class)
-                                {
-                                    if (log)
-                                        dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                                         "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'Class' built-in type.",
-                                                                                         die.GetOffset(),
-                                                                                         die.GetTagAsCString(),
-                                                                                         die.GetName());
-                                    clang_type = m_ast.GetBasicType(eBasicTypeObjCClass);
-                                    encoding_data_type = Type::eEncodingIsUID;
-                                    encoding_uid.Clear();
-                                    resolve_state = Type::eResolveStateFull;
-                                }
-                                else if (type_name_const_str == g_objc_type_name_selector)
-                                {
-                                    if (log)
-                                        dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                                         "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is Objective C 'selector' built-in type.",
-                                                                                         die.GetOffset(),
-                                                                                         die.GetTagAsCString(),
-                                                                                         die.GetName());
-                                    clang_type = m_ast.GetBasicType(eBasicTypeObjCSel);
-                                    encoding_data_type = Type::eEncodingIsUID;
-                                    encoding_uid.Clear();
-                                    resolve_state = Type::eResolveStateFull;
-                                }
-                            }
-                            else if (encoding_data_type == Type::eEncodingIsPointerUID && encoding_uid.IsValid())
-                            {
-                                // Clang sometimes erroneously emits id as objc_object*.  In that case we fix up the type to "id".
-
-                                const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid));
-
-                                if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type)
-                                {
-                                    if (const char *struct_name = encoding_die.GetName())
-                                    {
-                                        if (!strcmp(struct_name, "objc_object"))
-                                        {
-                                            if (log)
-                                                dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                                                 "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' is 'objc_object*', which we overrode to 'id'.",
-                                                                                                 die.GetOffset(),
-                                                                                                 die.GetTagAsCString(),
-                                                                                                 die.GetName());
-                                            clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
-                                            encoding_data_type = Type::eEncodingIsUID;
-                                            encoding_uid.Clear();
-                                            resolve_state = Type::eResolveStateFull;
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
+              case DW_AT_declaration:
+                is_forward_declaration = form_value.Boolean();
+                break;
 
-                    type_sp.reset( new Type (die.GetID(),
-                                             dwarf,
-                                             type_name_const_str,
-                                             byte_size,
-                                             NULL,
-                                             DIERef(encoding_uid).GetUID(dwarf),
-                                             encoding_data_type,
-                                             &decl,
-                                             clang_type,
-                                             resolve_state));
-
-                    dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
-
-                    //                  Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false);
-                    //                  if (encoding_type != NULL)
-                    //                  {
-                    //                      if (encoding_type != DIE_IS_BEING_PARSED)
-                    //                          type_sp->SetEncodingType(encoding_type);
-                    //                      else
-                    //                          m_indirect_fixups.push_back(type_sp.get());
-                    //                  }
-                }
-                    break;
+              case DW_AT_APPLE_runtime_class:
+                class_language = (LanguageType)form_value.Signed();
+                break;
 
-                case DW_TAG_structure_type:
-                case DW_TAG_union_type:
-                case DW_TAG_class_type:
-                {
-                    // Set a bit that lets us know that we are currently parsing this
-                    dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
-                    bool byte_size_valid = false;
-
-                    LanguageType class_language = eLanguageTypeUnknown;
-                    bool is_complete_objc_class = false;
-                    //bool struct_is_class = false;
-                    const size_t num_attributes = die.GetAttributes (attributes);
-                    if (num_attributes > 0)
-                    {
-                        uint32_t i;
-                        for (i=0; i<num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_decl_file:
-                                        if (die.GetCU()->DW_AT_decl_file_attributes_are_invalid())
-                                        {
-                                            // llvm-gcc outputs invalid DW_AT_decl_file attributes that always
-                                            // point to the compile unit file, so we clear this invalid value
-                                            // so that we can still unique types efficiently.
-                                            decl.SetFile(FileSpec ("<invalid>", false));
-                                        }
-                                        else
-                                            decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned()));
-                                        break;
-
-                                    case DW_AT_decl_line:
-                                        decl.SetLine(form_value.Unsigned());
-                                        break;
-
-                                    case DW_AT_decl_column:
-                                        decl.SetColumn(form_value.Unsigned());
-                                        break;
-
-                                    case DW_AT_name:
-                                        type_name_cstr = form_value.AsCString();
-                                        type_name_const_str.SetCString(type_name_cstr);
-                                        break;
-
-                                    case DW_AT_byte_size:
-                                        byte_size = form_value.Unsigned();
-                                        byte_size_valid = true;
-                                        break;
-
-                                    case DW_AT_accessibility:
-                                        accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
-                                        break;
-
-                                    case DW_AT_declaration:
-                                        is_forward_declaration = form_value.Boolean();
-                                        break;
-
-                                    case DW_AT_APPLE_runtime_class:
-                                        class_language = (LanguageType)form_value.Signed();
-                                        break;
-
-                                    case DW_AT_APPLE_objc_complete_type:
-                                        is_complete_objc_class = form_value.Signed();
-                                        break;
-
-                                    case DW_AT_allocated:
-                                    case DW_AT_associated:
-                                    case DW_AT_data_location:
-                                    case DW_AT_description:
-                                    case DW_AT_start_scope:
-                                    case DW_AT_visibility:
-                                    default:
-                                    case DW_AT_sibling:
-                                        break;
-                                }
-                            }
-                        }
-                    }
+              case DW_AT_APPLE_objc_complete_type:
+                is_complete_objc_class = form_value.Signed();
+                break;
 
-                    // UniqueDWARFASTType is large, so don't create a local variables on the
-                    // stack, put it on the heap. This function is often called recursively
-                    // and clang isn't good and sharing the stack space for variables in different blocks.
-                    std::unique_ptr<UniqueDWARFASTType> unique_ast_entry_ap(new UniqueDWARFASTType());
-
-                    ConstString unique_typename(type_name_const_str);
-                    Declaration unique_decl(decl);
-
-                    if (type_name_const_str)
-                    {
-                        LanguageType die_language = die.GetLanguage();
-                        if (Language::LanguageIsCPlusPlus(die_language))
-                        {
-                            // For C++, we rely solely upon the one definition rule that says only
-                            // one thing can exist at a given decl context. We ignore the file and
-                            // line that things are declared on.
-                            std::string qualified_name;
-                            if (die.GetQualifiedName(qualified_name))
-                                unique_typename = ConstString(qualified_name);
-                            unique_decl.Clear();
-                        }
+              case DW_AT_allocated:
+              case DW_AT_associated:
+              case DW_AT_data_location:
+              case DW_AT_description:
+              case DW_AT_start_scope:
+              case DW_AT_visibility:
+              default:
+              case DW_AT_sibling:
+                break;
+              }
+            }
+          }
+        }
 
-                        if (dwarf->GetUniqueDWARFASTTypeMap().Find(unique_typename, die, unique_decl,
-                                                                   byte_size_valid ? byte_size : -1,
-                                                                   *unique_ast_entry_ap))
-                        {
-                            type_sp = unique_ast_entry_ap->m_type_sp;
-                            if (type_sp)
-                            {
-                                dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
-                                return type_sp;
-                            }
-                        }
-                    }
+        // UniqueDWARFASTType is large, so don't create a local variables on the
+        // stack, put it on the heap. This function is often called recursively
+        // and clang isn't good and sharing the stack space for variables in
+        // different blocks.
+        std::unique_ptr<UniqueDWARFASTType> unique_ast_entry_ap(
+            new UniqueDWARFASTType());
+
+        ConstString unique_typename(type_name_const_str);
+        Declaration unique_decl(decl);
+
+        if (type_name_const_str) {
+          LanguageType die_language = die.GetLanguage();
+          if (Language::LanguageIsCPlusPlus(die_language)) {
+            // For C++, we rely solely upon the one definition rule that says
+            // only
+            // one thing can exist at a given decl context. We ignore the file
+            // and
+            // line that things are declared on.
+            std::string qualified_name;
+            if (die.GetQualifiedName(qualified_name))
+              unique_typename = ConstString(qualified_name);
+            unique_decl.Clear();
+          }
+
+          if (dwarf->GetUniqueDWARFASTTypeMap().Find(
+                  unique_typename, die, unique_decl,
+                  byte_size_valid ? byte_size : -1, *unique_ast_entry_ap)) {
+            type_sp = unique_ast_entry_ap->m_type_sp;
+            if (type_sp) {
+              dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+              return type_sp;
+            }
+          }
+        }
+
+        DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+                     DW_TAG_value_to_name(tag), type_name_cstr);
+
+        int tag_decl_kind = -1;
+        AccessType default_accessibility = eAccessNone;
+        if (tag == DW_TAG_structure_type) {
+          tag_decl_kind = clang::TTK_Struct;
+          default_accessibility = eAccessPublic;
+        } else if (tag == DW_TAG_union_type) {
+          tag_decl_kind = clang::TTK_Union;
+          default_accessibility = eAccessPublic;
+        } else if (tag == DW_TAG_class_type) {
+          tag_decl_kind = clang::TTK_Class;
+          default_accessibility = eAccessPrivate;
+        }
+
+        if (byte_size_valid && byte_size == 0 && type_name_cstr &&
+            die.HasChildren() == false &&
+            sc.comp_unit->GetLanguage() == eLanguageTypeObjC) {
+          // Work around an issue with clang at the moment where
+          // forward declarations for objective C classes are emitted
+          // as:
+          //  DW_TAG_structure_type [2]
+          //  DW_AT_name( "ForwardObjcClass" )
+          //  DW_AT_byte_size( 0x00 )
+          //  DW_AT_decl_file( "..." )
+          //  DW_AT_decl_line( 1 )
+          //
+          // Note that there is no DW_AT_declaration and there are
+          // no children, and the byte size is zero.
+          is_forward_declaration = true;
+        }
+
+        if (class_language == eLanguageTypeObjC ||
+            class_language == eLanguageTypeObjC_plus_plus) {
+          if (!is_complete_objc_class &&
+              die.Supports_DW_AT_APPLE_objc_complete_type()) {
+            // We have a valid eSymbolTypeObjCClass class symbol whose
+            // name matches the current objective C class that we
+            // are trying to find and this DIE isn't the complete
+            // definition (we checked is_complete_objc_class above and
+            // know it is false), so the real definition is in here somewhere
+            type_sp = dwarf->FindCompleteObjCDefinitionTypeForDIE(
+                die, type_name_const_str, true);
+
+            if (!type_sp) {
+              SymbolFileDWARFDebugMap *debug_map_symfile =
+                  dwarf->GetDebugMapSymfile();
+              if (debug_map_symfile) {
+                // We weren't able to find a full declaration in
+                // this DWARF, see if we have a declaration anywhere
+                // else...
+                type_sp =
+                    debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE(
+                        die, type_name_const_str, true);
+              }
+            }
+
+            if (type_sp) {
+              if (log) {
+                dwarf->GetObjectFile()->GetModule()->LogMessage(
+                    log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an "
+                         "incomplete objc type, complete type is 0x%8.8" PRIx64,
+                    static_cast<void *>(this), die.GetOffset(),
+                    DW_TAG_value_to_name(tag), type_name_cstr,
+                    type_sp->GetID());
+              }
+
+              // We found a real definition for this type elsewhere
+              // so lets use it and cache the fact that we found
+              // a complete type for this die
+              dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+              return type_sp;
+            }
+          }
+        }
+
+        if (is_forward_declaration) {
+          // We have a forward declaration to a type and we need
+          // to try and find a full declaration. We look in the
+          // current type index just in case we have a forward
+          // declaration followed by an actual declarations in the
+          // DWARF. If this fails, we need to look elsewhere...
+          if (log) {
+            dwarf->GetObjectFile()->GetModule()->LogMessage(
+                log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+                     "forward declaration, trying to find complete type",
+                static_cast<void *>(this), die.GetOffset(),
+                DW_TAG_value_to_name(tag), type_name_cstr);
+          }
+
+          // See if the type comes from a DWO module and if so, track down that
+          // type.
+          type_sp = ParseTypeFromDWO(die, log);
+          if (type_sp)
+            return type_sp;
+
+          DWARFDeclContext die_decl_ctx;
+          die.GetDWARFDeclContext(die_decl_ctx);
+
+          // type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
+          // type_name_const_str);
+          type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+
+          if (!type_sp) {
+            SymbolFileDWARFDebugMap *debug_map_symfile =
+                dwarf->GetDebugMapSymfile();
+            if (debug_map_symfile) {
+              // We weren't able to find a full declaration in
+              // this DWARF, see if we have a declaration anywhere
+              // else...
+              type_sp =
+                  debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(
+                      die_decl_ctx);
+            }
+          }
+
+          if (type_sp) {
+            if (log) {
+              dwarf->GetObjectFile()->GetModule()->LogMessage(
+                  log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+                       "forward declaration, complete type is 0x%8.8" PRIx64,
+                  static_cast<void *>(this), die.GetOffset(),
+                  DW_TAG_value_to_name(tag), type_name_cstr, type_sp->GetID());
+            }
+
+            // We found a real definition for this type elsewhere
+            // so lets use it and cache the fact that we found
+            // a complete type for this die
+            dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+            clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(
+                dwarf->DebugInfo()->GetDIE(DIERef(type_sp->GetID(), dwarf)));
+            if (defn_decl_ctx)
+              LinkDeclContextToDIE(defn_decl_ctx, die);
+            return type_sp;
+          }
+        }
+        assert(tag_decl_kind != -1);
+        bool clang_type_was_created = false;
+        clang_type.SetCompilerType(
+            &m_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
+        if (!clang_type) {
+          clang::DeclContext *decl_ctx =
+              GetClangDeclContextContainingDIE(die, nullptr);
+          if (accessibility == eAccessNone && decl_ctx) {
+            // Check the decl context that contains this class/struct/union.
+            // If it is a class we must give it an accessibility.
+            const clang::Decl::Kind containing_decl_kind =
+                decl_ctx->getDeclKind();
+            if (DeclKindIsCXXClass(containing_decl_kind))
+              accessibility = default_accessibility;
+          }
+
+          ClangASTMetadata metadata;
+          metadata.SetUserID(die.GetID());
+          metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
+
+          if (type_name_cstr && strchr(type_name_cstr, '<')) {
+            ClangASTContext::TemplateParameterInfos template_param_infos;
+            if (ParseTemplateParameterInfos(die, template_param_infos)) {
+              clang::ClassTemplateDecl *class_template_decl =
+                  m_ast.ParseClassTemplateDecl(decl_ctx, accessibility,
+                                               type_name_cstr, tag_decl_kind,
+                                               template_param_infos);
+
+              clang::ClassTemplateSpecializationDecl
+                  *class_specialization_decl =
+                      m_ast.CreateClassTemplateSpecializationDecl(
+                          decl_ctx, class_template_decl, tag_decl_kind,
+                          template_param_infos);
+              clang_type = m_ast.CreateClassTemplateSpecializationType(
+                  class_specialization_decl);
+              clang_type_was_created = true;
+
+              m_ast.SetMetadata(class_template_decl, metadata);
+              m_ast.SetMetadata(class_specialization_decl, metadata);
+            }
+          }
+
+          if (!clang_type_was_created) {
+            clang_type_was_created = true;
+            clang_type = m_ast.CreateRecordType(decl_ctx, accessibility,
+                                                type_name_cstr, tag_decl_kind,
+                                                class_language, &metadata);
+          }
+        }
+
+        // Store a forward declaration to this class type in case any
+        // parameters in any class methods need it for the clang
+        // types for function prototypes.
+        LinkDeclContextToDIE(m_ast.GetDeclContextForType(clang_type), die);
+        type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
+                               byte_size, NULL, LLDB_INVALID_UID,
+                               Type::eEncodingIsUID, &decl, clang_type,
+                               Type::eResolveStateForward));
+
+        type_sp->SetIsCompleteObjCClass(is_complete_objc_class);
+
+        // Add our type to the unique type map so we don't
+        // end up creating many copies of the same type over
+        // and over in the ASTContext for our module
+        unique_ast_entry_ap->m_type_sp = type_sp;
+        unique_ast_entry_ap->m_die = die;
+        unique_ast_entry_ap->m_declaration = unique_decl;
+        unique_ast_entry_ap->m_byte_size = byte_size;
+        dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
+                                                 *unique_ast_entry_ap);
+
+        if (is_forward_declaration && die.HasChildren()) {
+          // Check to see if the DIE actually has a definition, some version of
+          // GCC will
+          // emit DIEs with DW_AT_declaration set to true, but yet still have
+          // subprogram,
+          // members, or inheritance, so we can't trust it
+          DWARFDIE child_die = die.GetFirstChild();
+          while (child_die) {
+            switch (child_die.Tag()) {
+            case DW_TAG_inheritance:
+            case DW_TAG_subprogram:
+            case DW_TAG_member:
+            case DW_TAG_APPLE_property:
+            case DW_TAG_class_type:
+            case DW_TAG_structure_type:
+            case DW_TAG_enumeration_type:
+            case DW_TAG_typedef:
+            case DW_TAG_union_type:
+              child_die.Clear();
+              is_forward_declaration = false;
+              break;
+            default:
+              child_die = child_die.GetSibling();
+              break;
+            }
+          }
+        }
 
-                    DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr);
+        if (!is_forward_declaration) {
+          // Always start the definition for a class type so that
+          // if the class has child classes or types that require
+          // the class to be created for use as their decl contexts
+          // the class will be ready to accept these child definitions.
+          if (die.HasChildren() == false) {
+            // No children for this struct/union/class, lets finish it
+            if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
+              ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+            } else {
+              dwarf->GetObjectFile()->GetModule()->ReportError(
+                  "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
+                  "definition.\nPlease file a bug and attach the file at the "
+                  "start of this error message",
+                  die.GetOffset(), type_name_cstr);
+            }
+
+            if (tag == DW_TAG_structure_type) // this only applies in C
+            {
+              clang::RecordDecl *record_decl =
+                  ClangASTContext::GetAsRecordDecl(clang_type);
+
+              if (record_decl) {
+                GetClangASTImporter().InsertRecordDecl(
+                    record_decl, ClangASTImporter::LayoutInfo());
+              }
+            }
+          } else if (clang_type_was_created) {
+            // Start the definition if the class is not objective C since
+            // the underlying decls respond to isCompleteDefinition(). Objective
+            // C decls don't respond to isCompleteDefinition() so we can't
+            // start the declaration definition right away. For C++
+            // class/union/structs
+            // we want to start the definition in case the class is needed as
+            // the
+            // declaration context for a contained class or type without the
+            // need
+            // to complete that type..
+
+            if (class_language != eLanguageTypeObjC &&
+                class_language != eLanguageTypeObjC_plus_plus)
+              ClangASTContext::StartTagDeclarationDefinition(clang_type);
+
+            // Leave this as a forward declaration until we need
+            // to know the details of the type. lldb_private::Type
+            // will automatically call the SymbolFile virtual function
+            // "SymbolFileDWARF::CompleteType(Type *)"
+            // When the definition needs to be defined.
+            assert(!dwarf->GetForwardDeclClangTypeToDie().count(
+                       ClangUtil::RemoveFastQualifiers(clang_type)
+                           .GetOpaqueQualType()) &&
+                   "Type already in the forward declaration map!");
+            // Can't assume m_ast.GetSymbolFile() is actually a SymbolFileDWARF,
+            // it can be a
+            // SymbolFileDWARFDebugMap for Apple binaries.
+            dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
+                clang_type.GetOpaqueQualType();
+            dwarf->GetForwardDeclClangTypeToDie()
+                [ClangUtil::RemoveFastQualifiers(clang_type)
+                     .GetOpaqueQualType()] = die.GetDIERef();
+            m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
+          }
+        }
+      } break;
+
+      case DW_TAG_enumeration_type: {
+        // Set a bit that lets us know that we are currently parsing this
+        dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
 
-                    int tag_decl_kind = -1;
-                    AccessType default_accessibility = eAccessNone;
-                    if (tag == DW_TAG_structure_type)
-                    {
-                        tag_decl_kind = clang::TTK_Struct;
-                        default_accessibility = eAccessPublic;
-                    }
-                    else if (tag == DW_TAG_union_type)
-                    {
-                        tag_decl_kind = clang::TTK_Union;
-                        default_accessibility = eAccessPublic;
-                    }
-                    else if (tag == DW_TAG_class_type)
-                    {
-                        tag_decl_kind = clang::TTK_Class;
-                        default_accessibility = eAccessPrivate;
-                    }
+        DWARFFormValue encoding_form;
 
-                    if (byte_size_valid && byte_size == 0 && type_name_cstr &&
-                        die.HasChildren() == false &&
-                        sc.comp_unit->GetLanguage() == eLanguageTypeObjC)
-                    {
-                        // Work around an issue with clang at the moment where
-                        // forward declarations for objective C classes are emitted
-                        // as:
-                        //  DW_TAG_structure_type [2]
-                        //  DW_AT_name( "ForwardObjcClass" )
-                        //  DW_AT_byte_size( 0x00 )
-                        //  DW_AT_decl_file( "..." )
-                        //  DW_AT_decl_line( 1 )
-                        //
-                        // Note that there is no DW_AT_declaration and there are
-                        // no children, and the byte size is zero.
-                        is_forward_declaration = true;
-                    }
+        const size_t num_attributes = die.GetAttributes(attributes);
+        if (num_attributes > 0) {
+          uint32_t i;
 
-                    if (class_language == eLanguageTypeObjC ||
-                        class_language == eLanguageTypeObjC_plus_plus)
-                    {
-                        if (!is_complete_objc_class && die.Supports_DW_AT_APPLE_objc_complete_type())
-                        {
-                            // We have a valid eSymbolTypeObjCClass class symbol whose
-                            // name matches the current objective C class that we
-                            // are trying to find and this DIE isn't the complete
-                            // definition (we checked is_complete_objc_class above and
-                            // know it is false), so the real definition is in here somewhere
-                            type_sp = dwarf->FindCompleteObjCDefinitionTypeForDIE (die, type_name_const_str, true);
-
-                            if (!type_sp)
-                            {
-                                SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile();
-                                if (debug_map_symfile)
-                                {
-                                    // We weren't able to find a full declaration in
-                                    // this DWARF, see if we have a declaration anywhere
-                                    // else...
-                                    type_sp = debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE (die, type_name_const_str, true);
-                                }
-                            }
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_decl_file:
+                decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+                    form_value.Unsigned()));
+                break;
+              case DW_AT_decl_line:
+                decl.SetLine(form_value.Unsigned());
+                break;
+              case DW_AT_decl_column:
+                decl.SetColumn(form_value.Unsigned());
+                break;
+              case DW_AT_name:
+                type_name_cstr = form_value.AsCString();
+                type_name_const_str.SetCString(type_name_cstr);
+                break;
+              case DW_AT_type:
+                encoding_form = form_value;
+                break;
+              case DW_AT_byte_size:
+                byte_size = form_value.Unsigned();
+                break;
+              case DW_AT_accessibility:
+                break; // accessibility =
+                       // DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
+              case DW_AT_declaration:
+                is_forward_declaration = form_value.Boolean();
+                break;
+              case DW_AT_allocated:
+              case DW_AT_associated:
+              case DW_AT_bit_stride:
+              case DW_AT_byte_stride:
+              case DW_AT_data_location:
+              case DW_AT_description:
+              case DW_AT_start_scope:
+              case DW_AT_visibility:
+              case DW_AT_specification:
+              case DW_AT_abstract_origin:
+              case DW_AT_sibling:
+                break;
+              }
+            }
+          }
 
-                            if (type_sp)
-                            {
-                                if (log)
-                                {
-                                    dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                                     "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an incomplete objc type, complete type is 0x%8.8" PRIx64,
-                                                                                     static_cast<void*>(this),
-                                                                                     die.GetOffset(),
-                                                                                     DW_TAG_value_to_name(tag),
-                                                                                     type_name_cstr,
-                                                                                     type_sp->GetID());
-                                }
+          if (is_forward_declaration) {
+            type_sp = ParseTypeFromDWO(die, log);
+            if (type_sp)
+              return type_sp;
+
+            DWARFDeclContext die_decl_ctx;
+            die.GetDWARFDeclContext(die_decl_ctx);
+
+            type_sp =
+                dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+
+            if (!type_sp) {
+              SymbolFileDWARFDebugMap *debug_map_symfile =
+                  dwarf->GetDebugMapSymfile();
+              if (debug_map_symfile) {
+                // We weren't able to find a full declaration in
+                // this DWARF, see if we have a declaration anywhere
+                // else...
+                type_sp =
+                    debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(
+                        die_decl_ctx);
+              }
+            }
+
+            if (type_sp) {
+              if (log) {
+                dwarf->GetObjectFile()->GetModule()->LogMessage(
+                    log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+                         "forward declaration, complete type is 0x%8.8" PRIx64,
+                    static_cast<void *>(this), die.GetOffset(),
+                    DW_TAG_value_to_name(tag), type_name_cstr,
+                    type_sp->GetID());
+              }
+
+              // We found a real definition for this type elsewhere
+              // so lets use it and cache the fact that we found
+              // a complete type for this die
+              dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+              clang::DeclContext *defn_decl_ctx =
+                  GetCachedClangDeclContextForDIE(dwarf->DebugInfo()->GetDIE(
+                      DIERef(type_sp->GetID(), dwarf)));
+              if (defn_decl_ctx)
+                LinkDeclContextToDIE(defn_decl_ctx, die);
+              return type_sp;
+            }
+          }
+          DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+                       DW_TAG_value_to_name(tag), type_name_cstr);
+
+          CompilerType enumerator_clang_type;
+          clang_type.SetCompilerType(
+              &m_ast,
+              dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
+          if (!clang_type) {
+            if (encoding_form.IsValid()) {
+              Type *enumerator_type =
+                  dwarf->ResolveTypeUID(DIERef(encoding_form));
+              if (enumerator_type)
+                enumerator_clang_type = enumerator_type->GetFullCompilerType();
+            }
+
+            if (!enumerator_clang_type) {
+              if (byte_size > 0) {
+                enumerator_clang_type =
+                    m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
+                        NULL, DW_ATE_signed, byte_size * 8);
+              } else {
+                enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
+              }
+            }
+
+            clang_type = m_ast.CreateEnumerationType(
+                type_name_cstr, GetClangDeclContextContainingDIE(die, nullptr),
+                decl, enumerator_clang_type);
+          } else {
+            enumerator_clang_type =
+                m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType());
+          }
+
+          LinkDeclContextToDIE(
+              ClangASTContext::GetDeclContextForType(clang_type), die);
+
+          type_sp.reset(new Type(
+              die.GetID(), dwarf, type_name_const_str, byte_size, NULL,
+              DIERef(encoding_form).GetUID(dwarf), Type::eEncodingIsUID, &decl,
+              clang_type, Type::eResolveStateForward));
+
+          if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
+            if (die.HasChildren()) {
+              SymbolContext cu_sc(die.GetLLDBCompileUnit());
+              bool is_signed = false;
+              enumerator_clang_type.IsIntegerType(is_signed);
+              ParseChildEnumerators(cu_sc, clang_type, is_signed,
+                                    type_sp->GetByteSize(), die);
+            }
+            ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+          } else {
+            dwarf->GetObjectFile()->GetModule()->ReportError(
+                "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
+                "definition.\nPlease file a bug and attach the file at the "
+                "start of this error message",
+                die.GetOffset(), type_name_cstr);
+          }
+        }
+      } break;
+
+      case DW_TAG_inlined_subroutine:
+      case DW_TAG_subprogram:
+      case DW_TAG_subroutine_type: {
+        // Set a bit that lets us know that we are currently parsing this
+        dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+        DWARFFormValue type_die_form;
+        bool is_variadic = false;
+        bool is_inline = false;
+        bool is_static = false;
+        bool is_virtual = false;
+        bool is_explicit = false;
+        bool is_artificial = false;
+        bool has_template_params = false;
+        DWARFFormValue specification_die_form;
+        DWARFFormValue abstract_origin_die_form;
+        dw_offset_t object_pointer_die_offset = DW_INVALID_OFFSET;
+
+        unsigned type_quals = 0;
+        clang::StorageClass storage =
+            clang::SC_None; //, Extern, Static, PrivateExtern
 
-                                // We found a real definition for this type elsewhere
-                                // so lets use it and cache the fact that we found
-                                // a complete type for this die
-                                dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
-                                return type_sp;
-                            }
-                        }
-                    }
+        const size_t num_attributes = die.GetAttributes(attributes);
+        if (num_attributes > 0) {
+          uint32_t i;
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_decl_file:
+                decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+                    form_value.Unsigned()));
+                break;
+              case DW_AT_decl_line:
+                decl.SetLine(form_value.Unsigned());
+                break;
+              case DW_AT_decl_column:
+                decl.SetColumn(form_value.Unsigned());
+                break;
+              case DW_AT_name:
+                type_name_cstr = form_value.AsCString();
+                type_name_const_str.SetCString(type_name_cstr);
+                break;
 
+              case DW_AT_linkage_name:
+              case DW_AT_MIPS_linkage_name:
+                break; // mangled =
+                       // form_value.AsCString(&dwarf->get_debug_str_data());
+                       // break;
+              case DW_AT_type:
+                type_die_form = form_value;
+                break;
+              case DW_AT_accessibility:
+                accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
+                break;
+              case DW_AT_declaration:
+                break; // is_forward_declaration = form_value.Boolean(); break;
+              case DW_AT_inline:
+                is_inline = form_value.Boolean();
+                break;
+              case DW_AT_virtuality:
+                is_virtual = form_value.Boolean();
+                break;
+              case DW_AT_explicit:
+                is_explicit = form_value.Boolean();
+                break;
+              case DW_AT_artificial:
+                is_artificial = form_value.Boolean();
+                break;
 
-                    if (is_forward_declaration)
-                    {
-                        // We have a forward declaration to a type and we need
-                        // to try and find a full declaration. We look in the
-                        // current type index just in case we have a forward
-                        // declaration followed by an actual declarations in the
-                        // DWARF. If this fails, we need to look elsewhere...
-                        if (log)
-                        {
-                            dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                             "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, trying to find complete type",
-                                                                             static_cast<void*>(this),
-                                                                             die.GetOffset(),
-                                                                             DW_TAG_value_to_name(tag),
-                                                                             type_name_cstr);
-                        }
+              case DW_AT_external:
+                if (form_value.Unsigned()) {
+                  if (storage == clang::SC_None)
+                    storage = clang::SC_Extern;
+                  else
+                    storage = clang::SC_PrivateExtern;
+                }
+                break;
 
-                        // See if the type comes from a DWO module and if so, track down that type.
-                        type_sp = ParseTypeFromDWO(die, log);
-                        if (type_sp)
-                            return type_sp;
-
-                        DWARFDeclContext die_decl_ctx;
-                        die.GetDWARFDeclContext(die_decl_ctx);
-
-                        //type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
-                        type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx);
-
-                        if (!type_sp)
-                        {
-                            SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile();
-                            if (debug_map_symfile)
-                            {
-                                // We weren't able to find a full declaration in
-                                // this DWARF, see if we have a declaration anywhere
-                                // else...
-                                type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx);
-                            }
-                        }
+              case DW_AT_specification:
+                specification_die_form = form_value;
+                break;
 
-                        if (type_sp)
-                        {
-                            if (log)
-                            {
-                                dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                                 "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, complete type is 0x%8.8" PRIx64,
-                                                                                 static_cast<void*>(this),
-                                                                                 die.GetOffset(),
-                                                                                 DW_TAG_value_to_name(tag),
-                                                                                 type_name_cstr,
-                                                                                 type_sp->GetID());
-                            }
+              case DW_AT_abstract_origin:
+                abstract_origin_die_form = form_value;
+                break;
 
-                            // We found a real definition for this type elsewhere
-                            // so lets use it and cache the fact that we found
-                            // a complete type for this die
-                            dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
-                            clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(
-                                dwarf->DebugInfo()->GetDIE(DIERef(type_sp->GetID(), dwarf)));
-                            if (defn_decl_ctx)
-                                LinkDeclContextToDIE(defn_decl_ctx, die);
-                            return type_sp;
-                        }
-                    }
-                    assert (tag_decl_kind != -1);
-                    bool clang_type_was_created = false;
-                    clang_type.SetCompilerType(&m_ast, dwarf->GetForwardDeclDieToClangType().lookup (die.GetDIE()));
-                    if (!clang_type)
-                    {
-                        clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE (die, nullptr);
-                        if (accessibility == eAccessNone && decl_ctx)
-                        {
-                            // Check the decl context that contains this class/struct/union.
-                            // If it is a class we must give it an accessibility.
-                            const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind();
-                            if (DeclKindIsCXXClass (containing_decl_kind))
-                                accessibility = default_accessibility;
-                        }
+              case DW_AT_object_pointer:
+                object_pointer_die_offset = form_value.Reference();
+                break;
 
-                        ClangASTMetadata metadata;
-                        metadata.SetUserID(die.GetID());
-                        metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual (die));
-
-                        if (type_name_cstr && strchr (type_name_cstr, '<'))
-                        {
-                            ClangASTContext::TemplateParameterInfos template_param_infos;
-                            if (ParseTemplateParameterInfos (die, template_param_infos))
-                            {
-                                clang::ClassTemplateDecl *class_template_decl = m_ast.ParseClassTemplateDecl (decl_ctx,
-                                                                                                              accessibility,
-                                                                                                              type_name_cstr,
-                                                                                                              tag_decl_kind,
-                                                                                                              template_param_infos);
-
-                                clang::ClassTemplateSpecializationDecl *class_specialization_decl = m_ast.CreateClassTemplateSpecializationDecl (decl_ctx,
-                                                                                                                                                 class_template_decl,
-                                                                                                                                                 tag_decl_kind,
-                                                                                                                                                 template_param_infos);
-                                clang_type = m_ast.CreateClassTemplateSpecializationType (class_specialization_decl);
-                                clang_type_was_created = true;
+              case DW_AT_allocated:
+              case DW_AT_associated:
+              case DW_AT_address_class:
+              case DW_AT_calling_convention:
+              case DW_AT_data_location:
+              case DW_AT_elemental:
+              case DW_AT_entry_pc:
+              case DW_AT_frame_base:
+              case DW_AT_high_pc:
+              case DW_AT_low_pc:
+              case DW_AT_prototyped:
+              case DW_AT_pure:
+              case DW_AT_ranges:
+              case DW_AT_recursive:
+              case DW_AT_return_addr:
+              case DW_AT_segment:
+              case DW_AT_start_scope:
+              case DW_AT_static_link:
+              case DW_AT_trampoline:
+              case DW_AT_visibility:
+              case DW_AT_vtable_elem_location:
+              case DW_AT_description:
+              case DW_AT_sibling:
+                break;
+              }
+            }
+          }
+        }
 
-                                m_ast.SetMetadata (class_template_decl, metadata);
-                                m_ast.SetMetadata (class_specialization_decl, metadata);
-                            }
-                        }
+        std::string object_pointer_name;
+        if (object_pointer_die_offset != DW_INVALID_OFFSET) {
+          DWARFDIE object_pointer_die = die.GetDIE(object_pointer_die_offset);
+          if (object_pointer_die) {
+            const char *object_pointer_name_cstr = object_pointer_die.GetName();
+            if (object_pointer_name_cstr)
+              object_pointer_name = object_pointer_name_cstr;
+          }
+        }
 
-                        if (!clang_type_was_created)
-                        {
-                            clang_type_was_created = true;
-                            clang_type = m_ast.CreateRecordType (decl_ctx,
-                                                                 accessibility,
-                                                                 type_name_cstr,
-                                                                 tag_decl_kind,
-                                                                 class_language,
-                                                                 &metadata);
-                        }
-                    }
+        DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+                     DW_TAG_value_to_name(tag), type_name_cstr);
 
-                    // Store a forward declaration to this class type in case any
-                    // parameters in any class methods need it for the clang
-                    // types for function prototypes.
-                    LinkDeclContextToDIE(m_ast.GetDeclContextForType(clang_type), die);
-                    type_sp.reset (new Type (die.GetID(),
-                                             dwarf,
-                                             type_name_const_str,
-                                             byte_size,
-                                             NULL,
-                                             LLDB_INVALID_UID,
-                                             Type::eEncodingIsUID,
-                                             &decl,
-                                             clang_type,
-                                             Type::eResolveStateForward));
-
-                    type_sp->SetIsCompleteObjCClass(is_complete_objc_class);
-
-
-                    // Add our type to the unique type map so we don't
-                    // end up creating many copies of the same type over
-                    // and over in the ASTContext for our module
-                    unique_ast_entry_ap->m_type_sp = type_sp;
-                    unique_ast_entry_ap->m_die = die;
-                    unique_ast_entry_ap->m_declaration = unique_decl;
-                    unique_ast_entry_ap->m_byte_size = byte_size;
-                    dwarf->GetUniqueDWARFASTTypeMap().Insert (unique_typename,
-                                                              *unique_ast_entry_ap);
-
-                    if (is_forward_declaration && die.HasChildren())
-                    {
-                        // Check to see if the DIE actually has a definition, some version of GCC will
-                        // emit DIEs with DW_AT_declaration set to true, but yet still have subprogram,
-                        // members, or inheritance, so we can't trust it
-                        DWARFDIE child_die = die.GetFirstChild();
-                        while (child_die)
-                        {
-                            switch (child_die.Tag())
-                            {
-                                case DW_TAG_inheritance:
-                                case DW_TAG_subprogram:
-                                case DW_TAG_member:
-                                case DW_TAG_APPLE_property:
-                                case DW_TAG_class_type:
-                                case DW_TAG_structure_type:
-                                case DW_TAG_enumeration_type:
-                                case DW_TAG_typedef:
-                                case DW_TAG_union_type:
-                                    child_die.Clear();
-                                    is_forward_declaration = false;
-                                    break;
-                                default:
-                                    child_die = child_die.GetSibling();
-                                    break;
-                            }
-                        }
-                    }
+        CompilerType return_clang_type;
+        Type *func_type = NULL;
 
-                    if (!is_forward_declaration)
-                    {
-                        // Always start the definition for a class type so that
-                        // if the class has child classes or types that require
-                        // the class to be created for use as their decl contexts
-                        // the class will be ready to accept these child definitions.
-                        if (die.HasChildren() == false)
-                        {
-                            // No children for this struct/union/class, lets finish it
-                            if (ClangASTContext::StartTagDeclarationDefinition (clang_type))
-                            {
-                                ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
-                            }
-                            else
-                            {
-                                dwarf->GetObjectFile()->GetModule()->ReportError("DWARF DIE at 0x%8.8x named \"%s\" was not able to start its definition.\nPlease file a bug and attach the file at the start of this error message",
-                                                                                 die.GetOffset(),
-                                                                                 type_name_cstr);
-                            }
+        if (type_die_form.IsValid())
+          func_type = dwarf->ResolveTypeUID(DIERef(type_die_form));
 
-                            if (tag == DW_TAG_structure_type) // this only applies in C
-                            {
-                                clang::RecordDecl *record_decl = ClangASTContext::GetAsRecordDecl(clang_type);
-
-                                if (record_decl)
-                                {
-                                    GetClangASTImporter().InsertRecordDecl(record_decl, ClangASTImporter::LayoutInfo());
-                                }
-                            }
-                        }
-                        else if (clang_type_was_created)
-                        {
-                            // Start the definition if the class is not objective C since
-                            // the underlying decls respond to isCompleteDefinition(). Objective
-                            // C decls don't respond to isCompleteDefinition() so we can't
-                            // start the declaration definition right away. For C++ class/union/structs
-                            // we want to start the definition in case the class is needed as the
-                            // declaration context for a contained class or type without the need
-                            // to complete that type..
-
-                            if (class_language != eLanguageTypeObjC &&
-                                class_language != eLanguageTypeObjC_plus_plus)
-                                ClangASTContext::StartTagDeclarationDefinition (clang_type);
-
-                            // Leave this as a forward declaration until we need
-                            // to know the details of the type. lldb_private::Type
-                            // will automatically call the SymbolFile virtual function
-                            // "SymbolFileDWARF::CompleteType(Type *)"
-                            // When the definition needs to be defined.
-                            assert(!dwarf->GetForwardDeclClangTypeToDie().count(
-                                       ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType()) &&
-                                   "Type already in the forward declaration map!");
-                            // Can't assume m_ast.GetSymbolFile() is actually a SymbolFileDWARF, it can be a
-                            // SymbolFileDWARFDebugMap for Apple binaries.
-                            dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] = clang_type.GetOpaqueQualType();
-                            dwarf->GetForwardDeclClangTypeToDie()[ClangUtil::RemoveFastQualifiers(clang_type)
-                                                                      .GetOpaqueQualType()] = die.GetDIERef();
-                            m_ast.SetHasExternalStorage (clang_type.GetOpaqueQualType(), true);
-                        }
-                    }
-                }
-                    break;
+        if (func_type)
+          return_clang_type = func_type->GetForwardCompilerType();
+        else
+          return_clang_type = m_ast.GetBasicType(eBasicTypeVoid);
 
-                case DW_TAG_enumeration_type:
-                {
-                    // Set a bit that lets us know that we are currently parsing this
-                    dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-                    DWARFFormValue encoding_form;
-
-                    const size_t num_attributes = die.GetAttributes (attributes);
-                    if (num_attributes > 0)
-                    {
-                        uint32_t i;
-
-                        for (i=0; i<num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_decl_file:       decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
-                                    case DW_AT_decl_line:       decl.SetLine(form_value.Unsigned()); break;
-                                    case DW_AT_decl_column:     decl.SetColumn(form_value.Unsigned()); break;
-                                    case DW_AT_name:
-                                        type_name_cstr = form_value.AsCString();
-                                        type_name_const_str.SetCString(type_name_cstr);
-                                        break;
-                                    case DW_AT_type:            encoding_form = form_value; break;
-                                    case DW_AT_byte_size:       byte_size = form_value.Unsigned(); break;
-                                    case DW_AT_accessibility:   break; //accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
-                                    case DW_AT_declaration:     is_forward_declaration = form_value.Boolean(); break;
-                                    case DW_AT_allocated:
-                                    case DW_AT_associated:
-                                    case DW_AT_bit_stride:
-                                    case DW_AT_byte_stride:
-                                    case DW_AT_data_location:
-                                    case DW_AT_description:
-                                    case DW_AT_start_scope:
-                                    case DW_AT_visibility:
-                                    case DW_AT_specification:
-                                    case DW_AT_abstract_origin:
-                                    case DW_AT_sibling:
-                                        break;
-                                }
-                            }
-                        }
+        std::vector<CompilerType> function_param_types;
+        std::vector<clang::ParmVarDecl *> function_param_decls;
 
-                        if (is_forward_declaration)
-                        {
-                            type_sp = ParseTypeFromDWO(die, log);
-                            if (type_sp)
-                                return type_sp;
-
-                            DWARFDeclContext die_decl_ctx;
-                            die.GetDWARFDeclContext(die_decl_ctx);
-
-                            type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx);
-
-                            if (!type_sp)
-                            {
-                                SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile();
-                                if (debug_map_symfile)
-                                {
-                                    // We weren't able to find a full declaration in
-                                    // this DWARF, see if we have a declaration anywhere
-                                    // else...
-                                    type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext (die_decl_ctx);
-                                }
-                            }
+        // Parse the function children for the parameters
 
-                            if (type_sp)
-                            {
-                                if (log)
-                                {
-                                    dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                                     "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a forward declaration, complete type is 0x%8.8" PRIx64,
-                                                                                     static_cast<void*>(this),
-                                                                                     die.GetOffset(),
-                                                                                     DW_TAG_value_to_name(tag),
-                                                                                     type_name_cstr,
-                                                                                     type_sp->GetID());
-                                }
+        DWARFDIE decl_ctx_die;
+        clang::DeclContext *containing_decl_ctx =
+            GetClangDeclContextContainingDIE(die, &decl_ctx_die);
+        const clang::Decl::Kind containing_decl_kind =
+            containing_decl_ctx->getDeclKind();
+
+        bool is_cxx_method = DeclKindIsCXXClass(containing_decl_kind);
+        // Start off static. This will be set to false in
+        // ParseChildParameters(...)
+        // if we find a "this" parameters as the first parameter
+        if (is_cxx_method) {
+          is_static = true;
+        }
+
+        if (die.HasChildren()) {
+          bool skip_artificial = true;
+          ParseChildParameters(sc, containing_decl_ctx, die, skip_artificial,
+                               is_static, is_variadic, has_template_params,
+                               function_param_types, function_param_decls,
+                               type_quals);
+        }
+
+        bool ignore_containing_context = false;
+        // Check for templatized class member functions. If we had any
+        // DW_TAG_template_type_parameter
+        // or DW_TAG_template_value_parameter the DW_TAG_subprogram DIE, then we
+        // can't let this become
+        // a method in a class. Why? Because templatized functions are only
+        // emitted if one of the
+        // templatized methods is used in the current compile unit and we will
+        // end up with classes
+        // that may or may not include these member functions and this means one
+        // class won't match another
+        // class definition and it affects our ability to use a class in the
+        // clang expression parser. So
+        // for the greater good, we currently must not allow any template member
+        // functions in a class definition.
+        if (is_cxx_method && has_template_params) {
+          ignore_containing_context = true;
+          is_cxx_method = false;
+        }
+
+        // clang_type will get the function prototype clang type after this call
+        clang_type = m_ast.CreateFunctionType(
+            return_clang_type, function_param_types.data(),
+            function_param_types.size(), is_variadic, type_quals);
+
+        if (type_name_cstr) {
+          bool type_handled = false;
+          if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
+            ObjCLanguage::MethodName objc_method(type_name_cstr, true);
+            if (objc_method.IsValid(true)) {
+              CompilerType class_opaque_type;
+              ConstString class_name(objc_method.GetClassName());
+              if (class_name) {
+                TypeSP complete_objc_class_type_sp(
+                    dwarf->FindCompleteObjCDefinitionTypeForDIE(
+                        DWARFDIE(), class_name, false));
+
+                if (complete_objc_class_type_sp) {
+                  CompilerType type_clang_forward_type =
+                      complete_objc_class_type_sp->GetForwardCompilerType();
+                  if (ClangASTContext::IsObjCObjectOrInterfaceType(
+                          type_clang_forward_type))
+                    class_opaque_type = type_clang_forward_type;
+                }
+              }
+
+              if (class_opaque_type) {
+                // If accessibility isn't set to anything valid, assume public
+                // for
+                // now...
+                if (accessibility == eAccessNone)
+                  accessibility = eAccessPublic;
+
+                clang::ObjCMethodDecl *objc_method_decl =
+                    m_ast.AddMethodToObjCObjectType(
+                        class_opaque_type, type_name_cstr, clang_type,
+                        accessibility, is_artificial, is_variadic);
+                type_handled = objc_method_decl != NULL;
+                if (type_handled) {
+                  LinkDeclContextToDIE(
+                      ClangASTContext::GetAsDeclContext(objc_method_decl), die);
+                  m_ast.SetMetadataAsUserID(objc_method_decl, die.GetID());
+                } else {
+                  dwarf->GetObjectFile()->GetModule()->ReportError(
+                      "{0x%8.8x}: invalid Objective-C method 0x%4.4x (%s), "
+                      "please file a bug and attach the file at the start of "
+                      "this error message",
+                      die.GetOffset(), tag, DW_TAG_value_to_name(tag));
+                }
+              }
+            } else if (is_cxx_method) {
+              // Look at the parent of this DIE and see if is is
+              // a class or struct and see if this is actually a
+              // C++ method
+              Type *class_type = dwarf->ResolveType(decl_ctx_die);
+              if (class_type) {
+                bool alternate_defn = false;
+                if (class_type->GetID() != decl_ctx_die.GetID() ||
+                    decl_ctx_die.GetContainingDWOModuleDIE()) {
+                  alternate_defn = true;
+
+                  // We uniqued the parent class of this function to another
+                  // class
+                  // so we now need to associate all dies under "decl_ctx_die"
+                  // to
+                  // DIEs in the DIE for "class_type"...
+                  SymbolFileDWARF *class_symfile = NULL;
+                  DWARFDIE class_type_die;
+
+                  SymbolFileDWARFDebugMap *debug_map_symfile =
+                      dwarf->GetDebugMapSymfile();
+                  if (debug_map_symfile) {
+                    class_symfile = debug_map_symfile->GetSymbolFileByOSOIndex(
+                        SymbolFileDWARFDebugMap::GetOSOIndexFromUserID(
+                            class_type->GetID()));
+                    class_type_die = class_symfile->DebugInfo()->GetDIE(
+                        DIERef(class_type->GetID(), dwarf));
+                  } else {
+                    class_symfile = dwarf;
+                    class_type_die = dwarf->DebugInfo()->GetDIE(
+                        DIERef(class_type->GetID(), dwarf));
+                  }
+                  if (class_type_die) {
+                    DWARFDIECollection failures;
+
+                    CopyUniqueClassMethodTypes(decl_ctx_die, class_type_die,
+                                               class_type, failures);
+
+                    // FIXME do something with these failures that's smarter
+                    // than
+                    // just dropping them on the ground.  Unfortunately classes
+                    // don't
+                    // like having stuff added to them after their definitions
+                    // are
+                    // complete...
+
+                    type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
+                    if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) {
+                      type_sp = type_ptr->shared_from_this();
+                      break;
+                    }
+                  }
+                }
+
+                if (specification_die_form.IsValid()) {
+                  // We have a specification which we are going to base our
+                  // function
+                  // prototype off of, so we need this type to be completed so
+                  // that the
+                  // m_die_to_decl_ctx for the method in the specification has a
+                  // valid
+                  // clang decl context.
+                  class_type->GetForwardCompilerType();
+                  // If we have a specification, then the function type should
+                  // have been
+                  // made with the specification and not with this die.
+                  DWARFDIE spec_die = dwarf->DebugInfo()->GetDIE(
+                      DIERef(specification_die_form));
+                  clang::DeclContext *spec_clang_decl_ctx =
+                      GetClangDeclContextForDIE(spec_die);
+                  if (spec_clang_decl_ctx) {
+                    LinkDeclContextToDIE(spec_clang_decl_ctx, die);
+                  } else {
+                    dwarf->GetObjectFile()->GetModule()->ReportWarning(
+                        "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8" PRIx64
+                        ") has no decl\n",
+                        die.GetID(), specification_die_form.Reference());
+                  }
+                  type_handled = true;
+                } else if (abstract_origin_die_form.IsValid()) {
+                  // We have a specification which we are going to base our
+                  // function
+                  // prototype off of, so we need this type to be completed so
+                  // that the
+                  // m_die_to_decl_ctx for the method in the abstract origin has
+                  // a valid
+                  // clang decl context.
+                  class_type->GetForwardCompilerType();
+
+                  DWARFDIE abs_die = dwarf->DebugInfo()->GetDIE(
+                      DIERef(abstract_origin_die_form));
+                  clang::DeclContext *abs_clang_decl_ctx =
+                      GetClangDeclContextForDIE(abs_die);
+                  if (abs_clang_decl_ctx) {
+                    LinkDeclContextToDIE(abs_clang_decl_ctx, die);
+                  } else {
+                    dwarf->GetObjectFile()->GetModule()->ReportWarning(
+                        "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8" PRIx64
+                        ") has no decl\n",
+                        die.GetID(), abstract_origin_die_form.Reference());
+                  }
+                  type_handled = true;
+                } else {
+                  CompilerType class_opaque_type =
+                      class_type->GetForwardCompilerType();
+                  if (ClangASTContext::IsCXXClassType(class_opaque_type)) {
+                    if (class_opaque_type.IsBeingDefined() || alternate_defn) {
+                      if (!is_static && !die.HasChildren()) {
+                        // We have a C++ member function with no children (this
+                        // pointer!)
+                        // and clang will get mad if we try and make a function
+                        // that isn't
+                        // well formed in the DWARF, so we will just skip it...
+                        type_handled = true;
+                      } else {
+                        bool add_method = true;
+                        if (alternate_defn) {
+                          // If an alternate definition for the class exists,
+                          // then add the method only if an
+                          // equivalent is not already present.
+                          clang::CXXRecordDecl *record_decl =
+                              m_ast.GetAsCXXRecordDecl(
+                                  class_opaque_type.GetOpaqueQualType());
+                          if (record_decl) {
+                            for (auto method_iter = record_decl->method_begin();
+                                 method_iter != record_decl->method_end();
+                                 method_iter++) {
+                              clang::CXXMethodDecl *method_decl = *method_iter;
+                              if (method_decl->getNameInfo().getAsString() ==
+                                  std::string(type_name_cstr)) {
+                                if (method_decl->getType() ==
+                                    ClangUtil::GetQualType(clang_type)) {
+                                  add_method = false;
+                                  LinkDeclContextToDIE(
+                                      ClangASTContext::GetAsDeclContext(
+                                          method_decl),
+                                      die);
+                                  type_handled = true;
+
+                                  break;
+                                }
+                              }
+                            }
+                          }
+                        }
+
+                        if (add_method) {
+                          // REMOVE THE CRASH DESCRIPTION BELOW
+                          Host::SetCrashDescriptionWithFormat(
+                              "SymbolFileDWARF::ParseType() is adding a method "
+                              "%s to class %s in DIE 0x%8.8" PRIx64 " from %s",
+                              type_name_cstr,
+                              class_type->GetName().GetCString(), die.GetID(),
+                              dwarf->GetObjectFile()
+                                  ->GetFileSpec()
+                                  .GetPath()
+                                  .c_str());
+
+                          const bool is_attr_used = false;
+                          // Neither GCC 4.2 nor clang++ currently set a valid
+                          // accessibility
+                          // in the DWARF for C++ methods... Default to public
+                          // for now...
+                          if (accessibility == eAccessNone)
+                            accessibility = eAccessPublic;
+
+                          clang::CXXMethodDecl *cxx_method_decl;
+                          cxx_method_decl = m_ast.AddMethodToCXXRecordType(
+                              class_opaque_type.GetOpaqueQualType(),
+                              type_name_cstr, clang_type, accessibility,
+                              is_virtual, is_static, is_inline, is_explicit,
+                              is_attr_used, is_artificial);
+
+                          type_handled = cxx_method_decl != NULL;
+
+                          if (type_handled) {
+                            LinkDeclContextToDIE(
+                                ClangASTContext::GetAsDeclContext(
+                                    cxx_method_decl),
+                                die);
 
-                                // We found a real definition for this type elsewhere
-                                // so lets use it and cache the fact that we found
-                                // a complete type for this die
-                                dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
-                                clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(dwarf->DebugInfo()->GetDIE(DIERef(type_sp->GetID(), dwarf)));
-                                if (defn_decl_ctx)
-                                    LinkDeclContextToDIE(defn_decl_ctx, die);
-                                return type_sp;
-                            }
+                            Host::SetCrashDescription(NULL);
 
-                        }
-                        DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr);
+                            ClangASTMetadata metadata;
+                            metadata.SetUserID(die.GetID());
 
-                        CompilerType enumerator_clang_type;
-                        clang_type.SetCompilerType (&m_ast, dwarf->GetForwardDeclDieToClangType().lookup (die.GetDIE()));
-                        if (!clang_type)
-                        {
-                            if (encoding_form.IsValid())
-                            {
-                                Type *enumerator_type = dwarf->ResolveTypeUID(DIERef(encoding_form));
-                                if (enumerator_type)
-                                    enumerator_clang_type = enumerator_type->GetFullCompilerType ();
-                            }
+                            if (!object_pointer_name.empty()) {
+                              metadata.SetObjectPtrName(
+                                  object_pointer_name.c_str());
+                              if (log)
+                                log->Printf(
+                                    "Setting object pointer name: %s on method "
+                                    "object %p.\n",
+                                    object_pointer_name.c_str(),
+                                    static_cast<void *>(cxx_method_decl));
+                            }
+                            m_ast.SetMetadata(cxx_method_decl, metadata);
+                          } else {
+                            ignore_containing_context = true;
+                          }
+                        }
+                      }
+                    } else {
+                      // We were asked to parse the type for a method in a
+                      // class, yet the
+                      // class hasn't been asked to complete itself through the
+                      // clang::ExternalASTSource protocol, so we need to just
+                      // have the
+                      // class complete itself and do things the right way, then
+                      // our
+                      // DIE should then have an entry in the
+                      // dwarf->GetDIEToType() map. First
+                      // we need to modify the dwarf->GetDIEToType() so it
+                      // doesn't think we are
+                      // trying to parse this DIE anymore...
+                      dwarf->GetDIEToType()[die.GetDIE()] = NULL;
+
+                      // Now we get the full type to force our class type to
+                      // complete itself
+                      // using the clang::ExternalASTSource protocol which will
+                      // parse all
+                      // base classes and all methods (including the method for
+                      // this DIE).
+                      class_type->GetFullCompilerType();
+
+                      // The type for this DIE should have been filled in the
+                      // function call above
+                      type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
+                      if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) {
+                        type_sp = type_ptr->shared_from_this();
+                        break;
+                      }
 
-                            if (!enumerator_clang_type)
-                            {
-                                if (byte_size > 0)
-                                {
-                                    enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(NULL,
-                                                                                                           DW_ATE_signed,
-                                                                                                           byte_size * 8);
-                                }
-                                else
-                                {
-                                    enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
-                                }
-                            }
+                      // FIXME This is fixing some even uglier behavior but we
+                      // really need to
+                      // uniq the methods of each class as well as the class
+                      // itself.
+                      // <rdar://problem/11240464>
+                      type_handled = true;
+                    }
+                  }
+                }
+              }
+            }
+          }
+
+          if (!type_handled) {
+            clang::FunctionDecl *function_decl = nullptr;
+
+            if (abstract_origin_die_form.IsValid()) {
+              DWARFDIE abs_die =
+                  dwarf->DebugInfo()->GetDIE(DIERef(abstract_origin_die_form));
+
+              SymbolContext sc;
+
+              if (dwarf->ResolveType(abs_die)) {
+                function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
+                    GetCachedClangDeclContextForDIE(abs_die));
+
+                if (function_decl) {
+                  LinkDeclContextToDIE(function_decl, die);
+                }
+              }
+            }
+
+            if (!function_decl) {
+              // We just have a function that isn't part of a class
+              function_decl = m_ast.CreateFunctionDeclaration(
+                  ignore_containing_context ? m_ast.GetTranslationUnitDecl()
+                                            : containing_decl_ctx,
+                  type_name_cstr, clang_type, storage, is_inline);
+
+              //                            if (template_param_infos.GetSize() >
+              //                            0)
+              //                            {
+              //                                clang::FunctionTemplateDecl
+              //                                *func_template_decl =
+              //                                CreateFunctionTemplateDecl
+              //                                (containing_decl_ctx,
+              //                                                                                                              function_decl,
+              //                                                                                                              type_name_cstr,
+              //                                                                                                              template_param_infos);
+              //
+              //                                CreateFunctionTemplateSpecializationInfo
+              //                                (function_decl,
+              //                                                                          func_template_decl,
+              //                                                                          template_param_infos);
+              //                            }
+              // Add the decl to our DIE to decl context map
+
+              lldbassert(function_decl);
+
+              if (function_decl) {
+                LinkDeclContextToDIE(function_decl, die);
+
+                if (!function_param_decls.empty())
+                  m_ast.SetFunctionParameters(function_decl,
+                                              &function_param_decls.front(),
+                                              function_param_decls.size());
+
+                ClangASTMetadata metadata;
+                metadata.SetUserID(die.GetID());
+
+                if (!object_pointer_name.empty()) {
+                  metadata.SetObjectPtrName(object_pointer_name.c_str());
+                  if (log)
+                    log->Printf("Setting object pointer name: %s on function "
+                                "object %p.",
+                                object_pointer_name.c_str(),
+                                static_cast<void *>(function_decl));
+                }
+                m_ast.SetMetadata(function_decl, metadata);
+              }
+            }
+          }
+        }
+        type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, 0, NULL,
+                               LLDB_INVALID_UID, Type::eEncodingIsUID, &decl,
+                               clang_type, Type::eResolveStateFull));
+        assert(type_sp.get());
+      } break;
+
+      case DW_TAG_array_type: {
+        // Set a bit that lets us know that we are currently parsing this
+        dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+        DWARFFormValue type_die_form;
+        int64_t first_index = 0;
+        uint32_t byte_stride = 0;
+        uint32_t bit_stride = 0;
+        bool is_vector = false;
+        const size_t num_attributes = die.GetAttributes(attributes);
 
-                            clang_type = m_ast.CreateEnumerationType (type_name_cstr,
-                                                                      GetClangDeclContextContainingDIE (die, nullptr),
-                                                                      decl,
-                                                                      enumerator_clang_type);
-                        }
-                        else
-                        {
-                            enumerator_clang_type = m_ast.GetEnumerationIntegerType (clang_type.GetOpaqueQualType());
-                        }
+        if (num_attributes > 0) {
+          uint32_t i;
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_decl_file:
+                decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+                    form_value.Unsigned()));
+                break;
+              case DW_AT_decl_line:
+                decl.SetLine(form_value.Unsigned());
+                break;
+              case DW_AT_decl_column:
+                decl.SetColumn(form_value.Unsigned());
+                break;
+              case DW_AT_name:
+                type_name_cstr = form_value.AsCString();
+                type_name_const_str.SetCString(type_name_cstr);
+                break;
 
-                        LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type), die);
+              case DW_AT_type:
+                type_die_form = form_value;
+                break;
+              case DW_AT_byte_size:
+                break; // byte_size = form_value.Unsigned(); break;
+              case DW_AT_byte_stride:
+                byte_stride = form_value.Unsigned();
+                break;
+              case DW_AT_bit_stride:
+                bit_stride = form_value.Unsigned();
+                break;
+              case DW_AT_GNU_vector:
+                is_vector = form_value.Boolean();
+                break;
+              case DW_AT_accessibility:
+                break; // accessibility =
+                       // DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
+              case DW_AT_declaration:
+                break; // is_forward_declaration = form_value.Boolean(); break;
+              case DW_AT_allocated:
+              case DW_AT_associated:
+              case DW_AT_data_location:
+              case DW_AT_description:
+              case DW_AT_ordering:
+              case DW_AT_start_scope:
+              case DW_AT_visibility:
+              case DW_AT_specification:
+              case DW_AT_abstract_origin:
+              case DW_AT_sibling:
+                break;
+              }
+            }
+          }
 
-                        type_sp.reset( new Type (die.GetID(),
-                                                 dwarf,
-                                                 type_name_const_str,
-                                                 byte_size,
-                                                 NULL,
-                                                 DIERef(encoding_form).GetUID(dwarf),
-                                                 Type::eEncodingIsUID,
-                                                 &decl,
-                                                 clang_type,
-                                                 Type::eResolveStateForward));
-
-                        if (ClangASTContext::StartTagDeclarationDefinition (clang_type))
-                        {
-                            if (die.HasChildren())
-                            {
-                                SymbolContext cu_sc(die.GetLLDBCompileUnit());
-                                bool is_signed = false;
-                                enumerator_clang_type.IsIntegerType(is_signed);
-                                ParseChildEnumerators(cu_sc, clang_type, is_signed, type_sp->GetByteSize(), die);
-                            }
-                            ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
-                        }
-                        else
-                        {
-                            dwarf->GetObjectFile()->GetModule()->ReportError("DWARF DIE at 0x%8.8x named \"%s\" was not able to start its definition.\nPlease file a bug and attach the file at the start of this error message",
-                                                                             die.GetOffset(),
-                                                                             type_name_cstr);
-                        }
-                    }
-                }
-                    break;
+          DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+                       DW_TAG_value_to_name(tag), type_name_cstr);
 
-                case DW_TAG_inlined_subroutine:
-                case DW_TAG_subprogram:
-                case DW_TAG_subroutine_type:
-                {
-                    // Set a bit that lets us know that we are currently parsing this
-                    dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-                    DWARFFormValue type_die_form;
-                    bool is_variadic = false;
-                    bool is_inline = false;
-                    bool is_static = false;
-                    bool is_virtual = false;
-                    bool is_explicit = false;
-                    bool is_artificial = false;
-                    bool has_template_params = false;
-                    DWARFFormValue specification_die_form;
-                    DWARFFormValue abstract_origin_die_form;
-                    dw_offset_t object_pointer_die_offset = DW_INVALID_OFFSET;
-
-                    unsigned type_quals = 0;
-                    clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern
-
-
-                    const size_t num_attributes = die.GetAttributes (attributes);
-                    if (num_attributes > 0)
-                    {
-                        uint32_t i;
-                        for (i=0; i<num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_decl_file:   decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
-                                    case DW_AT_decl_line:   decl.SetLine(form_value.Unsigned()); break;
-                                    case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
-                                    case DW_AT_name:
-                                        type_name_cstr = form_value.AsCString();
-                                        type_name_const_str.SetCString(type_name_cstr);
-                                        break;
-
-                                    case DW_AT_linkage_name:
-                                    case DW_AT_MIPS_linkage_name:   break; // mangled = form_value.AsCString(&dwarf->get_debug_str_data()); break;
-                                    case DW_AT_type:                type_die_form = form_value; break;
-                                    case DW_AT_accessibility:       accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
-                                    case DW_AT_declaration:         break; // is_forward_declaration = form_value.Boolean(); break;
-                                    case DW_AT_inline:              is_inline = form_value.Boolean(); break;
-                                    case DW_AT_virtuality:          is_virtual = form_value.Boolean();  break;
-                                    case DW_AT_explicit:            is_explicit = form_value.Boolean();  break;
-                                    case DW_AT_artificial:          is_artificial = form_value.Boolean();  break;
-
-
-                                    case DW_AT_external:
-                                        if (form_value.Unsigned())
-                                        {
-                                            if (storage == clang::SC_None)
-                                                storage = clang::SC_Extern;
-                                            else
-                                                storage = clang::SC_PrivateExtern;
-                                        }
-                                        break;
-
-                                    case DW_AT_specification:
-                                        specification_die_form = form_value;
-                                        break;
-
-                                    case DW_AT_abstract_origin:
-                                        abstract_origin_die_form = form_value;
-                                        break;
-
-                                    case DW_AT_object_pointer:
-                                        object_pointer_die_offset = form_value.Reference();
-                                        break;
-
-                                    case DW_AT_allocated:
-                                    case DW_AT_associated:
-                                    case DW_AT_address_class:
-                                    case DW_AT_calling_convention:
-                                    case DW_AT_data_location:
-                                    case DW_AT_elemental:
-                                    case DW_AT_entry_pc:
-                                    case DW_AT_frame_base:
-                                    case DW_AT_high_pc:
-                                    case DW_AT_low_pc:
-                                    case DW_AT_prototyped:
-                                    case DW_AT_pure:
-                                    case DW_AT_ranges:
-                                    case DW_AT_recursive:
-                                    case DW_AT_return_addr:
-                                    case DW_AT_segment:
-                                    case DW_AT_start_scope:
-                                    case DW_AT_static_link:
-                                    case DW_AT_trampoline:
-                                    case DW_AT_visibility:
-                                    case DW_AT_vtable_elem_location:
-                                    case DW_AT_description:
-                                    case DW_AT_sibling:
-                                        break;
-                                }
-                            }
-                        }
-                    }
+          DIERef type_die_ref(type_die_form);
+          Type *element_type = dwarf->ResolveTypeUID(type_die_ref);
+
+          if (element_type) {
+            std::vector<uint64_t> element_orders;
+            ParseChildArrayInfo(sc, die, first_index, element_orders,
+                                byte_stride, bit_stride);
+            if (byte_stride == 0 && bit_stride == 0)
+              byte_stride = element_type->GetByteSize();
+            CompilerType array_element_type =
+                element_type->GetForwardCompilerType();
+
+            if (ClangASTContext::IsCXXClassType(array_element_type) &&
+                array_element_type.GetCompleteType() == false) {
+              ModuleSP module_sp = die.GetModule();
+              if (module_sp) {
+                if (die.GetCU()->GetProducer() ==
+                    DWARFCompileUnit::eProducerClang)
+                  module_sp->ReportError(
+                      "DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
+                      "class/union/struct element type DIE 0x%8.8x that is a "
+                      "forward declaration, not a complete definition.\nTry "
+                      "compiling the source file with -fno-limit-debug-info or "
+                      "disable -gmodule",
+                      die.GetOffset(), type_die_ref.die_offset);
+                else
+                  module_sp->ReportError(
+                      "DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
+                      "class/union/struct element type DIE 0x%8.8x that is a "
+                      "forward declaration, not a complete definition.\nPlease "
+                      "file a bug against the compiler and include the "
+                      "preprocessed output for %s",
+                      die.GetOffset(), type_die_ref.die_offset,
+                      die.GetLLDBCompileUnit()
+                          ? die.GetLLDBCompileUnit()->GetPath().c_str()
+                          : "the source file");
+              }
+
+              // We have no choice other than to pretend that the element class
+              // type
+              // is complete. If we don't do this, clang will crash when trying
+              // to layout the class. Since we provide layout assistance, all
+              // ivars in this class and other classes will be fine, this is
+              // the best we can do short of crashing.
+              if (ClangASTContext::StartTagDeclarationDefinition(
+                      array_element_type)) {
+                ClangASTContext::CompleteTagDeclarationDefinition(
+                    array_element_type);
+              } else {
+                module_sp->ReportError("DWARF DIE at 0x%8.8x was not able to "
+                                       "start its definition.\nPlease file a "
+                                       "bug and attach the file at the start "
+                                       "of this error message",
+                                       type_die_ref.die_offset);
+              }
+            }
+
+            uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
+            if (element_orders.size() > 0) {
+              uint64_t num_elements = 0;
+              std::vector<uint64_t>::const_reverse_iterator pos;
+              std::vector<uint64_t>::const_reverse_iterator end =
+                  element_orders.rend();
+              for (pos = element_orders.rbegin(); pos != end; ++pos) {
+                num_elements = *pos;
+                clang_type = m_ast.CreateArrayType(array_element_type,
+                                                   num_elements, is_vector);
+                array_element_type = clang_type;
+                array_element_bit_stride =
+                    num_elements ? array_element_bit_stride * num_elements
+                                 : array_element_bit_stride;
+              }
+            } else {
+              clang_type =
+                  m_ast.CreateArrayType(array_element_type, 0, is_vector);
+            }
+            ConstString empty_name;
+            type_sp.reset(new Type(
+                die.GetID(), dwarf, empty_name, array_element_bit_stride / 8,
+                NULL, DIERef(type_die_form).GetUID(dwarf), Type::eEncodingIsUID,
+                &decl, clang_type, Type::eResolveStateFull));
+            type_sp->SetEncodingType(element_type);
+          }
+        }
+      } break;
+
+      case DW_TAG_ptr_to_member_type: {
+        DWARFFormValue type_die_form;
+        DWARFFormValue containing_type_die_form;
 
-                    std::string object_pointer_name;
-                    if (object_pointer_die_offset != DW_INVALID_OFFSET)
-                    {
-                        DWARFDIE object_pointer_die = die.GetDIE (object_pointer_die_offset);
-                        if (object_pointer_die)
-                        {
-                            const char *object_pointer_name_cstr = object_pointer_die.GetName();
-                            if (object_pointer_name_cstr)
-                                object_pointer_name = object_pointer_name_cstr;
-                        }
-                    }
+        const size_t num_attributes = die.GetAttributes(attributes);
 
-                    DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr);
+        if (num_attributes > 0) {
+          uint32_t i;
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_type:
+                type_die_form = form_value;
+                break;
+              case DW_AT_containing_type:
+                containing_type_die_form = form_value;
+                break;
+              }
+            }
+          }
 
-                    CompilerType return_clang_type;
-                    Type *func_type = NULL;
+          Type *pointee_type = dwarf->ResolveTypeUID(DIERef(type_die_form));
+          Type *class_type =
+              dwarf->ResolveTypeUID(DIERef(containing_type_die_form));
 
-                    if (type_die_form.IsValid())
-                        func_type = dwarf->ResolveTypeUID(DIERef(type_die_form));
+          CompilerType pointee_clang_type =
+              pointee_type->GetForwardCompilerType();
+          CompilerType class_clang_type = class_type->GetLayoutCompilerType();
 
-                    if (func_type)
-                        return_clang_type = func_type->GetForwardCompilerType ();
-                    else
-                        return_clang_type = m_ast.GetBasicType(eBasicTypeVoid);
+          clang_type = ClangASTContext::CreateMemberPointerType(
+              class_clang_type, pointee_clang_type);
 
+          byte_size = clang_type.GetByteSize(nullptr);
 
-                    std::vector<CompilerType> function_param_types;
-                    std::vector<clang::ParmVarDecl*> function_param_decls;
+          type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
+                                 byte_size, NULL, LLDB_INVALID_UID,
+                                 Type::eEncodingIsUID, NULL, clang_type,
+                                 Type::eResolveStateForward));
+        }
 
-                    // Parse the function children for the parameters
+        break;
+      }
+      default:
+        dwarf->GetObjectFile()->GetModule()->ReportError(
+            "{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and "
+            "attach the file at the start of this error message",
+            die.GetOffset(), tag, DW_TAG_value_to_name(tag));
+        break;
+      }
 
-                    DWARFDIE decl_ctx_die;
-                    clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (die, &decl_ctx_die);
-                    const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind();
+      if (type_sp.get()) {
+        DWARFDIE sc_parent_die =
+            SymbolFileDWARF::GetParentSymbolContextDIE(die);
+        dw_tag_t sc_parent_tag = sc_parent_die.Tag();
 
-                    bool is_cxx_method = DeclKindIsCXXClass (containing_decl_kind);
-                    // Start off static. This will be set to false in ParseChildParameters(...)
-                    // if we find a "this" parameters as the first parameter
-                    if (is_cxx_method)
-                    {
-                        is_static = true;
-                    }
+        SymbolContextScope *symbol_context_scope = NULL;
+        if (sc_parent_tag == DW_TAG_compile_unit) {
+          symbol_context_scope = sc.comp_unit;
+        } else if (sc.function != NULL && sc_parent_die) {
+          symbol_context_scope =
+              sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
+          if (symbol_context_scope == NULL)
+            symbol_context_scope = sc.function;
+        }
 
-                    if (die.HasChildren())
-                    {
-                        bool skip_artificial = true;
-                        ParseChildParameters (sc,
-                                              containing_decl_ctx,
-                                              die,
-                                              skip_artificial,
-                                              is_static,
-                                              is_variadic,
-                                              has_template_params,
-                                              function_param_types,
-                                              function_param_decls,
-                                              type_quals);
-                    }
+        if (symbol_context_scope != NULL) {
+          type_sp->SetSymbolContextScope(symbol_context_scope);
+        }
 
-                    bool ignore_containing_context = false;
-                    // Check for templatized class member functions. If we had any DW_TAG_template_type_parameter
-                    // or DW_TAG_template_value_parameter the DW_TAG_subprogram DIE, then we can't let this become
-                    // a method in a class. Why? Because templatized functions are only emitted if one of the
-                    // templatized methods is used in the current compile unit and we will end up with classes
-                    // that may or may not include these member functions and this means one class won't match another
-                    // class definition and it affects our ability to use a class in the clang expression parser. So
-                    // for the greater good, we currently must not allow any template member functions in a class definition.
-                    if (is_cxx_method && has_template_params)
-                    {
-                        ignore_containing_context = true;
-                        is_cxx_method = false;
-                    }
+        // We are ready to put this type into the uniqued list up at the module
+        // level
+        type_list->Insert(type_sp);
 
-                    // clang_type will get the function prototype clang type after this call
-                    clang_type = m_ast.CreateFunctionType (return_clang_type,
-                                                           function_param_types.data(),
-                                                           function_param_types.size(),
-                                                           is_variadic,
-                                                           type_quals);
-
-
-                    if (type_name_cstr)
-                    {
-                        bool type_handled = false;
-                        if (tag == DW_TAG_subprogram ||
-                            tag == DW_TAG_inlined_subroutine)
-                        {
-                            ObjCLanguage::MethodName objc_method (type_name_cstr, true);
-                            if (objc_method.IsValid(true))
-                            {
-                                CompilerType class_opaque_type;
-                                ConstString class_name(objc_method.GetClassName());
-                                if (class_name)
-                                {
-                                    TypeSP complete_objc_class_type_sp (dwarf->FindCompleteObjCDefinitionTypeForDIE (DWARFDIE(), class_name, false));
-
-                                    if (complete_objc_class_type_sp)
-                                    {
-                                        CompilerType type_clang_forward_type = complete_objc_class_type_sp->GetForwardCompilerType ();
-                                        if (ClangASTContext::IsObjCObjectOrInterfaceType(type_clang_forward_type))
-                                            class_opaque_type = type_clang_forward_type;
-                                    }
-                                }
+        dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+      }
+    } else if (type_ptr != DIE_IS_BEING_PARSED) {
+      type_sp = type_ptr->shared_from_this();
+    }
+  }
+  return type_sp;
+}
 
-                                if (class_opaque_type)
-                                {
-                                    // If accessibility isn't set to anything valid, assume public for
-                                    // now...
-                                    if (accessibility == eAccessNone)
-                                        accessibility = eAccessPublic;
-
-                                    clang::ObjCMethodDecl *objc_method_decl = m_ast.AddMethodToObjCObjectType (class_opaque_type,
-                                                                                                               type_name_cstr,
-                                                                                                               clang_type,
-                                                                                                               accessibility,
-                                                                                                               is_artificial,
-                                                                                                               is_variadic);
-                                    type_handled = objc_method_decl != NULL;
-                                    if (type_handled)
-                                    {
-                                        LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(objc_method_decl), die);
-                                        m_ast.SetMetadataAsUserID (objc_method_decl, die.GetID());
-                                    }
-                                    else
-                                    {
-                                        dwarf->GetObjectFile()->GetModule()->ReportError ("{0x%8.8x}: invalid Objective-C method 0x%4.4x (%s), please file a bug and attach the file at the start of this error message",
-                                                                                          die.GetOffset(),
-                                                                                          tag,
-                                                                                          DW_TAG_value_to_name(tag));
-                                    }
-                                }
-                            }
-                            else if (is_cxx_method)
-                            {
-                                // Look at the parent of this DIE and see if is is
-                                // a class or struct and see if this is actually a
-                                // C++ method
-                                Type *class_type = dwarf->ResolveType (decl_ctx_die);
-                                if (class_type)
-                                {
-                                    bool alternate_defn = false;
-                                    if (class_type->GetID() != decl_ctx_die.GetID() || decl_ctx_die.GetContainingDWOModuleDIE())
-                                    {
-                                        alternate_defn = true;
-
-                                        // We uniqued the parent class of this function to another class
-                                        // so we now need to associate all dies under "decl_ctx_die" to
-                                        // DIEs in the DIE for "class_type"...
-                                        SymbolFileDWARF *class_symfile = NULL;
-                                        DWARFDIE class_type_die;
-
-                                        SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile();
-                                        if (debug_map_symfile)
-                                        {
-                                            class_symfile = debug_map_symfile->GetSymbolFileByOSOIndex(SymbolFileDWARFDebugMap::GetOSOIndexFromUserID(class_type->GetID()));
-                                            class_type_die = class_symfile->DebugInfo()->GetDIE (DIERef(class_type->GetID(), dwarf));
-                                        }
-                                        else
-                                        {
-                                            class_symfile = dwarf;
-                                            class_type_die = dwarf->DebugInfo()->GetDIE (DIERef(class_type->GetID(), dwarf));
-                                        }
-                                        if (class_type_die)
-                                        {
-                                            DWARFDIECollection failures;
-
-                                            CopyUniqueClassMethodTypes (decl_ctx_die,
-                                                                        class_type_die,
-                                                                        class_type,
-                                                                        failures);
-
-                                            // FIXME do something with these failures that's smarter than
-                                            // just dropping them on the ground.  Unfortunately classes don't
-                                            // like having stuff added to them after their definitions are
-                                            // complete...
-
-                                            type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
-                                            if (type_ptr && type_ptr != DIE_IS_BEING_PARSED)
-                                            {
-                                                type_sp = type_ptr->shared_from_this();
-                                                break;
-                                            }
-                                        }
-                                    }
-
-                                    if (specification_die_form.IsValid())
-                                    {
-                                        // We have a specification which we are going to base our function
-                                        // prototype off of, so we need this type to be completed so that the
-                                        // m_die_to_decl_ctx for the method in the specification has a valid
-                                        // clang decl context.
-                                        class_type->GetForwardCompilerType ();
-                                        // If we have a specification, then the function type should have been
-                                        // made with the specification and not with this die.
-                                        DWARFDIE spec_die = dwarf->DebugInfo()->GetDIE(DIERef(specification_die_form));
-                                        clang::DeclContext *spec_clang_decl_ctx = GetClangDeclContextForDIE (spec_die);
-                                        if (spec_clang_decl_ctx)
-                                        {
-                                            LinkDeclContextToDIE(spec_clang_decl_ctx, die);
-                                        }
-                                        else
-                                        {
-                                            dwarf->GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8" PRIx64 ") has no decl\n",
-                                                                                                die.GetID(),
-                                                                                                specification_die_form.Reference());
-                                        }
-                                        type_handled = true;
-                                    }
-                                    else if (abstract_origin_die_form.IsValid())
-                                    {
-                                        // We have a specification which we are going to base our function
-                                        // prototype off of, so we need this type to be completed so that the
-                                        // m_die_to_decl_ctx for the method in the abstract origin has a valid
-                                        // clang decl context.
-                                        class_type->GetForwardCompilerType ();
-
-                                        DWARFDIE abs_die = dwarf->DebugInfo()->GetDIE (DIERef(abstract_origin_die_form));
-                                        clang::DeclContext *abs_clang_decl_ctx = GetClangDeclContextForDIE (abs_die);
-                                        if (abs_clang_decl_ctx)
-                                        {
-                                            LinkDeclContextToDIE (abs_clang_decl_ctx, die);
-                                        }
-                                        else
-                                        {
-                                            dwarf->GetObjectFile()->GetModule()->ReportWarning ("0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8" PRIx64 ") has no decl\n",
-                                                                                                die.GetID(),
-                                                                                                abstract_origin_die_form.Reference());
-                                        }
-                                        type_handled = true;
-                                    }
-                                    else
-                                    {
-                                        CompilerType class_opaque_type = class_type->GetForwardCompilerType ();
-                                        if (ClangASTContext::IsCXXClassType(class_opaque_type))
-                                        {
-                                            if (class_opaque_type.IsBeingDefined () || alternate_defn)
-                                            {
-                                                if (!is_static && !die.HasChildren())
-                                                {
-                                                    // We have a C++ member function with no children (this pointer!)
-                                                    // and clang will get mad if we try and make a function that isn't
-                                                    // well formed in the DWARF, so we will just skip it...
-                                                    type_handled = true;
-                                                }
-                                                else
-                                                {
-                                                    bool add_method = true;
-                                                    if (alternate_defn)
-                                                    {
-                                                        // If an alternate definition for the class exists, then add the method only if an
-                                                        // equivalent is not already present.
-                                                        clang::CXXRecordDecl *record_decl = m_ast.GetAsCXXRecordDecl(class_opaque_type.GetOpaqueQualType());
-                                                        if (record_decl)
-                                                        {
-                                                            for (auto method_iter = record_decl->method_begin();
-                                                                 method_iter != record_decl->method_end();
-                                                                 method_iter++)
-                                                            {
-                                                                clang::CXXMethodDecl *method_decl = *method_iter;
-                                                                if (method_decl->getNameInfo().getAsString() == std::string(type_name_cstr))
-                                                                {
-                                                                    if (method_decl->getType() ==
-                                                                        ClangUtil::GetQualType(clang_type))
-                                                                    {
-                                                                        add_method = false;
-                                                                        LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(method_decl), die);
-                                                                        type_handled = true;
-
-                                                                        break;
-                                                                    }
-                                                                }
-                                                            }
-                                                        }
-                                                    }
-
-                                                    if (add_method)
-                                                    {
-                                                        // REMOVE THE CRASH DESCRIPTION BELOW
-                                                        Host::SetCrashDescriptionWithFormat ("SymbolFileDWARF::ParseType() is adding a method %s to class %s in DIE 0x%8.8" PRIx64 " from %s",
-                                                                                             type_name_cstr,
-                                                                                             class_type->GetName().GetCString(),
-                                                                                             die.GetID(),
-                                                                                             dwarf->GetObjectFile()->GetFileSpec().GetPath().c_str());
-
-                                                        const bool is_attr_used = false;
-                                                        // Neither GCC 4.2 nor clang++ currently set a valid accessibility
-                                                        // in the DWARF for C++ methods... Default to public for now...
-                                                        if (accessibility == eAccessNone)
-                                                            accessibility = eAccessPublic;
-
-                                                        clang::CXXMethodDecl *cxx_method_decl;
-                                                        cxx_method_decl = m_ast.AddMethodToCXXRecordType (class_opaque_type.GetOpaqueQualType(),
-                                                                                                          type_name_cstr,
-                                                                                                          clang_type,
-                                                                                                          accessibility,
-                                                                                                          is_virtual,
-                                                                                                          is_static,
-                                                                                                          is_inline,
-                                                                                                          is_explicit,
-                                                                                                          is_attr_used,
-                                                                                                          is_artificial);
-
-                                                        type_handled = cxx_method_decl != NULL;
-
-                                                        if (type_handled)
-                                                        {
-                                                            LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(cxx_method_decl), die);
-
-                                                            Host::SetCrashDescription (NULL);
-
-                                                            ClangASTMetadata metadata;
-                                                            metadata.SetUserID(die.GetID());
-
-                                                            if (!object_pointer_name.empty())
-                                                            {
-                                                                metadata.SetObjectPtrName(object_pointer_name.c_str());
-                                                                if (log)
-                                                                    log->Printf ("Setting object pointer name: %s on method object %p.\n",
-                                                                                 object_pointer_name.c_str(),
-                                                                                 static_cast<void*>(cxx_method_decl));
-                                                            }
-                                                            m_ast.SetMetadata (cxx_method_decl, metadata);
-                                                        }
-                                                        else
-                                                        {
-                                                            ignore_containing_context = true;
-                                                        }
-                                                    }
-                                                }
-                                            }
-                                            else
-                                            {
-                                                // We were asked to parse the type for a method in a class, yet the
-                                                // class hasn't been asked to complete itself through the
-                                                // clang::ExternalASTSource protocol, so we need to just have the
-                                                // class complete itself and do things the right way, then our
-                                                // DIE should then have an entry in the dwarf->GetDIEToType() map. First
-                                                // we need to modify the dwarf->GetDIEToType() so it doesn't think we are
-                                                // trying to parse this DIE anymore...
-                                                dwarf->GetDIEToType()[die.GetDIE()] = NULL;
-
-                                                // Now we get the full type to force our class type to complete itself
-                                                // using the clang::ExternalASTSource protocol which will parse all
-                                                // base classes and all methods (including the method for this DIE).
-                                                class_type->GetFullCompilerType ();
-
-                                                // The type for this DIE should have been filled in the function call above
-                                                type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
-                                                if (type_ptr && type_ptr != DIE_IS_BEING_PARSED)
-                                                {
-                                                    type_sp = type_ptr->shared_from_this();
-                                                    break;
-                                                }
-
-                                                // FIXME This is fixing some even uglier behavior but we really need to
-                                                // uniq the methods of each class as well as the class itself.
-                                                // <rdar://problem/11240464>
-                                                type_handled = true;
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                        }
+// DWARF parsing functions
 
-                        if (!type_handled)
-                        {
-                            clang::FunctionDecl *function_decl = nullptr;
-                            
-                            if (abstract_origin_die_form.IsValid())
-                            {
-                                DWARFDIE abs_die = dwarf->DebugInfo()->GetDIE (DIERef(abstract_origin_die_form));
-
-                                SymbolContext sc;
-                                
-                                if (dwarf->ResolveType (abs_die))
-                                {
-                                    function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(GetCachedClangDeclContextForDIE(abs_die));
-                            
-                                    if (function_decl)
-                                    {
-                                        LinkDeclContextToDIE(function_decl, die);
-                                    }
-                                }
-                            }
+class DWARFASTParserClang::DelayedAddObjCClassProperty {
+public:
+  DelayedAddObjCClassProperty(
+      const CompilerType &class_opaque_type, const char *property_name,
+      const CompilerType &property_opaque_type, // The property type is only
+                                                // required if you don't have an
+                                                // ivar decl
+      clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name,
+      const char *property_getter_name, uint32_t property_attributes,
+      const ClangASTMetadata *metadata)
+      : m_class_opaque_type(class_opaque_type), m_property_name(property_name),
+        m_property_opaque_type(property_opaque_type), m_ivar_decl(ivar_decl),
+        m_property_setter_name(property_setter_name),
+        m_property_getter_name(property_getter_name),
+        m_property_attributes(property_attributes) {
+    if (metadata != NULL) {
+      m_metadata_ap.reset(new ClangASTMetadata());
+      *m_metadata_ap = *metadata;
+    }
+  }
+
+  DelayedAddObjCClassProperty(const DelayedAddObjCClassProperty &rhs) {
+    *this = rhs;
+  }
+
+  DelayedAddObjCClassProperty &
+  operator=(const DelayedAddObjCClassProperty &rhs) {
+    m_class_opaque_type = rhs.m_class_opaque_type;
+    m_property_name = rhs.m_property_name;
+    m_property_opaque_type = rhs.m_property_opaque_type;
+    m_ivar_decl = rhs.m_ivar_decl;
+    m_property_setter_name = rhs.m_property_setter_name;
+    m_property_getter_name = rhs.m_property_getter_name;
+    m_property_attributes = rhs.m_property_attributes;
+
+    if (rhs.m_metadata_ap.get()) {
+      m_metadata_ap.reset(new ClangASTMetadata());
+      *m_metadata_ap = *rhs.m_metadata_ap;
+    }
+    return *this;
+  }
+
+  bool Finalize() {
+    return ClangASTContext::AddObjCClassProperty(
+        m_class_opaque_type, m_property_name, m_property_opaque_type,
+        m_ivar_decl, m_property_setter_name, m_property_getter_name,
+        m_property_attributes, m_metadata_ap.get());
+  }
 
-                            if (!function_decl)
-                            {
-                                // We just have a function that isn't part of a class
-                                function_decl = m_ast.CreateFunctionDeclaration (ignore_containing_context ? m_ast.GetTranslationUnitDecl() : containing_decl_ctx,
-                                                                                                      type_name_cstr,
-                                                                                                      clang_type,
-                                                                                                      storage,
-                                                                                                      is_inline);
-
-                                //                            if (template_param_infos.GetSize() > 0)
-                                //                            {
-                                //                                clang::FunctionTemplateDecl *func_template_decl = CreateFunctionTemplateDecl (containing_decl_ctx,
-                                //                                                                                                              function_decl,
-                                //                                                                                                              type_name_cstr,
-                                //                                                                                                              template_param_infos);
-                                //
-                                //                                CreateFunctionTemplateSpecializationInfo (function_decl,
-                                //                                                                          func_template_decl,
-                                //                                                                          template_param_infos);
-                                //                            }
-                                // Add the decl to our DIE to decl context map
-                                
-                                lldbassert (function_decl);
-                                
-                                if (function_decl)
-                                {
-                                    LinkDeclContextToDIE(function_decl, die);
-                                    
-                                    if (!function_param_decls.empty())
-                                        m_ast.SetFunctionParameters (function_decl,
-                                                                     &function_param_decls.front(),
-                                                                     function_param_decls.size());
-                                    
-                                    ClangASTMetadata metadata;
-                                    metadata.SetUserID(die.GetID());
-                                    
-                                    if (!object_pointer_name.empty())
-                                    {
-                                        metadata.SetObjectPtrName(object_pointer_name.c_str());
-                                        if (log)
-                                            log->Printf ("Setting object pointer name: %s on function object %p.",
-                                                         object_pointer_name.c_str(),
-                                                         static_cast<void*>(function_decl));
-                                    }
-                                    m_ast.SetMetadata (function_decl, metadata);
-                                }
-                            }
-                        }
-                    }
-                    type_sp.reset( new Type (die.GetID(),
-                                             dwarf,
-                                             type_name_const_str,
-                                             0,
-                                             NULL,
-                                             LLDB_INVALID_UID,
-                                             Type::eEncodingIsUID,
-                                             &decl,
-                                             clang_type,
-                                             Type::eResolveStateFull));
-                    assert(type_sp.get());
-                }
-                    break;
+private:
+  CompilerType m_class_opaque_type;
+  const char *m_property_name;
+  CompilerType m_property_opaque_type;
+  clang::ObjCIvarDecl *m_ivar_decl;
+  const char *m_property_setter_name;
+  const char *m_property_getter_name;
+  uint32_t m_property_attributes;
+  std::unique_ptr<ClangASTMetadata> m_metadata_ap;
+};
 
-                case DW_TAG_array_type:
-                {
-                    // Set a bit that lets us know that we are currently parsing this
-                    dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-                    DWARFFormValue type_die_form;
-                    int64_t first_index = 0;
-                    uint32_t byte_stride = 0;
-                    uint32_t bit_stride = 0;
-                    bool is_vector = false;
-                    const size_t num_attributes = die.GetAttributes (attributes);
-
-                    if (num_attributes > 0)
-                    {
-                        uint32_t i;
-                        for (i=0; i<num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_decl_file:   decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
-                                    case DW_AT_decl_line:   decl.SetLine(form_value.Unsigned()); break;
-                                    case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
-                                    case DW_AT_name:
-                                        type_name_cstr = form_value.AsCString();
-                                        type_name_const_str.SetCString(type_name_cstr);
-                                        break;
-
-                                    case DW_AT_type:            type_die_form = form_value; break;
-                                    case DW_AT_byte_size:       break; // byte_size = form_value.Unsigned(); break;
-                                    case DW_AT_byte_stride:     byte_stride = form_value.Unsigned(); break;
-                                    case DW_AT_bit_stride:      bit_stride = form_value.Unsigned(); break;
-                                    case DW_AT_GNU_vector:      is_vector = form_value.Boolean(); break;
-                                    case DW_AT_accessibility:   break; // accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
-                                    case DW_AT_declaration:     break; // is_forward_declaration = form_value.Boolean(); break;
-                                    case DW_AT_allocated:
-                                    case DW_AT_associated:
-                                    case DW_AT_data_location:
-                                    case DW_AT_description:
-                                    case DW_AT_ordering:
-                                    case DW_AT_start_scope:
-                                    case DW_AT_visibility:
-                                    case DW_AT_specification:
-                                    case DW_AT_abstract_origin:
-                                    case DW_AT_sibling:
-                                        break;
-                                }
-                            }
-                        }
+bool DWARFASTParserClang::ParseTemplateDIE(
+    const DWARFDIE &die,
+    ClangASTContext::TemplateParameterInfos &template_param_infos) {
+  const dw_tag_t tag = die.Tag();
+
+  switch (tag) {
+  case DW_TAG_template_type_parameter:
+  case DW_TAG_template_value_parameter: {
+    DWARFAttributes attributes;
+    const size_t num_attributes = die.GetAttributes(attributes);
+    const char *name = nullptr;
+    CompilerType clang_type;
+    uint64_t uval64 = 0;
+    bool uval64_valid = false;
+    if (num_attributes > 0) {
+      DWARFFormValue form_value;
+      for (size_t i = 0; i < num_attributes; ++i) {
+        const dw_attr_t attr = attributes.AttributeAtIndex(i);
+
+        switch (attr) {
+        case DW_AT_name:
+          if (attributes.ExtractFormValueAtIndex(i, form_value))
+            name = form_value.AsCString();
+          break;
+
+        case DW_AT_type:
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            Type *lldb_type = die.ResolveTypeUID(DIERef(form_value));
+            if (lldb_type)
+              clang_type = lldb_type->GetForwardCompilerType();
+          }
+          break;
+
+        case DW_AT_const_value:
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            uval64_valid = true;
+            uval64 = form_value.Unsigned();
+          }
+          break;
+        default:
+          break;
+        }
+      }
 
-                        DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr);
+      clang::ASTContext *ast = m_ast.getASTContext();
+      if (!clang_type)
+        clang_type = m_ast.GetBasicType(eBasicTypeVoid);
+
+      if (clang_type) {
+        bool is_signed = false;
+        if (name && name[0])
+          template_param_infos.names.push_back(name);
+        else
+          template_param_infos.names.push_back(NULL);
 
-                        DIERef type_die_ref(type_die_form);
-                        Type *element_type = dwarf->ResolveTypeUID(type_die_ref);
+        // Get the signed value for any integer or enumeration if available
+        clang_type.IsIntegerOrEnumerationType(is_signed);
 
-                        if (element_type)
-                        {
-                            std::vector<uint64_t> element_orders;
-                            ParseChildArrayInfo(sc, die, first_index, element_orders, byte_stride, bit_stride);
-                            if (byte_stride == 0 && bit_stride == 0)
-                                byte_stride = element_type->GetByteSize();
-                            CompilerType array_element_type = element_type->GetForwardCompilerType ();
-
-                            if (ClangASTContext::IsCXXClassType(array_element_type) && array_element_type.GetCompleteType() == false)
-                            {
-                                ModuleSP module_sp = die.GetModule();
-                                if (module_sp)
-                                {
-                                    if (die.GetCU()->GetProducer() == DWARFCompileUnit::eProducerClang)
-                                        module_sp->ReportError ("DWARF DW_TAG_array_type DIE at 0x%8.8x has a class/union/struct element type DIE 0x%8.8x that is a forward declaration, not a complete definition.\nTry compiling the source file with -fno-limit-debug-info or disable -gmodule",
-                                                                die.GetOffset(),
-                                                                type_die_ref.die_offset);
-                                    else
-                                        module_sp->ReportError ("DWARF DW_TAG_array_type DIE at 0x%8.8x has a class/union/struct element type DIE 0x%8.8x that is a forward declaration, not a complete definition.\nPlease file a bug against the compiler and include the preprocessed output for %s",
-                                                                die.GetOffset(),
-                                                                type_die_ref.die_offset,
-                                                                die.GetLLDBCompileUnit() ? die.GetLLDBCompileUnit()->GetPath().c_str() : "the source file");
-                                }
-
-                                // We have no choice other than to pretend that the element class type
-                                // is complete. If we don't do this, clang will crash when trying
-                                // to layout the class. Since we provide layout assistance, all
-                                // ivars in this class and other classes will be fine, this is
-                                // the best we can do short of crashing.
-                                if (ClangASTContext::StartTagDeclarationDefinition(array_element_type))
-                                {
-                                    ClangASTContext::CompleteTagDeclarationDefinition(array_element_type);
-                                }
-                                else
-                                {
-                                    module_sp->ReportError ("DWARF DIE at 0x%8.8x was not able to start its definition.\nPlease file a bug and attach the file at the start of this error message",
-                                                            type_die_ref.die_offset);
-                                }
-                            }
-
-                            uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
-                            if (element_orders.size() > 0)
-                            {
-                                uint64_t num_elements = 0;
-                                std::vector<uint64_t>::const_reverse_iterator pos;
-                                std::vector<uint64_t>::const_reverse_iterator end = element_orders.rend();
-                                for (pos = element_orders.rbegin(); pos != end; ++pos)
-                                {
-                                    num_elements = *pos;
-                                    clang_type = m_ast.CreateArrayType (array_element_type,
-                                                                        num_elements,
-                                                                        is_vector);
-                                    array_element_type = clang_type;
-                                    array_element_bit_stride = num_elements ?
-                                    array_element_bit_stride * num_elements :
-                                    array_element_bit_stride;
-                                }
-                            }
-                            else
-                            {
-                                clang_type = m_ast.CreateArrayType (array_element_type, 0, is_vector);
-                            }
-                            ConstString empty_name;
-                            type_sp.reset( new Type (die.GetID(),
-                                                     dwarf,
-                                                     empty_name,
-                                                     array_element_bit_stride / 8,
-                                                     NULL,
-                                                     DIERef(type_die_form).GetUID(dwarf),
-                                                     Type::eEncodingIsUID,
-                                                     &decl,
-                                                     clang_type,
-                                                     Type::eResolveStateFull));
-                            type_sp->SetEncodingType (element_type);
-                        }
-                    }
-                }
-                    break;
-
-                case DW_TAG_ptr_to_member_type:
-                {
-                    DWARFFormValue type_die_form;
-                    DWARFFormValue containing_type_die_form;
-
-                    const size_t num_attributes = die.GetAttributes (attributes);
-
-                    if (num_attributes > 0) {
-                        uint32_t i;
-                        for (i=0; i<num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_type:
-                                        type_die_form = form_value; break;
-                                    case DW_AT_containing_type:
-                                        containing_type_die_form = form_value; break;
-                                }
-                            }
-                        }
-
-                        Type *pointee_type = dwarf->ResolveTypeUID(DIERef(type_die_form));
-                        Type *class_type = dwarf->ResolveTypeUID(DIERef(containing_type_die_form));
-
-                        CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType ();
-                        CompilerType class_clang_type = class_type->GetLayoutCompilerType ();
-                        
-                        clang_type = ClangASTContext::CreateMemberPointerType(class_clang_type, pointee_clang_type);
-
-                        byte_size = clang_type.GetByteSize(nullptr);
-
-                        type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, byte_size, NULL,
-                                               LLDB_INVALID_UID, Type::eEncodingIsUID, NULL, clang_type,
-                                               Type::eResolveStateForward));
-                    }
-
-                    break;
-                }
-                default:
-                    dwarf->GetObjectFile()->GetModule()->ReportError ("{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and attach the file at the start of this error message",
-                                                                      die.GetOffset(),
-                                                                      tag,
-                                                                      DW_TAG_value_to_name(tag));
-                    break;
-            }
-
-            if (type_sp.get())
-            {
-                DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die);
-                dw_tag_t sc_parent_tag = sc_parent_die.Tag();
-
-                SymbolContextScope * symbol_context_scope = NULL;
-                if (sc_parent_tag == DW_TAG_compile_unit)
-                {
-                    symbol_context_scope = sc.comp_unit;
-                }
-                else if (sc.function != NULL && sc_parent_die)
-                {
-                    symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
-                    if (symbol_context_scope == NULL)
-                        symbol_context_scope = sc.function;
-                }
-
-                if (symbol_context_scope != NULL)
-                {
-                    type_sp->SetSymbolContextScope(symbol_context_scope);
-                }
-
-                // We are ready to put this type into the uniqued list up at the module level
-                type_list->Insert (type_sp);
-
-                dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
-            }
-        }
-        else if (type_ptr != DIE_IS_BEING_PARSED)
-        {
-            type_sp = type_ptr->shared_from_this();
-        }
-    }
-    return type_sp;
-}
-
-// DWARF parsing functions
-
-class DWARFASTParserClang::DelayedAddObjCClassProperty
-{
-public:
-    DelayedAddObjCClassProperty(const CompilerType     &class_opaque_type,
-                                const char             *property_name,
-                                const CompilerType     &property_opaque_type,  // The property type is only required if you don't have an ivar decl
-                                clang::ObjCIvarDecl    *ivar_decl,
-                                const char             *property_setter_name,
-                                const char             *property_getter_name,
-                                uint32_t                property_attributes,
-                                const ClangASTMetadata *metadata) :
-    m_class_opaque_type     (class_opaque_type),
-    m_property_name         (property_name),
-    m_property_opaque_type  (property_opaque_type),
-    m_ivar_decl             (ivar_decl),
-    m_property_setter_name  (property_setter_name),
-    m_property_getter_name  (property_getter_name),
-    m_property_attributes   (property_attributes)
-    {
-        if (metadata != NULL)
-        {
-            m_metadata_ap.reset(new ClangASTMetadata());
-            *m_metadata_ap = *metadata;
-        }
-    }
-
-    DelayedAddObjCClassProperty (const DelayedAddObjCClassProperty &rhs)
-    {
-        *this = rhs;
-    }
-
-    DelayedAddObjCClassProperty& operator= (const DelayedAddObjCClassProperty &rhs)
-    {
-        m_class_opaque_type    = rhs.m_class_opaque_type;
-        m_property_name        = rhs.m_property_name;
-        m_property_opaque_type = rhs.m_property_opaque_type;
-        m_ivar_decl            = rhs.m_ivar_decl;
-        m_property_setter_name = rhs.m_property_setter_name;
-        m_property_getter_name = rhs.m_property_getter_name;
-        m_property_attributes  = rhs.m_property_attributes;
-
-        if (rhs.m_metadata_ap.get())
-        {
-            m_metadata_ap.reset (new ClangASTMetadata());
-            *m_metadata_ap = *rhs.m_metadata_ap;
-        }
-        return *this;
-    }
-
-    bool
-    Finalize()
-    {
-        return ClangASTContext::AddObjCClassProperty (m_class_opaque_type,
-                                                      m_property_name,
-                                                      m_property_opaque_type,
-                                                      m_ivar_decl,
-                                                      m_property_setter_name,
-                                                      m_property_getter_name,
-                                                      m_property_attributes,
-                                                      m_metadata_ap.get());
-    }
-
-private:
-    CompilerType            m_class_opaque_type;
-    const char             *m_property_name;
-    CompilerType            m_property_opaque_type;
-    clang::ObjCIvarDecl    *m_ivar_decl;
-    const char             *m_property_setter_name;
-    const char             *m_property_getter_name;
-    uint32_t                m_property_attributes;
-    std::unique_ptr<ClangASTMetadata> m_metadata_ap;
-};
-
-bool
-DWARFASTParserClang::ParseTemplateDIE (const DWARFDIE &die,
-                                       ClangASTContext::TemplateParameterInfos &template_param_infos)
-{
-    const dw_tag_t tag = die.Tag();
-
-    switch (tag)
-    {
-        case DW_TAG_template_type_parameter:
-        case DW_TAG_template_value_parameter:
-        {
-            DWARFAttributes attributes;
-            const size_t num_attributes = die.GetAttributes (attributes);
-            const char *name = nullptr;
-            CompilerType clang_type;
-            uint64_t uval64 = 0;
-            bool uval64_valid = false;
-            if (num_attributes > 0)
-            {
-                DWARFFormValue form_value;
-                for (size_t i=0; i<num_attributes; ++i)
-                {
-                    const dw_attr_t attr = attributes.AttributeAtIndex(i);
-
-                    switch (attr)
-                    {
-                        case DW_AT_name:
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                                name = form_value.AsCString();
-                            break;
-
-                        case DW_AT_type:
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                Type *lldb_type = die.ResolveTypeUID(DIERef(form_value));
-                                if (lldb_type)
-                                    clang_type = lldb_type->GetForwardCompilerType ();
-                            }
-                            break;
-
-                        case DW_AT_const_value:
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                uval64_valid = true;
-                                uval64 = form_value.Unsigned();
-                            }
-                            break;
-                        default:
-                            break;
-                    }
-                }
-
-                clang::ASTContext *ast = m_ast.getASTContext();
-                if (!clang_type)
-                    clang_type = m_ast.GetBasicType(eBasicTypeVoid);
-
-                if (clang_type)
-                {
-                    bool is_signed = false;
-                    if (name && name[0])
-                        template_param_infos.names.push_back(name);
-                    else
-                        template_param_infos.names.push_back(NULL);
-
-                    // Get the signed value for any integer or enumeration if available
-                    clang_type.IsIntegerOrEnumerationType (is_signed);
-
-                    if (tag == DW_TAG_template_value_parameter && uval64_valid)
-                    {
-                        llvm::APInt apint (clang_type.GetBitSize(nullptr), uval64, is_signed);
-                        template_param_infos.args.push_back(
-                            clang::TemplateArgument(*ast, llvm::APSInt(apint, !is_signed), ClangUtil::GetQualType(clang_type)));
-                    }
-                    else
-                    {
-                        template_param_infos.args.push_back(
-                            clang::TemplateArgument(ClangUtil::GetQualType(clang_type)));
-                    }
-                }
-                else
-                {
-                    return false;
-                }
-
-            }
-        }
-            return true;
-
-        default:
-            break;
-    }
-    return false;
-}
-
-bool
-DWARFASTParserClang::ParseTemplateParameterInfos (const DWARFDIE &parent_die,
-                                                  ClangASTContext::TemplateParameterInfos &template_param_infos)
-{
-
-    if (!parent_die)
-        return false;
-
-    Args template_parameter_names;
-    for (DWARFDIE die = parent_die.GetFirstChild();
-         die.IsValid();
-         die = die.GetSibling())
-    {
-        const dw_tag_t tag = die.Tag();
-
-        switch (tag)
-        {
-            case DW_TAG_template_type_parameter:
-            case DW_TAG_template_value_parameter:
-                ParseTemplateDIE (die, template_param_infos);
-                break;
-
-            default:
-                break;
-        }
-    }
-    if (template_param_infos.args.empty())
-        return false;
-    return template_param_infos.args.size() == template_param_infos.names.size();
-}
-
-bool
-DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type, CompilerType &clang_type)
-{
-    SymbolFileDWARF *dwarf = die.GetDWARF();
-
-    std::lock_guard<std::recursive_mutex> guard(dwarf->GetObjectFile()->GetModule()->GetMutex());
-
-    // Disable external storage for this type so we don't get anymore
-    // clang::ExternalASTSource queries for this type.
-    m_ast.SetHasExternalStorage (clang_type.GetOpaqueQualType(), false);
-
-    if (!die)
-        return false;
-
-#if defined LLDB_CONFIGURATION_DEBUG
-    //----------------------------------------------------------------------
-    // For debugging purposes, the LLDB_DWARF_DONT_COMPLETE_TYPENAMES
-    // environment variable can be set with one or more typenames separated
-    // by ';' characters. This will cause this function to not complete any
-    // types whose names match.
-    //
-    // Examples of setting this environment variable:
-    //
-    // LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo
-    // LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo;Bar;Baz
-    //----------------------------------------------------------------------
-    const char *dont_complete_typenames_cstr = getenv("LLDB_DWARF_DONT_COMPLETE_TYPENAMES");
-    if (dont_complete_typenames_cstr && dont_complete_typenames_cstr[0])
-    {
-        const char *die_name = die.GetName();
-        if (die_name && die_name[0])
-        {
-            const char *match = strstr(dont_complete_typenames_cstr, die_name);
-            if (match)
-            {
-                size_t die_name_length = strlen(die_name);
-                while (match)
-                {
-                    const char separator_char = ';';
-                    const char next_char = match[die_name_length];
-                    if (next_char == '\0' || next_char == separator_char)
-                    {
-                        if (match == dont_complete_typenames_cstr || match[-1] == separator_char)
-                            return false;
-                    }
-                    match = strstr(match+1, die_name);
-                }
-            }
-        }
-    }
-#endif
-
-    const dw_tag_t tag = die.Tag();
-
-    Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
-    if (log)
-        dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log,
-                                                                         "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...",
-                                                                         die.GetID(),
-                                                                         die.GetTagAsCString(),
-                                                                         type->GetName().AsCString());
-    assert (clang_type);
-    DWARFAttributes attributes;
-    switch (tag)
-    {
-        case DW_TAG_structure_type:
-        case DW_TAG_union_type:
-        case DW_TAG_class_type:
-        {
-            ClangASTImporter::LayoutInfo layout_info;
-
-            {
-                if (die.HasChildren())
-                {
-                    LanguageType class_language = eLanguageTypeUnknown;
-                    if (ClangASTContext::IsObjCObjectOrInterfaceType(clang_type))
-                    {
-                        class_language = eLanguageTypeObjC;
-                        // For objective C we don't start the definition when
-                        // the class is created.
-                        ClangASTContext::StartTagDeclarationDefinition (clang_type);
-                    }
-
-                    int tag_decl_kind = -1;
-                    AccessType default_accessibility = eAccessNone;
-                    if (tag == DW_TAG_structure_type)
-                    {
-                        tag_decl_kind = clang::TTK_Struct;
-                        default_accessibility = eAccessPublic;
-                    }
-                    else if (tag == DW_TAG_union_type)
-                    {
-                        tag_decl_kind = clang::TTK_Union;
-                        default_accessibility = eAccessPublic;
-                    }
-                    else if (tag == DW_TAG_class_type)
-                    {
-                        tag_decl_kind = clang::TTK_Class;
-                        default_accessibility = eAccessPrivate;
-                    }
-
-                    SymbolContext sc(die.GetLLDBCompileUnit());
-                    std::vector<clang::CXXBaseSpecifier *> base_classes;
-                    std::vector<int> member_accessibilities;
-                    bool is_a_class = false;
-                    // Parse members and base classes first
-                    DWARFDIECollection member_function_dies;
-
-                    DelayedPropertyList delayed_properties;
-                    ParseChildMembers (sc,
-                                       die,
-                                       clang_type,
-                                       class_language,
-                                       base_classes,
-                                       member_accessibilities,
-                                       member_function_dies,
-                                       delayed_properties,
-                                       default_accessibility,
-                                       is_a_class,
-                                       layout_info);
-
-                    // Now parse any methods if there were any...
-                    size_t num_functions = member_function_dies.Size();
-                    if (num_functions > 0)
-                    {
-                        for (size_t i=0; i<num_functions; ++i)
-                        {
-                            dwarf->ResolveType(member_function_dies.GetDIEAtIndex(i));
-                        }
-                    }
-
-                    if (class_language == eLanguageTypeObjC)
-                    {
-                        ConstString class_name (clang_type.GetTypeName());
-                        if (class_name)
-                        {
-                            DIEArray method_die_offsets;
-                            dwarf->GetObjCMethodDIEOffsets(class_name, method_die_offsets);
-
-                            if (!method_die_offsets.empty())
-                            {
-                                DWARFDebugInfo* debug_info = dwarf->DebugInfo();
-
-                                const size_t num_matches = method_die_offsets.size();
-                                for (size_t i=0; i<num_matches; ++i)
-                                {
-                                    const DIERef& die_ref = method_die_offsets[i];
-                                    DWARFDIE method_die = debug_info->GetDIE (die_ref);
-
-                                    if (method_die)
-                                        method_die.ResolveType ();
-                                }
-                            }
-
-                            for (DelayedPropertyList::iterator pi = delayed_properties.begin(), pe = delayed_properties.end();
-                                 pi != pe;
-                                 ++pi)
-                                pi->Finalize();
-                        }
-                    }
-
-                    // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we
-                    // need to tell the clang type it is actually a class.
-                    if (class_language != eLanguageTypeObjC)
-                    {
-                        if (is_a_class && tag_decl_kind != clang::TTK_Class)
-                            m_ast.SetTagTypeKind(ClangUtil::GetQualType(clang_type), clang::TTK_Class);
-                    }
-
-                    // Since DW_TAG_structure_type gets used for both classes
-                    // and structures, we may need to set any DW_TAG_member
-                    // fields to have a "private" access if none was specified.
-                    // When we parsed the child members we tracked that actual
-                    // accessibility value for each DW_TAG_member in the
-                    // "member_accessibilities" array. If the value for the
-                    // member is zero, then it was set to the "default_accessibility"
-                    // which for structs was "public". Below we correct this
-                    // by setting any fields to "private" that weren't correctly
-                    // set.
-                    if (is_a_class && !member_accessibilities.empty())
-                    {
-                        // This is a class and all members that didn't have
-                        // their access specified are private.
-                        m_ast.SetDefaultAccessForRecordFields (m_ast.GetAsRecordDecl(clang_type),
-                                                               eAccessPrivate,
-                                                               &member_accessibilities.front(),
-                                                               member_accessibilities.size());
-                    }
-
-                    if (!base_classes.empty())
-                    {
-                        // Make sure all base classes refer to complete types and not
-                        // forward declarations. If we don't do this, clang will crash
-                        // with an assertion in the call to clang_type.SetBaseClassesForClassType()
-                        for (auto &base_class : base_classes)
-                        {
-                            clang::TypeSourceInfo *type_source_info = base_class->getTypeSourceInfo();
-                            if (type_source_info)
-                            {
-                                CompilerType base_class_type (&m_ast, type_source_info->getType().getAsOpaquePtr());
-                                if (base_class_type.GetCompleteType() == false)
-                                {
-                                    auto module = dwarf->GetObjectFile()->GetModule();
-                                    module->ReportError (
-                                        ":: Class '%s' has a base class '%s' which does not have a complete definition.",
-                                        die.GetName(),
-                                        base_class_type.GetTypeName().GetCString());
-                                    if (die.GetCU()->GetProducer() == DWARFCompileUnit::eProducerClang)
-                                         module->ReportError (":: Try compiling the source file with -fno-limit-debug-info.");
-
-                                    // We have no choice other than to pretend that the base class
-                                    // is complete. If we don't do this, clang will crash when we
-                                    // call setBases() inside of "clang_type.SetBaseClassesForClassType()"
-                                    // below. Since we provide layout assistance, all ivars in this
-                                    // class and other classes will be fine, this is the best we can do
-                                    // short of crashing.
-                                    if (ClangASTContext::StartTagDeclarationDefinition (base_class_type))
-                                    {
-                                        ClangASTContext::CompleteTagDeclarationDefinition (base_class_type);
-                                    }
-                                }
-                            }
-                        }
-                        m_ast.SetBaseClassesForClassType (clang_type.GetOpaqueQualType(),
-                                                          &base_classes.front(),
-                                                          base_classes.size());
-
-                        // Clang will copy each CXXBaseSpecifier in "base_classes"
-                        // so we have to free them all.
-                        ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(),
-                                                                    base_classes.size());
-                    }
-                }
-            }
-
-            ClangASTContext::BuildIndirectFields (clang_type);
-            ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
-
-            if (!layout_info.field_offsets.empty() ||
-                !layout_info.base_offsets.empty()  ||
-                !layout_info.vbase_offsets.empty() )
-            {
-                if (type)
-                    layout_info.bit_size = type->GetByteSize() * 8;
-                if (layout_info.bit_size == 0)
-                    layout_info.bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
-
-                clang::CXXRecordDecl *record_decl = m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
-                if (record_decl)
-                {
-                    if (log)
-                    {
-                        ModuleSP module_sp = dwarf->GetObjectFile()->GetModule();
-
-                        if (module_sp)
-                        {
-                            module_sp->LogMessage (log,
-                                                   "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) caching layout info for record_decl = %p, bit_size = %" PRIu64 ", alignment = %" PRIu64 ", field_offsets[%u], base_offsets[%u], vbase_offsets[%u])",
-                                                   static_cast<void*>(clang_type.GetOpaqueQualType()),
-                                                   static_cast<void*>(record_decl),
-                                                   layout_info.bit_size,
-                                                   layout_info.alignment,
-                                                   static_cast<uint32_t>(layout_info.field_offsets.size()),
-                                                   static_cast<uint32_t>(layout_info.base_offsets.size()),
-                                                   static_cast<uint32_t>(layout_info.vbase_offsets.size()));
-
-                            uint32_t idx;
-                            {
-                                llvm::DenseMap<const clang::FieldDecl *, uint64_t>::const_iterator pos,
-                                end = layout_info.field_offsets.end();
-                                for (idx = 0, pos = layout_info.field_offsets.begin(); pos != end; ++pos, ++idx)
-                                {
-                                    module_sp->LogMessage(log,
-                                                          "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) field[%u] = { bit_offset=%u, name='%s' }",
-                                                          static_cast<void *>(clang_type.GetOpaqueQualType()),
-                                                          idx,
-                                                          static_cast<uint32_t>(pos->second),
-                                                          pos->first->getNameAsString().c_str());
-                                }
-                            }
-
-                            {
-                                llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator base_pos,
-                                base_end = layout_info.base_offsets.end();
-                                for (idx = 0, base_pos = layout_info.base_offsets.begin(); base_pos != base_end; ++base_pos, ++idx)
-                                {
-                                    module_sp->LogMessage(log,
-                                                          "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) base[%u] = { byte_offset=%u, name='%s' }",
-                                                          clang_type.GetOpaqueQualType(), idx, (uint32_t)base_pos->second.getQuantity(),
-                                                          base_pos->first->getNameAsString().c_str());
-                                }
-                            }
-                            {
-                                llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>::const_iterator vbase_pos,
-                                vbase_end = layout_info.vbase_offsets.end();
-                                for (idx = 0, vbase_pos = layout_info.vbase_offsets.begin(); vbase_pos != vbase_end; ++vbase_pos, ++idx)
-                                {
-                                    module_sp->LogMessage(log,
-                                                          "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) vbase[%u] = { byte_offset=%u, name='%s' }",
-                                                          static_cast<void *>(clang_type.GetOpaqueQualType()), idx,
-                                                          static_cast<uint32_t>(vbase_pos->second.getQuantity()),
-                                                          vbase_pos->first->getNameAsString().c_str());
-                                }
-                            }
-
-                        }
-                    }
-                    GetClangASTImporter().InsertRecordDecl(record_decl, layout_info);
-                }
-            }
-        }
-
-            return (bool)clang_type;
-
-        case DW_TAG_enumeration_type:
-            if (ClangASTContext::StartTagDeclarationDefinition (clang_type))
-            {
-                if (die.HasChildren())
-                {
-                    SymbolContext sc(die.GetLLDBCompileUnit());
-                    bool is_signed = false;
-                    clang_type.IsIntegerType(is_signed);
-                    ParseChildEnumerators(sc, clang_type, is_signed, type->GetByteSize(), die);
-                }
-                ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
-            }
-            return (bool)clang_type;
-
-        default:
-            assert(false && "not a forward clang type decl!");
-            break;
-    }
-
-    return false;
-}
-
-std::vector<DWARFDIE>
-DWARFASTParserClang::GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context)
-{
-    std::vector<DWARFDIE> result;
-    for (auto it = m_decl_ctx_to_die.find((clang::DeclContext *)decl_context.GetOpaqueDeclContext()); it != m_decl_ctx_to_die.end(); it++)
-        result.push_back(it->second);
-    return result;
-}
-
-CompilerDecl
-DWARFASTParserClang::GetDeclForUIDFromDWARF (const DWARFDIE &die)
-{
-    clang::Decl *clang_decl = GetClangDeclForDIE(die);
-    if (clang_decl != nullptr)
-        return CompilerDecl(&m_ast, clang_decl);
-    return CompilerDecl();
-}
-
-CompilerDeclContext
-DWARFASTParserClang::GetDeclContextForUIDFromDWARF (const DWARFDIE &die)
-{
-    clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (die);
-    if (clang_decl_ctx)
-        return CompilerDeclContext(&m_ast, clang_decl_ctx);
-    return CompilerDeclContext();
-}
-
-CompilerDeclContext
-DWARFASTParserClang::GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die)
-{
-    clang::DeclContext *clang_decl_ctx = GetClangDeclContextContainingDIE (die, nullptr);
-    if (clang_decl_ctx)
-        return CompilerDeclContext(&m_ast, clang_decl_ctx);
-    return CompilerDeclContext();
-}
-
-size_t
-DWARFASTParserClang::ParseChildEnumerators (const SymbolContext& sc,
-                                            lldb_private::CompilerType &clang_type,
-                                            bool is_signed,
-                                            uint32_t enumerator_byte_size,
-                                            const DWARFDIE &parent_die)
-{
-    if (!parent_die)
-        return 0;
-
-    size_t enumerators_added = 0;
-
-    for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
-    {
-        const dw_tag_t tag = die.Tag();
-        if (tag == DW_TAG_enumerator)
-        {
-            DWARFAttributes attributes;
-            const size_t num_child_attributes = die.GetAttributes(attributes);
-            if (num_child_attributes > 0)
-            {
-                const char *name = NULL;
-                bool got_value = false;
-                int64_t enum_value = 0;
-                Declaration decl;
-
-                uint32_t i;
-                for (i=0; i<num_child_attributes; ++i)
-                {
-                    const dw_attr_t attr = attributes.AttributeAtIndex(i);
-                    DWARFFormValue form_value;
-                    if (attributes.ExtractFormValueAtIndex(i, form_value))
-                    {
-                        switch (attr)
-                        {
-                            case DW_AT_const_value:
-                                got_value = true;
-                                if (is_signed)
-                                    enum_value = form_value.Signed();
-                                else
-                                    enum_value = form_value.Unsigned();
-                                break;
-
-                            case DW_AT_name:
-                                name = form_value.AsCString();
-                                break;
-
-                            case DW_AT_description:
-                            default:
-                            case DW_AT_decl_file:   decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
-                            case DW_AT_decl_line:   decl.SetLine(form_value.Unsigned()); break;
-                            case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
-                            case DW_AT_sibling:
-                                break;
-                        }
-                    }
-                }
-
-                if (name && name[0] && got_value)
-                {
-                    m_ast.AddEnumerationValueToEnumerationType (clang_type.GetOpaqueQualType(),
-                                                                m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType()),
-                                                                decl,
-                                                                name,
-                                                                enum_value,
-                                                                enumerator_byte_size * 8);
-                    ++enumerators_added;
-                }
-            }
-        }
-    }
-    return enumerators_added;
-}
-
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
-
-class DIEStack
-{
-public:
-
-    void Push (const DWARFDIE &die)
-    {
-        m_dies.push_back (die);
-    }
-
-
-    void LogDIEs (Log *log)
-    {
-        StreamString log_strm;
-        const size_t n = m_dies.size();
-        log_strm.Printf("DIEStack[%" PRIu64 "]:\n", (uint64_t)n);
-        for (size_t i=0; i<n; i++)
-        {
-            std::string qualified_name;
-            const DWARFDIE &die = m_dies[i];
-            die.GetQualifiedName(qualified_name);
-            log_strm.Printf ("[%" PRIu64 "] 0x%8.8x: %s name='%s'\n",
-                             (uint64_t)i,
-                             die.GetOffset(),
-                             die.GetTagAsCString(),
-                             qualified_name.c_str());
-        }
-        log->PutCString(log_strm.GetData());
-    }
-    void Pop ()
-    {
-        m_dies.pop_back();
-    }
-
-    class ScopedPopper
-    {
-    public:
-        ScopedPopper (DIEStack &die_stack) :
-        m_die_stack (die_stack),
-        m_valid (false)
-        {
-        }
-
-        void
-        Push (const DWARFDIE &die)
-        {
-            m_valid = true;
-            m_die_stack.Push (die);
-        }
-
-        ~ScopedPopper ()
-        {
-            if (m_valid)
-                m_die_stack.Pop();
-        }
-
-
-
-    protected:
-        DIEStack &m_die_stack;
-        bool m_valid;
-    };
-
-protected:
-    typedef std::vector<DWARFDIE> Stack;
-    Stack m_dies;
-};
-#endif
-
-Function *
-DWARFASTParserClang::ParseFunctionFromDWARF (const SymbolContext& sc,
-                                             const DWARFDIE &die)
-{
-    DWARFRangeList func_ranges;
-    const char *name = NULL;
-    const char *mangled = NULL;
-    int decl_file = 0;
-    int decl_line = 0;
-    int decl_column = 0;
-    int call_file = 0;
-    int call_line = 0;
-    int call_column = 0;
-    DWARFExpression frame_base(die.GetCU());
-
-    const dw_tag_t tag = die.Tag();
-
-    if (tag != DW_TAG_subprogram)
-        return NULL;
-
-    if (die.GetDIENamesAndRanges (name,
-                                  mangled,
-                                  func_ranges,
-                                  decl_file,
-                                  decl_line,
-                                  decl_column,
-                                  call_file,
-                                  call_line,
-                                  call_column,
-                                  &frame_base))
-    {
-
-        // Union of all ranges in the function DIE (if the function is discontiguous)
-        AddressRange func_range;
-        lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase (0);
-        lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd (0);
-        if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr)
-        {
-            ModuleSP module_sp (die.GetModule());
-            func_range.GetBaseAddress().ResolveAddressUsingFileSections (lowest_func_addr, module_sp->GetSectionList());
-            if (func_range.GetBaseAddress().IsValid())
-                func_range.SetByteSize(highest_func_addr - lowest_func_addr);
-        }
-
-        if (func_range.GetBaseAddress().IsValid())
-        {
-            Mangled func_name;
-            if (mangled)
-                func_name.SetValue(ConstString(mangled), true);
-            else if (die.GetParent().Tag() == DW_TAG_compile_unit &&
-                     Language::LanguageIsCPlusPlus(die.GetLanguage()) &&
-                     name && strcmp(name, "main") != 0)
-            {
-                // If the mangled name is not present in the DWARF, generate the demangled name
-                // using the decl context. We skip if the function is "main" as its name is
-                // never mangled.
-                bool is_static = false;
-                bool is_variadic = false;
-                bool has_template_params = false;
-                unsigned type_quals = 0;
-                std::vector<CompilerType> param_types;
-                std::vector<clang::ParmVarDecl*> param_decls;
-                DWARFDeclContext decl_ctx;
-                StreamString sstr;
-
-                die.GetDWARFDeclContext(decl_ctx);
-                sstr << decl_ctx.GetQualifiedName();
-
-                clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE(die, nullptr);
-                ParseChildParameters(sc,
-                                     containing_decl_ctx,
-                                     die,
-                                     true,
-                                     is_static,
-                                     is_variadic,
-                                     has_template_params,
-                                     param_types,
-                                     param_decls,
-                                     type_quals);
-                sstr << "(";
-                for (size_t i = 0; i < param_types.size(); i++)
-                {
-                    if (i > 0)
-                        sstr << ", ";
-                    sstr << param_types[i].GetTypeName();
-                }
-                if (is_variadic)
-                    sstr << ", ...";
-                sstr << ")";
-                if (type_quals & clang::Qualifiers::Const)
-                    sstr << " const";
-
-                func_name.SetValue(ConstString(sstr.GetData()), false);
-            }
-            else
-                func_name.SetValue(ConstString(name), false);
-
-            FunctionSP func_sp;
-            std::unique_ptr<Declaration> decl_ap;
-            if (decl_file != 0 || decl_line != 0 || decl_column != 0)
-                decl_ap.reset(new Declaration (sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file),
-                                               decl_line,
-                                               decl_column));
-
-            SymbolFileDWARF *dwarf = die.GetDWARF();
-            // Supply the type _only_ if it has already been parsed
-            Type *func_type = dwarf->GetDIEToType().lookup (die.GetDIE());
-
-            assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
-
-            if (dwarf->FixupAddress (func_range.GetBaseAddress()))
-            {
-                const user_id_t func_user_id = die.GetID();
-                func_sp.reset(new Function (sc.comp_unit,
-                                            func_user_id,       // UserID is the DIE offset
-                                            func_user_id,
-                                            func_name,
-                                            func_type,
-                                            func_range));           // first address range
-
-                if (func_sp.get() != NULL)
-                {
-                    if (frame_base.IsValid())
-                        func_sp->GetFrameBaseExpression() = frame_base;
-                    sc.comp_unit->AddFunction(func_sp);
-                    return func_sp.get();
-                }
-            }
-        }
-    }
-    return NULL;
-}
-
-bool
-DWARFASTParserClang::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &parent_die,
-                                       CompilerType &class_clang_type, const LanguageType class_language,
-                                       std::vector<clang::CXXBaseSpecifier *> &base_classes,
-                                       std::vector<int> &member_accessibilities,
-                                       DWARFDIECollection &member_function_dies,
-                                       DelayedPropertyList &delayed_properties, AccessType &default_accessibility,
-                                       bool &is_a_class, ClangASTImporter::LayoutInfo &layout_info)
-{
-    if (!parent_die)
-        return 0;
-
-    // Get the parent byte size so we can verify any members will fit
-    const uint64_t parent_byte_size = parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX) * 8;
-    const uint64_t parent_bit_size = parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8;
-
-    uint32_t member_idx = 0;
-    BitfieldInfo last_field_info;
-
-    ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
-    ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(class_clang_type.GetTypeSystem());
-    if (ast == nullptr)
-        return 0;
-
-    for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
-    {
-        dw_tag_t tag = die.Tag();
-
-        switch (tag)
-        {
-            case DW_TAG_member:
-            case DW_TAG_APPLE_property:
-            {
-                DWARFAttributes attributes;
-                const size_t num_attributes = die.GetAttributes (attributes);
-                if (num_attributes > 0)
-                {
-                    Declaration decl;
-                    //DWARFExpression location;
-                    const char *name = NULL;
-                    const char *prop_name = NULL;
-                    const char *prop_getter_name = NULL;
-                    const char *prop_setter_name = NULL;
-                    uint32_t prop_attributes = 0;
-
-
-                    bool is_artificial = false;
-                    DWARFFormValue encoding_form;
-                    AccessType accessibility = eAccessNone;
-                    uint32_t member_byte_offset = (parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX;
-                    size_t byte_size = 0;
-                    int64_t bit_offset = 0;
-                    uint64_t data_bit_offset = UINT64_MAX;
-                    size_t bit_size = 0;
-                    bool is_external = false; // On DW_TAG_members, this means the member is static
-                    uint32_t i;
-                    for (i=0; i<num_attributes && !is_artificial; ++i)
-                    {
-                        const dw_attr_t attr = attributes.AttributeAtIndex(i);
-                        DWARFFormValue form_value;
-                        if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        {
-                            switch (attr)
-                            {
-                                case DW_AT_decl_file:   decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
-                                case DW_AT_decl_line:   decl.SetLine(form_value.Unsigned()); break;
-                                case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
-                                case DW_AT_name:        name = form_value.AsCString(); break;
-                                case DW_AT_type:        encoding_form = form_value; break;
-                                case DW_AT_bit_offset:  bit_offset = form_value.Signed(); break;
-                                case DW_AT_bit_size:    bit_size = form_value.Unsigned(); break;
-                                case DW_AT_byte_size:   byte_size = form_value.Unsigned(); break;
-                                case DW_AT_data_bit_offset: data_bit_offset = form_value.Unsigned(); break;
-                                case DW_AT_data_member_location:
-                                    if (form_value.BlockData())
-                                    {
-                                        Value initialValue(0);
-                                        Value memberOffset(0);
-                                        const DWARFDataExtractor& debug_info_data = die.GetDWARF()->get_debug_info_data();
-                                        uint32_t block_length = form_value.Unsigned();
-                                        uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
-                                        if (DWARFExpression::Evaluate(nullptr, // ExecutionContext *
-                                                                      nullptr, // ClangExpressionVariableList *
-                                                                      nullptr, // ClangExpressionDeclMap *
-                                                                      nullptr, // RegisterContext *
-                                                                      module_sp,
-                                                                      debug_info_data,
-                                                                      die.GetCU(),
-                                                                      block_offset,
-                                                                      block_length,
-                                                                      eRegisterKindDWARF,
-                                                                      &initialValue,
-                                                                      nullptr,
-                                                                      memberOffset,
-                                                                      nullptr))
-                                        {
-                                            member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
-                                        }
-                                    }
-                                    else
-                                    {
-                                        // With DWARF 3 and later, if the value is an integer constant,
-                                        // this form value is the offset in bytes from the beginning
-                                        // of the containing entity.
-                                        member_byte_offset = form_value.Unsigned();
-                                    }
-                                    break;
-
-                                case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType (form_value.Unsigned()); break;
-                                case DW_AT_artificial: is_artificial = form_value.Boolean(); break;
-                                case DW_AT_APPLE_property_name:      prop_name = form_value.AsCString();
-                                    break;
-                                case DW_AT_APPLE_property_getter:    prop_getter_name = form_value.AsCString();
-                                    break;
-                                case DW_AT_APPLE_property_setter:    prop_setter_name = form_value.AsCString();
-                                    break;
-                                case DW_AT_APPLE_property_attribute: prop_attributes = form_value.Unsigned(); break;
-                                case DW_AT_external:                 is_external = form_value.Boolean(); break;
-
-                                default:
-                                case DW_AT_declaration:
-                                case DW_AT_description:
-                                case DW_AT_mutable:
-                                case DW_AT_visibility:
-                                case DW_AT_sibling:
-                                    break;
-                            }
-                        }
-                    }
-
-                    if (prop_name)
-                    {
-                        ConstString fixed_getter;
-                        ConstString fixed_setter;
-
-                        // Check if the property getter/setter were provided as full
-                        // names.  We want basenames, so we extract them.
-
-                        if (prop_getter_name && prop_getter_name[0] == '-')
-                        {
-                            ObjCLanguage::MethodName prop_getter_method(prop_getter_name, true);
-                            prop_getter_name = prop_getter_method.GetSelector().GetCString();
-                        }
-
-                        if (prop_setter_name && prop_setter_name[0] == '-')
-                        {
-                            ObjCLanguage::MethodName prop_setter_method(prop_setter_name, true);
-                            prop_setter_name = prop_setter_method.GetSelector().GetCString();
-                        }
-
-                        // If the names haven't been provided, they need to be
-                        // filled in.
-
-                        if (!prop_getter_name)
-                        {
-                            prop_getter_name = prop_name;
-                        }
-                        if (!prop_setter_name && prop_name[0] && !(prop_attributes & DW_APPLE_PROPERTY_readonly))
-                        {
-                            StreamString ss;
-
-                            ss.Printf("set%c%s:",
-                                      toupper(prop_name[0]),
-                                      &prop_name[1]);
-
-                            fixed_setter.SetCString(ss.GetData());
-                            prop_setter_name = fixed_setter.GetCString();
-                        }
-                    }
-
-                    // Clang has a DWARF generation bug where sometimes it
-                    // represents fields that are references with bad byte size
-                    // and bit size/offset information such as:
-                    //
-                    //  DW_AT_byte_size( 0x00 )
-                    //  DW_AT_bit_size( 0x40 )
-                    //  DW_AT_bit_offset( 0xffffffffffffffc0 )
-                    //
-                    // So check the bit offset to make sure it is sane, and if
-                    // the values are not sane, remove them. If we don't do this
-                    // then we will end up with a crash if we try to use this
-                    // type in an expression when clang becomes unhappy with its
-                    // recycled debug info.
-
-                    if (byte_size == 0 && bit_offset < 0)
-                    {
-                        bit_size = 0;
-                        bit_offset = 0;
-                    }
-
-                    // FIXME: Make Clang ignore Objective-C accessibility for expressions
-                    if (class_language == eLanguageTypeObjC ||
-                        class_language == eLanguageTypeObjC_plus_plus)
-                        accessibility = eAccessNone;
-
-                    if (member_idx == 0 && !is_artificial && name && (strstr (name, "_vptr$") == name))
-                    {
-                        // Not all compilers will mark the vtable pointer
-                        // member as artificial (llvm-gcc). We can't have
-                        // the virtual members in our classes otherwise it
-                        // throws off all child offsets since we end up
-                        // having and extra pointer sized member in our
-                        // class layouts.
-                        is_artificial = true;
-                    }
-
-                    // Handle static members
-                    if (is_external && member_byte_offset == UINT32_MAX)
-                    {
-                        Type *var_type = die.ResolveTypeUID(DIERef(encoding_form));
-
-                        if (var_type)
-                        {
-                            if (accessibility == eAccessNone)
-                                accessibility = eAccessPublic;
-                            ClangASTContext::AddVariableToRecordType (class_clang_type,
-                                                                      name,
-                                                                      var_type->GetLayoutCompilerType (),
-                                                                      accessibility);
-                        }
-                        break;
-                    }
-
-                    if (is_artificial == false)
-                    {
-                        Type *member_type = die.ResolveTypeUID(DIERef(encoding_form));
-
-                        clang::FieldDecl *field_decl = NULL;
-                        if (tag == DW_TAG_member)
-                        {
-                            if (member_type)
-                            {
-                                if (accessibility == eAccessNone)
-                                    accessibility = default_accessibility;
-                                member_accessibilities.push_back(accessibility);
-
-                                uint64_t field_bit_offset = (member_byte_offset == UINT32_MAX ? 0 : (member_byte_offset * 8));
-                                if (bit_size > 0)
-                                {
-
-                                    BitfieldInfo this_field_info;
-                                    this_field_info.bit_offset = field_bit_offset;
-                                    this_field_info.bit_size = bit_size;
-
-                                    /////////////////////////////////////////////////////////////
-                                    // How to locate a field given the DWARF debug information
-                                    //
-                                    // AT_byte_size indicates the size of the word in which the
-                                    // bit offset must be interpreted.
-                                    //
-                                    // AT_data_member_location indicates the byte offset of the
-                                    // word from the base address of the structure.
-                                    //
-                                    // AT_bit_offset indicates how many bits into the word
-                                    // (according to the host endianness) the low-order bit of
-                                    // the field starts.  AT_bit_offset can be negative.
-                                    //
-                                    // AT_bit_size indicates the size of the field in bits.
-                                    /////////////////////////////////////////////////////////////
-
-                                    if (data_bit_offset != UINT64_MAX)
-                                    {
-                                        this_field_info.bit_offset = data_bit_offset;
-                                    }
-                                    else
-                                    {
-                                        if (byte_size == 0)
-                                            byte_size = member_type->GetByteSize();
-
-                                        ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
-                                        if (objfile->GetByteOrder() == eByteOrderLittle)
-                                        {
-                                            this_field_info.bit_offset += byte_size * 8;
-                                            this_field_info.bit_offset -= (bit_offset + bit_size);
-                                        }
-                                        else
-                                        {
-                                            this_field_info.bit_offset += bit_offset;
-                                        }
-                                    }
-
-                                    if ((this_field_info.bit_offset >= parent_bit_size) || !last_field_info.NextBitfieldOffsetIsValid(this_field_info.bit_offset))
-                                    {
-                                        ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
-                                        objfile->GetModule()->ReportWarning("0x%8.8" PRIx64 ": %s bitfield named \"%s\" has invalid bit offset (0x%8.8" PRIx64 ") member will be ignored. Please file a bug against the compiler and include the preprocessed output for %s\n",
-                                                                            die.GetID(),
-                                                                            DW_TAG_value_to_name(tag),
-                                                                            name,
-                                                                            this_field_info.bit_offset,
-                                                                            sc.comp_unit ? sc.comp_unit->GetPath().c_str() : "the source file");
-                                        this_field_info.Clear();
-                                        continue;
-                                    }
-
-                                    // Update the field bit offset we will report for layout
-                                    field_bit_offset = this_field_info.bit_offset;
-
-                                    // If the member to be emitted did not start on a character boundary and there is
-                                    // empty space between the last field and this one, then we need to emit an
-                                    // anonymous member filling up the space up to its start.  There are three cases
-                                    // here:
-                                    //
-                                    // 1 If the previous member ended on a character boundary, then we can emit an
-                                    //   anonymous member starting at the most recent character boundary.
-                                    //
-                                    // 2 If the previous member did not end on a character boundary and the distance
-                                    //   from the end of the previous member to the current member is less than a
-                                    //   word width, then we can emit an anonymous member starting right after the
-                                    //   previous member and right before this member.
-                                    //
-                                    // 3 If the previous member did not end on a character boundary and the distance
-                                    //   from the end of the previous member to the current member is greater than
-                                    //   or equal a word width, then we act as in Case 1.
-
-                                    const uint64_t character_width = 8;
-                                    const uint64_t word_width = 32;
-
-                                    // Objective-C has invalid DW_AT_bit_offset values in older versions
-                                    // of clang, so we have to be careful and only insert unnamed bitfields
-                                    // if we have a new enough clang.
-                                    bool detect_unnamed_bitfields = true;
-
-                                    if (class_language == eLanguageTypeObjC || class_language == eLanguageTypeObjC_plus_plus)
-                                        detect_unnamed_bitfields = die.GetCU()->Supports_unnamed_objc_bitfields ();
-
-                                    if (detect_unnamed_bitfields)
-                                    {
-                                        BitfieldInfo anon_field_info;
-
-                                        if ((this_field_info.bit_offset % character_width) != 0) // not char aligned
-                                        {
-                                            uint64_t last_field_end = 0;
-
-                                            if (last_field_info.IsValid())
-                                                last_field_end = last_field_info.bit_offset + last_field_info.bit_size;
-
-                                            if (this_field_info.bit_offset != last_field_end)
-                                            {
-                                                if (((last_field_end % character_width) == 0) ||                    // case 1
-                                                    (this_field_info.bit_offset - last_field_end >= word_width))    // case 3
-                                                {
-                                                    anon_field_info.bit_size = this_field_info.bit_offset % character_width;
-                                                    anon_field_info.bit_offset = this_field_info.bit_offset - anon_field_info.bit_size;
-                                                }
-                                                else                                                                // case 2
-                                                {
-                                                    anon_field_info.bit_size = this_field_info.bit_offset - last_field_end;
-                                                    anon_field_info.bit_offset = last_field_end;
-                                                }
-                                            }
-                                        }
-
-                                        if (anon_field_info.IsValid())
-                                        {
-                                            clang::FieldDecl *unnamed_bitfield_decl =
-                                            ClangASTContext::AddFieldToRecordType (class_clang_type,
-                                                                                   NULL,
-                                                                                   m_ast.GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, word_width),
-                                                                                   accessibility,
-                                                                                   anon_field_info.bit_size);
-
-                                            layout_info.field_offsets.insert(
-                                                                             std::make_pair(unnamed_bitfield_decl, anon_field_info.bit_offset));
-                                        }
-                                    }
-                                    last_field_info = this_field_info;
-                                }
-                                else
-                                {
-                                    last_field_info.Clear();
-                                }
-
-                                CompilerType member_clang_type = member_type->GetLayoutCompilerType ();
-                                if (!member_clang_type.IsCompleteType())
-                                    member_clang_type.GetCompleteType();
-
-                                {
-                                    // Older versions of clang emit array[0] and array[1] in the same way (<rdar://problem/12566646>).
-                                    // If the current field is at the end of the structure, then there is definitely no room for extra
-                                    // elements and we override the type to array[0].
-
-                                    CompilerType member_array_element_type;
-                                    uint64_t member_array_size;
-                                    bool member_array_is_incomplete;
-
-                                    if (member_clang_type.IsArrayType(&member_array_element_type,
-                                                                      &member_array_size,
-                                                                      &member_array_is_incomplete) &&
-                                        !member_array_is_incomplete)
-                                    {
-                                        uint64_t parent_byte_size = parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX);
-
-                                        if (member_byte_offset >= parent_byte_size)
-                                        {
-                                            if (member_array_size != 1 && (member_array_size != 0 || member_byte_offset > parent_byte_size))
-                                            {
-                                                module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which extends beyond the bounds of 0x%8.8" PRIx64,
-                                                                        die.GetID(),
-                                                                        name,
-                                                                        encoding_form.Reference(),
-                                                                        parent_die.GetID());
-                                            }
-
-                                            member_clang_type = m_ast.CreateArrayType(member_array_element_type, 0, false);
-                                        }
-                                    }
-                                }
-
-                                if (ClangASTContext::IsCXXClassType(member_clang_type) && member_clang_type.GetCompleteType() == false)
-                                {
-                                    if (die.GetCU()->GetProducer() == DWARFCompileUnit::eProducerClang)
-                                        module_sp->ReportError ("DWARF DIE at 0x%8.8x (class %s) has a member variable 0x%8.8x (%s) whose type is a forward declaration, not a complete definition.\nTry compiling the source file with -fno-limit-debug-info",
-                                                                parent_die.GetOffset(),
-                                                                parent_die.GetName(),
-                                                                die.GetOffset(),
-                                                                name);
-                                    else
-                                        module_sp->ReportError ("DWARF DIE at 0x%8.8x (class %s) has a member variable 0x%8.8x (%s) whose type is a forward declaration, not a complete definition.\nPlease file a bug against the compiler and include the preprocessed output for %s",
-                                                                parent_die.GetOffset(),
-                                                                parent_die.GetName(),
-                                                                die.GetOffset(),
-                                                                name,
-                                                                sc.comp_unit ? sc.comp_unit->GetPath().c_str() : "the source file");
-                                    // We have no choice other than to pretend that the member class
-                                    // is complete. If we don't do this, clang will crash when trying
-                                    // to layout the class. Since we provide layout assistance, all
-                                    // ivars in this class and other classes will be fine, this is
-                                    // the best we can do short of crashing.
-                                    if (ClangASTContext::StartTagDeclarationDefinition(member_clang_type))
-                                    {
-                                        ClangASTContext::CompleteTagDeclarationDefinition(member_clang_type);
-                                    }
-                                    else
-                                    {
-                                        module_sp->ReportError ("DWARF DIE at 0x%8.8x (class %s) has a member variable 0x%8.8x (%s) whose type claims to be a C++ class but we were not able to start its definition.\nPlease file a bug and attach the file at the start of this error message",
-                                                                parent_die.GetOffset(),
-                                                                parent_die.GetName(),
-                                                                die.GetOffset(),
-                                                                name);
-                                    }
-                                }
-
-                                field_decl = ClangASTContext::AddFieldToRecordType (class_clang_type,
-                                                                                    name,
-                                                                                    member_clang_type,
-                                                                                    accessibility,
-                                                                                    bit_size);
-
-                                m_ast.SetMetadataAsUserID (field_decl, die.GetID());
-
-                                layout_info.field_offsets.insert(std::make_pair(field_decl, field_bit_offset));
-                            }
-                            else
-                            {
-                                if (name)
-                                    module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64 " which was unable to be parsed",
-                                                            die.GetID(),
-                                                            name,
-                                                            encoding_form.Reference());
-                                else
-                                    module_sp->ReportError ("0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8" PRIx64 " which was unable to be parsed",
-                                                            die.GetID(),
-                                                            encoding_form.Reference());
-                            }
-                        }
-
-                        if (prop_name != NULL && member_type)
-                        {
-                            clang::ObjCIvarDecl *ivar_decl = NULL;
-
-                            if (field_decl)
-                            {
-                                ivar_decl = clang::dyn_cast<clang::ObjCIvarDecl>(field_decl);
-                                assert (ivar_decl != NULL);
-                            }
-
-                            ClangASTMetadata metadata;
-                            metadata.SetUserID (die.GetID());
-                            delayed_properties.push_back(DelayedAddObjCClassProperty(class_clang_type,
-                                                                                     prop_name,
-                                                                                     member_type->GetLayoutCompilerType (),
-                                                                                     ivar_decl,
-                                                                                     prop_setter_name,
-                                                                                     prop_getter_name,
-                                                                                     prop_attributes,
-                                                                                     &metadata));
-
-                            if (ivar_decl)
-                                m_ast.SetMetadataAsUserID (ivar_decl, die.GetID());
-                        }
-                    }
-                }
-                ++member_idx;
-            }
-                break;
-
-            case DW_TAG_subprogram:
-                // Let the type parsing code handle this one for us.
-                member_function_dies.Append (die);
-                break;
-
-            case DW_TAG_inheritance:
-            {
-                is_a_class = true;
-                if (default_accessibility == eAccessNone)
-                    default_accessibility = eAccessPrivate;
-                // TODO: implement DW_TAG_inheritance type parsing
-                DWARFAttributes attributes;
-                const size_t num_attributes = die.GetAttributes (attributes);
-                if (num_attributes > 0)
-                {
-                    Declaration decl;
-                    DWARFExpression location(die.GetCU());
-                    DWARFFormValue encoding_form;
-                    AccessType accessibility = default_accessibility;
-                    bool is_virtual = false;
-                    bool is_base_of_class = true;
-                    off_t member_byte_offset = 0;
-                    uint32_t i;
-                    for (i=0; i<num_attributes; ++i)
-                    {
-                        const dw_attr_t attr = attributes.AttributeAtIndex(i);
-                        DWARFFormValue form_value;
-                        if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        {
-                            switch (attr)
-                            {
-                                case DW_AT_decl_file:   decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
-                                case DW_AT_decl_line:   decl.SetLine(form_value.Unsigned()); break;
-                                case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
-                                case DW_AT_type:        encoding_form = form_value; break;
-                                case DW_AT_data_member_location:
-                                    if (form_value.BlockData())
-                                    {
-                                        Value initialValue(0);
-                                        Value memberOffset(0);
-                                        const DWARFDataExtractor& debug_info_data = die.GetDWARF()->get_debug_info_data();
-                                        uint32_t block_length = form_value.Unsigned();
-                                        uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
-                                        if (DWARFExpression::Evaluate (nullptr,
-                                                                       nullptr,
-                                                                       nullptr,
-                                                                       nullptr,
-                                                                       module_sp,
-                                                                       debug_info_data,
-                                                                       die.GetCU(),
-                                                                       block_offset,
-                                                                       block_length,
-                                                                       eRegisterKindDWARF,
-                                                                       &initialValue,
-                                                                       nullptr,
-                                                                       memberOffset,
-                                                                       nullptr))
-                                        {
-                                            member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
-                                        }
-                                    }
-                                    else
-                                    {
-                                        // With DWARF 3 and later, if the value is an integer constant,
-                                        // this form value is the offset in bytes from the beginning
-                                        // of the containing entity.
-                                        member_byte_offset = form_value.Unsigned();
-                                    }
-                                    break;
-
-                                case DW_AT_accessibility:
-                                    accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
-                                    break;
-
-                                case DW_AT_virtuality:
-                                    is_virtual = form_value.Boolean();
-                                    break;
-
-                                case DW_AT_sibling:
-                                    break;
-
-                                default:
-                                    break;
-                            }
-                        }
-                    }
-
-                    Type *base_class_type = die.ResolveTypeUID(DIERef(encoding_form));
-                    if (base_class_type == NULL)
-                    {
-                        module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to resolve the base class at 0x%8.8" PRIx64 " from enclosing type 0x%8.8x. \nPlease file a bug and attach the file at the start of this error message",
-                                               die.GetOffset(),
-                                               encoding_form.Reference(),
-                                               parent_die.GetOffset());
-                        break;
-                    }
-
-                    CompilerType base_class_clang_type = base_class_type->GetFullCompilerType ();
-                    assert (base_class_clang_type);
-                    if (class_language == eLanguageTypeObjC)
-                    {
-                        ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
-                    }
-                    else
-                    {
-                        base_classes.push_back (ast->CreateBaseClassSpecifier (base_class_clang_type.GetOpaqueQualType(),
-                                                                               accessibility,
-                                                                               is_virtual,
-                                                                               is_base_of_class));
-
-                        if (is_virtual)
-                        {
-                            // Do not specify any offset for virtual inheritance. The DWARF produced by clang doesn't
-                            // give us a constant offset, but gives us a DWARF expressions that requires an actual object
-                            // in memory. the DW_AT_data_member_location for a virtual base class looks like:
-                            //      DW_AT_data_member_location( DW_OP_dup, DW_OP_deref, DW_OP_constu(0x00000018), DW_OP_minus, DW_OP_deref, DW_OP_plus )
-                            // Given this, there is really no valid response we can give to clang for virtual base
-                            // class offsets, and this should eventually be removed from LayoutRecordType() in the external
-                            // AST source in clang.
-                        }
-                        else
-                        {
-                            layout_info.base_offsets.insert(
-                                                            std::make_pair(ast->GetAsCXXRecordDecl(base_class_clang_type.GetOpaqueQualType()),
-                                                                           clang::CharUnits::fromQuantity(member_byte_offset)));
-                        }
-                    }
-                }
-            }
-                break;
-
-            default:
-                break;
+        if (tag == DW_TAG_template_value_parameter && uval64_valid) {
+          llvm::APInt apint(clang_type.GetBitSize(nullptr), uval64, is_signed);
+          template_param_infos.args.push_back(
+              clang::TemplateArgument(*ast, llvm::APSInt(apint, !is_signed),
+                                      ClangUtil::GetQualType(clang_type)));
+        } else {
+          template_param_infos.args.push_back(
+              clang::TemplateArgument(ClangUtil::GetQualType(clang_type)));
         }
+      } else {
+        return false;
+      }
     }
-
+  }
     return true;
+
+  default:
+    break;
+  }
+  return false;
 }
 
+bool DWARFASTParserClang::ParseTemplateParameterInfos(
+    const DWARFDIE &parent_die,
+    ClangASTContext::TemplateParameterInfos &template_param_infos) {
 
-size_t
-DWARFASTParserClang::ParseChildParameters (const SymbolContext& sc,
-                                           clang::DeclContext *containing_decl_ctx,
-                                           const DWARFDIE &parent_die,
-                                           bool skip_artificial,
-                                           bool &is_static,
-                                           bool &is_variadic,
-                                           bool &has_template_params,
-                                           std::vector<CompilerType>& function_param_types,
-                                           std::vector<clang::ParmVarDecl*>& function_param_decls,
-                                           unsigned &type_quals)
-{
-    if (!parent_die)
-        return 0;
+  if (!parent_die)
+    return false;
 
-    size_t arg_idx = 0;
-    for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
-    {
-        const dw_tag_t tag = die.Tag();
-        switch (tag)
-        {
-            case DW_TAG_formal_parameter:
-            {
-                DWARFAttributes attributes;
-                const size_t num_attributes = die.GetAttributes(attributes);
-                if (num_attributes > 0)
-                {
-                    const char *name = NULL;
-                    Declaration decl;
-                    DWARFFormValue param_type_die_form;
-                    bool is_artificial = false;
-                    // one of None, Auto, Register, Extern, Static, PrivateExtern
-
-                    clang::StorageClass storage = clang::SC_None;
-                    uint32_t i;
-                    for (i=0; i<num_attributes; ++i)
-                    {
-                        const dw_attr_t attr = attributes.AttributeAtIndex(i);
-                        DWARFFormValue form_value;
-                        if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        {
-                            switch (attr)
-                            {
-                                case DW_AT_decl_file:   decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
-                                case DW_AT_decl_line:   decl.SetLine(form_value.Unsigned()); break;
-                                case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
-                                case DW_AT_name:        name = form_value.AsCString();
-                                    break;
-                                case DW_AT_type:        param_type_die_form = form_value; break;
-                                case DW_AT_artificial:  is_artificial = form_value.Boolean(); break;
-                                case DW_AT_location:
-                                    //                          if (form_value.BlockData())
-                                    //                          {
-                                    //                              const DWARFDataExtractor& debug_info_data = debug_info();
-                                    //                              uint32_t block_length = form_value.Unsigned();
-                                    //                              DWARFDataExtractor location(debug_info_data, form_value.BlockData() - debug_info_data.GetDataStart(), block_length);
-                                    //                          }
-                                    //                          else
-                                    //                          {
-                                    //                          }
-                                    //                          break;
-                                case DW_AT_const_value:
-                                case DW_AT_default_value:
-                                case DW_AT_description:
-                                case DW_AT_endianity:
-                                case DW_AT_is_optional:
-                                case DW_AT_segment:
-                                case DW_AT_variable_parameter:
-                                default:
-                                case DW_AT_abstract_origin:
-                                case DW_AT_sibling:
-                                    break;
-                            }
-                        }
-                    }
+  Args template_parameter_names;
+  for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
+       die = die.GetSibling()) {
+    const dw_tag_t tag = die.Tag();
 
-                    bool skip = false;
-                    if (skip_artificial)
-                    {
-                        if (is_artificial)
-                        {
-                            // In order to determine if a C++ member function is
-                            // "const" we have to look at the const-ness of "this"...
-                            // Ugly, but that
-                            if (arg_idx == 0)
-                            {
-                                if (DeclKindIsCXXClass(containing_decl_ctx->getDeclKind()))
-                                {
-                                    // Often times compilers omit the "this" name for the
-                                    // specification DIEs, so we can't rely upon the name
-                                    // being in the formal parameter DIE...
-                                    if (name == NULL || ::strcmp(name, "this")==0)
-                                    {
-                                        Type *this_type = die.ResolveTypeUID (DIERef(param_type_die_form));
-                                        if (this_type)
-                                        {
-                                            uint32_t encoding_mask = this_type->GetEncodingMask();
-                                            if (encoding_mask & Type::eEncodingIsPointerUID)
-                                            {
-                                                is_static = false;
-
-                                                if (encoding_mask & (1u << Type::eEncodingIsConstUID))
-                                                    type_quals |= clang::Qualifiers::Const;
-                                                if (encoding_mask & (1u << Type::eEncodingIsVolatileUID))
-                                                    type_quals |= clang::Qualifiers::Volatile;
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                            skip = true;
-                        }
-                        else
-                        {
+    switch (tag) {
+    case DW_TAG_template_type_parameter:
+    case DW_TAG_template_value_parameter:
+      ParseTemplateDIE(die, template_param_infos);
+      break;
 
-                            // HACK: Objective C formal parameters "self" and "_cmd"
-                            // are not marked as artificial in the DWARF...
-                            CompileUnit *comp_unit = die.GetLLDBCompileUnit();
-                            if (comp_unit)
-                            {
-                                switch (comp_unit->GetLanguage())
-                                {
-                                    case eLanguageTypeObjC:
-                                    case eLanguageTypeObjC_plus_plus:
-                                        if (name && name[0] && (strcmp (name, "self") == 0 || strcmp (name, "_cmd") == 0))
-                                            skip = true;
-                                        break;
-                                    default:
-                                        break;
-                                }
-                            }
-                        }
-                    }
+    default:
+      break;
+    }
+  }
+  if (template_param_infos.args.empty())
+    return false;
+  return template_param_infos.args.size() == template_param_infos.names.size();
+}
 
-                    if (!skip)
-                    {
-                        Type *type = die.ResolveTypeUID(DIERef(param_type_die_form));
-                        if (type)
-                        {
-                            function_param_types.push_back (type->GetForwardCompilerType ());
-
-                            clang::ParmVarDecl *param_var_decl = m_ast.CreateParameterDeclaration (name,
-                                                                                                   type->GetForwardCompilerType (),
-                                                                                                   storage);
-                            assert(param_var_decl);
-                            function_param_decls.push_back(param_var_decl);
+bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
+                                                lldb_private::Type *type,
+                                                CompilerType &clang_type) {
+  SymbolFileDWARF *dwarf = die.GetDWARF();
 
-                            m_ast.SetMetadataAsUserID (param_var_decl, die.GetID());
-                        }
-                    }
-                }
-                arg_idx++;
-            }
-                break;
+  std::lock_guard<std::recursive_mutex> guard(
+      dwarf->GetObjectFile()->GetModule()->GetMutex());
 
-            case DW_TAG_unspecified_parameters:
-                is_variadic = true;
-                break;
+  // Disable external storage for this type so we don't get anymore
+  // clang::ExternalASTSource queries for this type.
+  m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), false);
 
-            case DW_TAG_template_type_parameter:
-            case DW_TAG_template_value_parameter:
-                // The one caller of this was never using the template_param_infos,
-                // and the local variable was taking up a large amount of stack space
-                // in SymbolFileDWARF::ParseType() so this was removed. If we ever need
-                // the template params back, we can add them back.
-                // ParseTemplateDIE (dwarf_cu, die, template_param_infos);
-                has_template_params = true;
-                break;
+  if (!die)
+    return false;
 
-            default:
-                break;
+#if defined LLDB_CONFIGURATION_DEBUG
+  //----------------------------------------------------------------------
+  // For debugging purposes, the LLDB_DWARF_DONT_COMPLETE_TYPENAMES
+  // environment variable can be set with one or more typenames separated
+  // by ';' characters. This will cause this function to not complete any
+  // types whose names match.
+  //
+  // Examples of setting this environment variable:
+  //
+  // LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo
+  // LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo;Bar;Baz
+  //----------------------------------------------------------------------
+  const char *dont_complete_typenames_cstr =
+      getenv("LLDB_DWARF_DONT_COMPLETE_TYPENAMES");
+  if (dont_complete_typenames_cstr && dont_complete_typenames_cstr[0]) {
+    const char *die_name = die.GetName();
+    if (die_name && die_name[0]) {
+      const char *match = strstr(dont_complete_typenames_cstr, die_name);
+      if (match) {
+        size_t die_name_length = strlen(die_name);
+        while (match) {
+          const char separator_char = ';';
+          const char next_char = match[die_name_length];
+          if (next_char == '\0' || next_char == separator_char) {
+            if (match == dont_complete_typenames_cstr ||
+                match[-1] == separator_char)
+              return false;
+          }
+          match = strstr(match + 1, die_name);
         }
+      }
     }
-    return arg_idx;
+  }
+#endif
+
+  const dw_tag_t tag = die.Tag();
+
+  Log *log =
+      nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
+  if (log)
+    dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace(
+        log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...",
+        die.GetID(), die.GetTagAsCString(), type->GetName().AsCString());
+  assert(clang_type);
+  DWARFAttributes attributes;
+  switch (tag) {
+  case DW_TAG_structure_type:
+  case DW_TAG_union_type:
+  case DW_TAG_class_type: {
+    ClangASTImporter::LayoutInfo layout_info;
+
+    {
+      if (die.HasChildren()) {
+        LanguageType class_language = eLanguageTypeUnknown;
+        if (ClangASTContext::IsObjCObjectOrInterfaceType(clang_type)) {
+          class_language = eLanguageTypeObjC;
+          // For objective C we don't start the definition when
+          // the class is created.
+          ClangASTContext::StartTagDeclarationDefinition(clang_type);
+        }
+
+        int tag_decl_kind = -1;
+        AccessType default_accessibility = eAccessNone;
+        if (tag == DW_TAG_structure_type) {
+          tag_decl_kind = clang::TTK_Struct;
+          default_accessibility = eAccessPublic;
+        } else if (tag == DW_TAG_union_type) {
+          tag_decl_kind = clang::TTK_Union;
+          default_accessibility = eAccessPublic;
+        } else if (tag == DW_TAG_class_type) {
+          tag_decl_kind = clang::TTK_Class;
+          default_accessibility = eAccessPrivate;
+        }
+
+        SymbolContext sc(die.GetLLDBCompileUnit());
+        std::vector<clang::CXXBaseSpecifier *> base_classes;
+        std::vector<int> member_accessibilities;
+        bool is_a_class = false;
+        // Parse members and base classes first
+        DWARFDIECollection member_function_dies;
+
+        DelayedPropertyList delayed_properties;
+        ParseChildMembers(sc, die, clang_type, class_language, base_classes,
+                          member_accessibilities, member_function_dies,
+                          delayed_properties, default_accessibility, is_a_class,
+                          layout_info);
+
+        // Now parse any methods if there were any...
+        size_t num_functions = member_function_dies.Size();
+        if (num_functions > 0) {
+          for (size_t i = 0; i < num_functions; ++i) {
+            dwarf->ResolveType(member_function_dies.GetDIEAtIndex(i));
+          }
+        }
+
+        if (class_language == eLanguageTypeObjC) {
+          ConstString class_name(clang_type.GetTypeName());
+          if (class_name) {
+            DIEArray method_die_offsets;
+            dwarf->GetObjCMethodDIEOffsets(class_name, method_die_offsets);
+
+            if (!method_die_offsets.empty()) {
+              DWARFDebugInfo *debug_info = dwarf->DebugInfo();
+
+              const size_t num_matches = method_die_offsets.size();
+              for (size_t i = 0; i < num_matches; ++i) {
+                const DIERef &die_ref = method_die_offsets[i];
+                DWARFDIE method_die = debug_info->GetDIE(die_ref);
+
+                if (method_die)
+                  method_die.ResolveType();
+              }
+            }
+
+            for (DelayedPropertyList::iterator pi = delayed_properties.begin(),
+                                               pe = delayed_properties.end();
+                 pi != pe; ++pi)
+              pi->Finalize();
+          }
+        }
+
+        // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we
+        // need to tell the clang type it is actually a class.
+        if (class_language != eLanguageTypeObjC) {
+          if (is_a_class && tag_decl_kind != clang::TTK_Class)
+            m_ast.SetTagTypeKind(ClangUtil::GetQualType(clang_type),
+                                 clang::TTK_Class);
+        }
+
+        // Since DW_TAG_structure_type gets used for both classes
+        // and structures, we may need to set any DW_TAG_member
+        // fields to have a "private" access if none was specified.
+        // When we parsed the child members we tracked that actual
+        // accessibility value for each DW_TAG_member in the
+        // "member_accessibilities" array. If the value for the
+        // member is zero, then it was set to the "default_accessibility"
+        // which for structs was "public". Below we correct this
+        // by setting any fields to "private" that weren't correctly
+        // set.
+        if (is_a_class && !member_accessibilities.empty()) {
+          // This is a class and all members that didn't have
+          // their access specified are private.
+          m_ast.SetDefaultAccessForRecordFields(
+              m_ast.GetAsRecordDecl(clang_type), eAccessPrivate,
+              &member_accessibilities.front(), member_accessibilities.size());
+        }
+
+        if (!base_classes.empty()) {
+          // Make sure all base classes refer to complete types and not
+          // forward declarations. If we don't do this, clang will crash
+          // with an assertion in the call to
+          // clang_type.SetBaseClassesForClassType()
+          for (auto &base_class : base_classes) {
+            clang::TypeSourceInfo *type_source_info =
+                base_class->getTypeSourceInfo();
+            if (type_source_info) {
+              CompilerType base_class_type(
+                  &m_ast, type_source_info->getType().getAsOpaquePtr());
+              if (base_class_type.GetCompleteType() == false) {
+                auto module = dwarf->GetObjectFile()->GetModule();
+                module->ReportError(":: Class '%s' has a base class '%s' which "
+                                    "does not have a complete definition.",
+                                    die.GetName(),
+                                    base_class_type.GetTypeName().GetCString());
+                if (die.GetCU()->GetProducer() ==
+                    DWARFCompileUnit::eProducerClang)
+                  module->ReportError(":: Try compiling the source file with "
+                                      "-fno-limit-debug-info.");
+
+                // We have no choice other than to pretend that the base class
+                // is complete. If we don't do this, clang will crash when we
+                // call setBases() inside of
+                // "clang_type.SetBaseClassesForClassType()"
+                // below. Since we provide layout assistance, all ivars in this
+                // class and other classes will be fine, this is the best we can
+                // do
+                // short of crashing.
+                if (ClangASTContext::StartTagDeclarationDefinition(
+                        base_class_type)) {
+                  ClangASTContext::CompleteTagDeclarationDefinition(
+                      base_class_type);
+                }
+              }
+            }
+          }
+          m_ast.SetBaseClassesForClassType(clang_type.GetOpaqueQualType(),
+                                           &base_classes.front(),
+                                           base_classes.size());
+
+          // Clang will copy each CXXBaseSpecifier in "base_classes"
+          // so we have to free them all.
+          ClangASTContext::DeleteBaseClassSpecifiers(&base_classes.front(),
+                                                     base_classes.size());
+        }
+      }
+    }
+
+    ClangASTContext::BuildIndirectFields(clang_type);
+    ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+
+    if (!layout_info.field_offsets.empty() ||
+        !layout_info.base_offsets.empty() ||
+        !layout_info.vbase_offsets.empty()) {
+      if (type)
+        layout_info.bit_size = type->GetByteSize() * 8;
+      if (layout_info.bit_size == 0)
+        layout_info.bit_size =
+            die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
+
+      clang::CXXRecordDecl *record_decl =
+          m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
+      if (record_decl) {
+        if (log) {
+          ModuleSP module_sp = dwarf->GetObjectFile()->GetModule();
+
+          if (module_sp) {
+            module_sp->LogMessage(
+                log,
+                "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) "
+                "caching layout info for record_decl = %p, bit_size = %" PRIu64
+                ", alignment = %" PRIu64
+                ", field_offsets[%u], base_offsets[%u], vbase_offsets[%u])",
+                static_cast<void *>(clang_type.GetOpaqueQualType()),
+                static_cast<void *>(record_decl), layout_info.bit_size,
+                layout_info.alignment,
+                static_cast<uint32_t>(layout_info.field_offsets.size()),
+                static_cast<uint32_t>(layout_info.base_offsets.size()),
+                static_cast<uint32_t>(layout_info.vbase_offsets.size()));
+
+            uint32_t idx;
+            {
+              llvm::DenseMap<const clang::FieldDecl *, uint64_t>::const_iterator
+                  pos,
+                  end = layout_info.field_offsets.end();
+              for (idx = 0, pos = layout_info.field_offsets.begin(); pos != end;
+                   ++pos, ++idx) {
+                module_sp->LogMessage(
+                    log, "ClangASTContext::CompleteTypeFromDWARF (clang_type = "
+                         "%p) field[%u] = { bit_offset=%u, name='%s' }",
+                    static_cast<void *>(clang_type.GetOpaqueQualType()), idx,
+                    static_cast<uint32_t>(pos->second),
+                    pos->first->getNameAsString().c_str());
+              }
+            }
+
+            {
+              llvm::DenseMap<const clang::CXXRecordDecl *,
+                             clang::CharUnits>::const_iterator base_pos,
+                  base_end = layout_info.base_offsets.end();
+              for (idx = 0, base_pos = layout_info.base_offsets.begin();
+                   base_pos != base_end; ++base_pos, ++idx) {
+                module_sp->LogMessage(
+                    log, "ClangASTContext::CompleteTypeFromDWARF (clang_type = "
+                         "%p) base[%u] = { byte_offset=%u, name='%s' }",
+                    clang_type.GetOpaqueQualType(), idx,
+                    (uint32_t)base_pos->second.getQuantity(),
+                    base_pos->first->getNameAsString().c_str());
+              }
+            }
+            {
+              llvm::DenseMap<const clang::CXXRecordDecl *,
+                             clang::CharUnits>::const_iterator vbase_pos,
+                  vbase_end = layout_info.vbase_offsets.end();
+              for (idx = 0, vbase_pos = layout_info.vbase_offsets.begin();
+                   vbase_pos != vbase_end; ++vbase_pos, ++idx) {
+                module_sp->LogMessage(
+                    log, "ClangASTContext::CompleteTypeFromDWARF (clang_type = "
+                         "%p) vbase[%u] = { byte_offset=%u, name='%s' }",
+                    static_cast<void *>(clang_type.GetOpaqueQualType()), idx,
+                    static_cast<uint32_t>(vbase_pos->second.getQuantity()),
+                    vbase_pos->first->getNameAsString().c_str());
+              }
+            }
+          }
+        }
+        GetClangASTImporter().InsertRecordDecl(record_decl, layout_info);
+      }
+    }
+  }
+
+    return (bool)clang_type;
+
+  case DW_TAG_enumeration_type:
+    if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
+      if (die.HasChildren()) {
+        SymbolContext sc(die.GetLLDBCompileUnit());
+        bool is_signed = false;
+        clang_type.IsIntegerType(is_signed);
+        ParseChildEnumerators(sc, clang_type, is_signed, type->GetByteSize(),
+                              die);
+      }
+      ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+    }
+    return (bool)clang_type;
+
+  default:
+    assert(false && "not a forward clang type decl!");
+    break;
+  }
+
+  return false;
+}
+
+std::vector<DWARFDIE> DWARFASTParserClang::GetDIEForDeclContext(
+    lldb_private::CompilerDeclContext decl_context) {
+  std::vector<DWARFDIE> result;
+  for (auto it = m_decl_ctx_to_die.find(
+           (clang::DeclContext *)decl_context.GetOpaqueDeclContext());
+       it != m_decl_ctx_to_die.end(); it++)
+    result.push_back(it->second);
+  return result;
+}
+
+CompilerDecl DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) {
+  clang::Decl *clang_decl = GetClangDeclForDIE(die);
+  if (clang_decl != nullptr)
+    return CompilerDecl(&m_ast, clang_decl);
+  return CompilerDecl();
 }
 
-void
-DWARFASTParserClang::ParseChildArrayInfo (const SymbolContext& sc,
-                                          const DWARFDIE &parent_die,
-                                          int64_t& first_index,
-                                          std::vector<uint64_t>& element_orders,
-                                          uint32_t& byte_stride,
-                                          uint32_t& bit_stride)
-{
-    if (!parent_die)
-        return;
+CompilerDeclContext
+DWARFASTParserClang::GetDeclContextForUIDFromDWARF(const DWARFDIE &die) {
+  clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE(die);
+  if (clang_decl_ctx)
+    return CompilerDeclContext(&m_ast, clang_decl_ctx);
+  return CompilerDeclContext();
+}
 
-    for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
-    {
-        const dw_tag_t tag = die.Tag();
-        switch (tag)
-        {
-            case DW_TAG_subrange_type:
-            {
-                DWARFAttributes attributes;
-                const size_t num_child_attributes = die.GetAttributes(attributes);
-                if (num_child_attributes > 0)
-                {
-                    uint64_t num_elements = 0;
-                    uint64_t lower_bound = 0;
-                    uint64_t upper_bound = 0;
-                    bool upper_bound_valid = false;
-                    uint32_t i;
-                    for (i=0; i<num_child_attributes; ++i)
-                    {
-                        const dw_attr_t attr = attributes.AttributeAtIndex(i);
-                        DWARFFormValue form_value;
-                        if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        {
-                            switch (attr)
-                            {
-                                case DW_AT_name:
-                                    break;
-
-                                case DW_AT_count:
-                                    num_elements = form_value.Unsigned();
-                                    break;
-
-                                case DW_AT_bit_stride:
-                                    bit_stride = form_value.Unsigned();
-                                    break;
-
-                                case DW_AT_byte_stride:
-                                    byte_stride = form_value.Unsigned();
-                                    break;
-
-                                case DW_AT_lower_bound:
-                                    lower_bound = form_value.Unsigned();
-                                    break;
-
-                                case DW_AT_upper_bound:
-                                    upper_bound_valid = true;
-                                    upper_bound = form_value.Unsigned();
-                                    break;
-
-                                default:
-                                case DW_AT_abstract_origin:
-                                case DW_AT_accessibility:
-                                case DW_AT_allocated:
-                                case DW_AT_associated:
-                                case DW_AT_data_location:
-                                case DW_AT_declaration:
-                                case DW_AT_description:
-                                case DW_AT_sibling:
-                                case DW_AT_threads_scaled:
-                                case DW_AT_type:
-                                case DW_AT_visibility:
-                                    break;
-                            }
-                        }
-                    }
+CompilerDeclContext
+DWARFASTParserClang::GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) {
+  clang::DeclContext *clang_decl_ctx =
+      GetClangDeclContextContainingDIE(die, nullptr);
+  if (clang_decl_ctx)
+    return CompilerDeclContext(&m_ast, clang_decl_ctx);
+  return CompilerDeclContext();
+}
+
+size_t DWARFASTParserClang::ParseChildEnumerators(
+    const SymbolContext &sc, lldb_private::CompilerType &clang_type,
+    bool is_signed, uint32_t enumerator_byte_size, const DWARFDIE &parent_die) {
+  if (!parent_die)
+    return 0;
 
-                    if (num_elements == 0)
-                    {
-                        if (upper_bound_valid && upper_bound >= lower_bound)
-                            num_elements = upper_bound - lower_bound + 1;
-                    }
+  size_t enumerators_added = 0;
 
-                    element_orders.push_back (num_elements);
-                }
-            }
-                break;
+  for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
+       die = die.GetSibling()) {
+    const dw_tag_t tag = die.Tag();
+    if (tag == DW_TAG_enumerator) {
+      DWARFAttributes attributes;
+      const size_t num_child_attributes = die.GetAttributes(attributes);
+      if (num_child_attributes > 0) {
+        const char *name = NULL;
+        bool got_value = false;
+        int64_t enum_value = 0;
+        Declaration decl;
+
+        uint32_t i;
+        for (i = 0; i < num_child_attributes; ++i) {
+          const dw_attr_t attr = attributes.AttributeAtIndex(i);
+          DWARFFormValue form_value;
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            switch (attr) {
+            case DW_AT_const_value:
+              got_value = true;
+              if (is_signed)
+                enum_value = form_value.Signed();
+              else
+                enum_value = form_value.Unsigned();
+              break;
+
+            case DW_AT_name:
+              name = form_value.AsCString();
+              break;
+
+            case DW_AT_description:
+            default:
+            case DW_AT_decl_file:
+              decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+                  form_value.Unsigned()));
+              break;
+            case DW_AT_decl_line:
+              decl.SetLine(form_value.Unsigned());
+              break;
+            case DW_AT_decl_column:
+              decl.SetColumn(form_value.Unsigned());
+              break;
+            case DW_AT_sibling:
+              break;
+            }
+          }
+        }
+
+        if (name && name[0] && got_value) {
+          m_ast.AddEnumerationValueToEnumerationType(
+              clang_type.GetOpaqueQualType(),
+              m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType()),
+              decl, name, enum_value, enumerator_byte_size * 8);
+          ++enumerators_added;
         }
+      }
     }
+  }
+  return enumerators_added;
 }
 
-Type *
-DWARFASTParserClang::GetTypeForDIE (const DWARFDIE &die)
-{
-    if (die)
-    {
-        SymbolFileDWARF *dwarf = die.GetDWARF();
-        DWARFAttributes attributes;
-        const size_t num_attributes = die.GetAttributes(attributes);
-        if (num_attributes > 0)
-        {
-            DWARFFormValue type_die_form;
-            for (size_t i = 0; i < num_attributes; ++i)
-            {
-                dw_attr_t attr = attributes.AttributeAtIndex(i);
-                DWARFFormValue form_value;
+#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
 
-                if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
-                    return dwarf->ResolveTypeUID(dwarf->GetDIE (DIERef(form_value)), true);
-            }
-        }
-    }
+class DIEStack {
+public:
+  void Push(const DWARFDIE &die) { m_dies.push_back(die); }
 
-    return nullptr;
-}
+  void LogDIEs(Log *log) {
+    StreamString log_strm;
+    const size_t n = m_dies.size();
+    log_strm.Printf("DIEStack[%" PRIu64 "]:\n", (uint64_t)n);
+    for (size_t i = 0; i < n; i++) {
+      std::string qualified_name;
+      const DWARFDIE &die = m_dies[i];
+      die.GetQualifiedName(qualified_name);
+      log_strm.Printf("[%" PRIu64 "] 0x%8.8x: %s name='%s'\n", (uint64_t)i,
+                      die.GetOffset(), die.GetTagAsCString(),
+                      qualified_name.c_str());
+    }
+    log->PutCString(log_strm.GetData());
+  }
+  void Pop() { m_dies.pop_back(); }
+
+  class ScopedPopper {
+  public:
+    ScopedPopper(DIEStack &die_stack)
+        : m_die_stack(die_stack), m_valid(false) {}
+
+    void Push(const DWARFDIE &die) {
+      m_valid = true;
+      m_die_stack.Push(die);
+    }
+
+    ~ScopedPopper() {
+      if (m_valid)
+        m_die_stack.Pop();
+    }
+
+  protected:
+    DIEStack &m_die_stack;
+    bool m_valid;
+  };
 
-clang::Decl *
-DWARFASTParserClang::GetClangDeclForDIE (const DWARFDIE &die)
-{
-    if (!die)
-        return nullptr;
+protected:
+  typedef std::vector<DWARFDIE> Stack;
+  Stack m_dies;
+};
+#endif
 
-    switch (die.Tag())
-    {
-        case DW_TAG_variable:
-        case DW_TAG_constant:
-        case DW_TAG_formal_parameter:
-        case DW_TAG_imported_declaration:
-        case DW_TAG_imported_module:
-            break;
-        default:
-            return nullptr;
-    }
+Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc,
+                                                      const DWARFDIE &die) {
+  DWARFRangeList func_ranges;
+  const char *name = NULL;
+  const char *mangled = NULL;
+  int decl_file = 0;
+  int decl_line = 0;
+  int decl_column = 0;
+  int call_file = 0;
+  int call_line = 0;
+  int call_column = 0;
+  DWARFExpression frame_base(die.GetCU());
 
-    DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
-    if (cache_pos != m_die_to_decl.end())
-        return cache_pos->second;
+  const dw_tag_t tag = die.Tag();
 
-    if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
-    {
-        clang::Decl *decl = GetClangDeclForDIE(spec_die);
-        m_die_to_decl[die.GetDIE()] = decl;
-        m_decl_to_die[decl].insert(die.GetDIE());
-        return decl;
-    }
-    
-    if (DWARFDIE abstract_origin_die = die.GetReferencedDIE(DW_AT_abstract_origin))
-    {
-        clang::Decl *decl = GetClangDeclForDIE(abstract_origin_die);
-        m_die_to_decl[die.GetDIE()] = decl;
-        m_decl_to_die[decl].insert(die.GetDIE());
-        return decl;
-    }
+  if (tag != DW_TAG_subprogram)
+    return NULL;
 
-    clang::Decl *decl = nullptr;
-    switch (die.Tag())
-    {
-        case DW_TAG_variable:
-        case DW_TAG_constant:
-        case DW_TAG_formal_parameter:
-        {
-            SymbolFileDWARF *dwarf = die.GetDWARF();
-            Type *type = GetTypeForDIE(die);
-            if (dwarf && type)
-            {
-                const char *name = die.GetName();
-                clang::DeclContext *decl_context =
-                    ClangASTContext::DeclContextGetAsDeclContext(dwarf->GetDeclContextContainingUID(die.GetID()));
-                decl = m_ast.CreateVariableDeclaration(decl_context, name,
-                                                       ClangUtil::GetQualType(type->GetForwardCompilerType()));
-            }
-            break;
-        }
-        case DW_TAG_imported_declaration:
-        {
-            SymbolFileDWARF *dwarf = die.GetDWARF();
-            DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
-            if (imported_uid)
-            {
-                CompilerDecl imported_decl = imported_uid.GetDecl();
-                if (imported_decl)
-                {
-                    clang::DeclContext *decl_context = ClangASTContext::DeclContextGetAsDeclContext(dwarf->GetDeclContextContainingUID(die.GetID()));
-                    if (clang::NamedDecl *clang_imported_decl = llvm::dyn_cast<clang::NamedDecl>((clang::Decl *)imported_decl.GetOpaqueDecl()))
-                        decl = m_ast.CreateUsingDeclaration(decl_context, clang_imported_decl);
-                }
-            }
-            break;
-        }
-        case DW_TAG_imported_module:
-        {
-            SymbolFileDWARF *dwarf = die.GetDWARF();
-            DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
+  if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line,
+                               decl_column, call_file, call_line, call_column,
+                               &frame_base)) {
+
+    // Union of all ranges in the function DIE (if the function is
+    // discontiguous)
+    AddressRange func_range;
+    lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
+    lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
+    if (lowest_func_addr != LLDB_INVALID_ADDRESS &&
+        lowest_func_addr <= highest_func_addr) {
+      ModuleSP module_sp(die.GetModule());
+      func_range.GetBaseAddress().ResolveAddressUsingFileSections(
+          lowest_func_addr, module_sp->GetSectionList());
+      if (func_range.GetBaseAddress().IsValid())
+        func_range.SetByteSize(highest_func_addr - lowest_func_addr);
+    }
+
+    if (func_range.GetBaseAddress().IsValid()) {
+      Mangled func_name;
+      if (mangled)
+        func_name.SetValue(ConstString(mangled), true);
+      else if (die.GetParent().Tag() == DW_TAG_compile_unit &&
+               Language::LanguageIsCPlusPlus(die.GetLanguage()) && name &&
+               strcmp(name, "main") != 0) {
+        // If the mangled name is not present in the DWARF, generate the
+        // demangled name
+        // using the decl context. We skip if the function is "main" as its name
+        // is
+        // never mangled.
+        bool is_static = false;
+        bool is_variadic = false;
+        bool has_template_params = false;
+        unsigned type_quals = 0;
+        std::vector<CompilerType> param_types;
+        std::vector<clang::ParmVarDecl *> param_decls;
+        DWARFDeclContext decl_ctx;
+        StreamString sstr;
+
+        die.GetDWARFDeclContext(decl_ctx);
+        sstr << decl_ctx.GetQualifiedName();
+
+        clang::DeclContext *containing_decl_ctx =
+            GetClangDeclContextContainingDIE(die, nullptr);
+        ParseChildParameters(sc, containing_decl_ctx, die, true, is_static,
+                             is_variadic, has_template_params, param_types,
+                             param_decls, type_quals);
+        sstr << "(";
+        for (size_t i = 0; i < param_types.size(); i++) {
+          if (i > 0)
+            sstr << ", ";
+          sstr << param_types[i].GetTypeName();
+        }
+        if (is_variadic)
+          sstr << ", ...";
+        sstr << ")";
+        if (type_quals & clang::Qualifiers::Const)
+          sstr << " const";
+
+        func_name.SetValue(ConstString(sstr.GetData()), false);
+      } else
+        func_name.SetValue(ConstString(name), false);
+
+      FunctionSP func_sp;
+      std::unique_ptr<Declaration> decl_ap;
+      if (decl_file != 0 || decl_line != 0 || decl_column != 0)
+        decl_ap.reset(new Declaration(
+            sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file),
+            decl_line, decl_column));
+
+      SymbolFileDWARF *dwarf = die.GetDWARF();
+      // Supply the type _only_ if it has already been parsed
+      Type *func_type = dwarf->GetDIEToType().lookup(die.GetDIE());
+
+      assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
+
+      if (dwarf->FixupAddress(func_range.GetBaseAddress())) {
+        const user_id_t func_user_id = die.GetID();
+        func_sp.reset(new Function(sc.comp_unit,
+                                   func_user_id, // UserID is the DIE offset
+                                   func_user_id, func_name, func_type,
+                                   func_range)); // first address range
+
+        if (func_sp.get() != NULL) {
+          if (frame_base.IsValid())
+            func_sp->GetFrameBaseExpression() = frame_base;
+          sc.comp_unit->AddFunction(func_sp);
+          return func_sp.get();
+        }
+      }
+    }
+  }
+  return NULL;
+}
+
+bool DWARFASTParserClang::ParseChildMembers(
+    const SymbolContext &sc, const DWARFDIE &parent_die,
+    CompilerType &class_clang_type, const LanguageType class_language,
+    std::vector<clang::CXXBaseSpecifier *> &base_classes,
+    std::vector<int> &member_accessibilities,
+    DWARFDIECollection &member_function_dies,
+    DelayedPropertyList &delayed_properties, AccessType &default_accessibility,
+    bool &is_a_class, ClangASTImporter::LayoutInfo &layout_info) {
+  if (!parent_die)
+    return 0;
+
+  // Get the parent byte size so we can verify any members will fit
+  const uint64_t parent_byte_size =
+      parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX) * 8;
+  const uint64_t parent_bit_size =
+      parent_byte_size == UINT64_MAX ? UINT64_MAX : parent_byte_size * 8;
+
+  uint32_t member_idx = 0;
+  BitfieldInfo last_field_info;
+
+  ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
+  ClangASTContext *ast =
+      llvm::dyn_cast_or_null<ClangASTContext>(class_clang_type.GetTypeSystem());
+  if (ast == nullptr)
+    return 0;
+
+  for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
+       die = die.GetSibling()) {
+    dw_tag_t tag = die.Tag();
+
+    switch (tag) {
+    case DW_TAG_member:
+    case DW_TAG_APPLE_property: {
+      DWARFAttributes attributes;
+      const size_t num_attributes = die.GetAttributes(attributes);
+      if (num_attributes > 0) {
+        Declaration decl;
+        // DWARFExpression location;
+        const char *name = NULL;
+        const char *prop_name = NULL;
+        const char *prop_getter_name = NULL;
+        const char *prop_setter_name = NULL;
+        uint32_t prop_attributes = 0;
+
+        bool is_artificial = false;
+        DWARFFormValue encoding_form;
+        AccessType accessibility = eAccessNone;
+        uint32_t member_byte_offset =
+            (parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX;
+        size_t byte_size = 0;
+        int64_t bit_offset = 0;
+        uint64_t data_bit_offset = UINT64_MAX;
+        size_t bit_size = 0;
+        bool is_external =
+            false; // On DW_TAG_members, this means the member is static
+        uint32_t i;
+        for (i = 0; i < num_attributes && !is_artificial; ++i) {
+          const dw_attr_t attr = attributes.AttributeAtIndex(i);
+          DWARFFormValue form_value;
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            switch (attr) {
+            case DW_AT_decl_file:
+              decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+                  form_value.Unsigned()));
+              break;
+            case DW_AT_decl_line:
+              decl.SetLine(form_value.Unsigned());
+              break;
+            case DW_AT_decl_column:
+              decl.SetColumn(form_value.Unsigned());
+              break;
+            case DW_AT_name:
+              name = form_value.AsCString();
+              break;
+            case DW_AT_type:
+              encoding_form = form_value;
+              break;
+            case DW_AT_bit_offset:
+              bit_offset = form_value.Signed();
+              break;
+            case DW_AT_bit_size:
+              bit_size = form_value.Unsigned();
+              break;
+            case DW_AT_byte_size:
+              byte_size = form_value.Unsigned();
+              break;
+            case DW_AT_data_bit_offset:
+              data_bit_offset = form_value.Unsigned();
+              break;
+            case DW_AT_data_member_location:
+              if (form_value.BlockData()) {
+                Value initialValue(0);
+                Value memberOffset(0);
+                const DWARFDataExtractor &debug_info_data =
+                    die.GetDWARF()->get_debug_info_data();
+                uint32_t block_length = form_value.Unsigned();
+                uint32_t block_offset =
+                    form_value.BlockData() - debug_info_data.GetDataStart();
+                if (DWARFExpression::Evaluate(
+                        nullptr, // ExecutionContext *
+                        nullptr, // ClangExpressionVariableList *
+                        nullptr, // ClangExpressionDeclMap *
+                        nullptr, // RegisterContext *
+                        module_sp, debug_info_data, die.GetCU(), block_offset,
+                        block_length, eRegisterKindDWARF, &initialValue,
+                        nullptr, memberOffset, nullptr)) {
+                  member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
+                }
+              } else {
+                // With DWARF 3 and later, if the value is an integer constant,
+                // this form value is the offset in bytes from the beginning
+                // of the containing entity.
+                member_byte_offset = form_value.Unsigned();
+              }
+              break;
+
+            case DW_AT_accessibility:
+              accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
+              break;
+            case DW_AT_artificial:
+              is_artificial = form_value.Boolean();
+              break;
+            case DW_AT_APPLE_property_name:
+              prop_name = form_value.AsCString();
+              break;
+            case DW_AT_APPLE_property_getter:
+              prop_getter_name = form_value.AsCString();
+              break;
+            case DW_AT_APPLE_property_setter:
+              prop_setter_name = form_value.AsCString();
+              break;
+            case DW_AT_APPLE_property_attribute:
+              prop_attributes = form_value.Unsigned();
+              break;
+            case DW_AT_external:
+              is_external = form_value.Boolean();
+              break;
 
-            if (imported_uid)
-            {
-                CompilerDeclContext imported_decl_ctx = imported_uid.GetDeclContext();
-                if (imported_decl_ctx)
-                {
-                    clang::DeclContext *decl_context = ClangASTContext::DeclContextGetAsDeclContext(dwarf->GetDeclContextContainingUID(die.GetID()));
-                    if (clang::NamespaceDecl *ns_decl = ClangASTContext::DeclContextGetAsNamespaceDecl(imported_decl_ctx))
-                        decl = m_ast.CreateUsingDirectiveDeclaration(decl_context, ns_decl);
-                }
+            default:
+            case DW_AT_declaration:
+            case DW_AT_description:
+            case DW_AT_mutable:
+            case DW_AT_visibility:
+            case DW_AT_sibling:
+              break;
             }
-            break;
+          }
         }
-        default:
-            break;
-    }
-
-    m_die_to_decl[die.GetDIE()] = decl;
-    m_decl_to_die[decl].insert(die.GetDIE());
 
-    return decl;
-}
+        if (prop_name) {
+          ConstString fixed_getter;
+          ConstString fixed_setter;
 
-clang::DeclContext *
-DWARFASTParserClang::GetClangDeclContextForDIE (const DWARFDIE &die)
-{
-    if (die)
-    {
-        clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE (die);
-        if (decl_ctx)
-            return decl_ctx;
-
-        bool try_parsing_type = true;
-        switch (die.Tag())
-        {
-            case DW_TAG_compile_unit:
-                decl_ctx = m_ast.GetTranslationUnitDecl();
-                try_parsing_type = false;
-                break;
-
-            case DW_TAG_namespace:
-                decl_ctx = ResolveNamespaceDIE (die);
-                try_parsing_type = false;
-                break;
-
-            case DW_TAG_lexical_block:
-                decl_ctx = (clang::DeclContext *)ResolveBlockDIE(die);
-                try_parsing_type = false;
-                break;
+          // Check if the property getter/setter were provided as full
+          // names.  We want basenames, so we extract them.
 
-            default:
-                break;
-        }
+          if (prop_getter_name && prop_getter_name[0] == '-') {
+            ObjCLanguage::MethodName prop_getter_method(prop_getter_name, true);
+            prop_getter_name = prop_getter_method.GetSelector().GetCString();
+          }
 
-        if (decl_ctx == nullptr && try_parsing_type)
-        {
-            Type* type = die.GetDWARF()->ResolveType (die);
-            if (type)
-                decl_ctx = GetCachedClangDeclContextForDIE (die);
-        }
+          if (prop_setter_name && prop_setter_name[0] == '-') {
+            ObjCLanguage::MethodName prop_setter_method(prop_setter_name, true);
+            prop_setter_name = prop_setter_method.GetSelector().GetCString();
+          }
 
-        if (decl_ctx)
-        {
-            LinkDeclContextToDIE (decl_ctx, die);
-            return decl_ctx;
-        }
-    }
-    return nullptr;
-}
+          // If the names haven't been provided, they need to be
+          // filled in.
 
-clang::BlockDecl *
-DWARFASTParserClang::ResolveBlockDIE (const DWARFDIE &die)
-{
-    if (die && die.Tag() == DW_TAG_lexical_block)
-    {
-        clang::BlockDecl *decl = llvm::cast_or_null<clang::BlockDecl>(m_die_to_decl_ctx[die.GetDIE()]);
+          if (!prop_getter_name) {
+            prop_getter_name = prop_name;
+          }
+          if (!prop_setter_name && prop_name[0] &&
+              !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
+            StreamString ss;
 
-        if (!decl)
-        {
-            DWARFDIE decl_context_die;
-            clang::DeclContext *decl_context = GetClangDeclContextContainingDIE(die, &decl_context_die);
-            decl = m_ast.CreateBlockDeclaration(decl_context);
+            ss.Printf("set%c%s:", toupper(prop_name[0]), &prop_name[1]);
 
-            if (decl)
-                LinkDeclContextToDIE((clang::DeclContext *)decl, die);
+            fixed_setter.SetCString(ss.GetData());
+            prop_setter_name = fixed_setter.GetCString();
+          }
         }
 
-        return decl;
-    }
-    return nullptr;
-}
-
-clang::NamespaceDecl *
-DWARFASTParserClang::ResolveNamespaceDIE (const DWARFDIE &die)
-{
-    if (die && die.Tag() == DW_TAG_namespace)
-    {
-        // See if we already parsed this namespace DIE and associated it with a
-        // uniqued namespace declaration
-        clang::NamespaceDecl *namespace_decl = static_cast<clang::NamespaceDecl *>(m_die_to_decl_ctx[die.GetDIE()]);
-        if (namespace_decl)
-            return namespace_decl;
-        else
-        {
-            const char *namespace_name = die.GetName();
-            clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (die, nullptr);
-            namespace_decl = m_ast.GetUniqueNamespaceDeclaration (namespace_name, containing_decl_ctx);
-            Log *log = nullptr;// (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
-            if (log)
-            {
-                SymbolFileDWARF *dwarf = die.GetDWARF();
-                if (namespace_name)
-                {
-                    dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                     "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl *%p (original = %p)",
-                                                                     static_cast<void*>(m_ast.getASTContext()),
-                                                                     die.GetID(),
-                                                                     namespace_name,
-                                                                     static_cast<void*>(namespace_decl),
-                                                                     static_cast<void*>(namespace_decl->getOriginalNamespace()));
-                }
+        // Clang has a DWARF generation bug where sometimes it
+        // represents fields that are references with bad byte size
+        // and bit size/offset information such as:
+        //
+        //  DW_AT_byte_size( 0x00 )
+        //  DW_AT_bit_size( 0x40 )
+        //  DW_AT_bit_offset( 0xffffffffffffffc0 )
+        //
+        // So check the bit offset to make sure it is sane, and if
+        // the values are not sane, remove them. If we don't do this
+        // then we will end up with a crash if we try to use this
+        // type in an expression when clang becomes unhappy with its
+        // recycled debug info.
+
+        if (byte_size == 0 && bit_offset < 0) {
+          bit_size = 0;
+          bit_offset = 0;
+        }
+
+        // FIXME: Make Clang ignore Objective-C accessibility for expressions
+        if (class_language == eLanguageTypeObjC ||
+            class_language == eLanguageTypeObjC_plus_plus)
+          accessibility = eAccessNone;
+
+        if (member_idx == 0 && !is_artificial && name &&
+            (strstr(name, "_vptr$") == name)) {
+          // Not all compilers will mark the vtable pointer
+          // member as artificial (llvm-gcc). We can't have
+          // the virtual members in our classes otherwise it
+          // throws off all child offsets since we end up
+          // having and extra pointer sized member in our
+          // class layouts.
+          is_artificial = true;
+        }
+
+        // Handle static members
+        if (is_external && member_byte_offset == UINT32_MAX) {
+          Type *var_type = die.ResolveTypeUID(DIERef(encoding_form));
+
+          if (var_type) {
+            if (accessibility == eAccessNone)
+              accessibility = eAccessPublic;
+            ClangASTContext::AddVariableToRecordType(
+                class_clang_type, name, var_type->GetLayoutCompilerType(),
+                accessibility);
+          }
+          break;
+        }
+
+        if (is_artificial == false) {
+          Type *member_type = die.ResolveTypeUID(DIERef(encoding_form));
+
+          clang::FieldDecl *field_decl = NULL;
+          if (tag == DW_TAG_member) {
+            if (member_type) {
+              if (accessibility == eAccessNone)
+                accessibility = default_accessibility;
+              member_accessibilities.push_back(accessibility);
+
+              uint64_t field_bit_offset =
+                  (member_byte_offset == UINT32_MAX ? 0
+                                                    : (member_byte_offset * 8));
+              if (bit_size > 0) {
+
+                BitfieldInfo this_field_info;
+                this_field_info.bit_offset = field_bit_offset;
+                this_field_info.bit_size = bit_size;
+
+                /////////////////////////////////////////////////////////////
+                // How to locate a field given the DWARF debug information
+                //
+                // AT_byte_size indicates the size of the word in which the
+                // bit offset must be interpreted.
+                //
+                // AT_data_member_location indicates the byte offset of the
+                // word from the base address of the structure.
+                //
+                // AT_bit_offset indicates how many bits into the word
+                // (according to the host endianness) the low-order bit of
+                // the field starts.  AT_bit_offset can be negative.
+                //
+                // AT_bit_size indicates the size of the field in bits.
+                /////////////////////////////////////////////////////////////
+
+                if (data_bit_offset != UINT64_MAX) {
+                  this_field_info.bit_offset = data_bit_offset;
+                } else {
+                  if (byte_size == 0)
+                    byte_size = member_type->GetByteSize();
+
+                  ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
+                  if (objfile->GetByteOrder() == eByteOrderLittle) {
+                    this_field_info.bit_offset += byte_size * 8;
+                    this_field_info.bit_offset -= (bit_offset + bit_size);
+                  } else {
+                    this_field_info.bit_offset += bit_offset;
+                  }
+                }
+
+                if ((this_field_info.bit_offset >= parent_bit_size) ||
+                    !last_field_info.NextBitfieldOffsetIsValid(
+                        this_field_info.bit_offset)) {
+                  ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
+                  objfile->GetModule()->ReportWarning(
+                      "0x%8.8" PRIx64 ": %s bitfield named \"%s\" has invalid "
+                                      "bit offset (0x%8.8" PRIx64
+                      ") member will be ignored. Please file a bug against the "
+                      "compiler and include the preprocessed output for %s\n",
+                      die.GetID(), DW_TAG_value_to_name(tag), name,
+                      this_field_info.bit_offset,
+                      sc.comp_unit ? sc.comp_unit->GetPath().c_str()
+                                   : "the source file");
+                  this_field_info.Clear();
+                  continue;
+                }
+
+                // Update the field bit offset we will report for layout
+                field_bit_offset = this_field_info.bit_offset;
+
+                // If the member to be emitted did not start on a character
+                // boundary and there is
+                // empty space between the last field and this one, then we need
+                // to emit an
+                // anonymous member filling up the space up to its start.  There
+                // are three cases
+                // here:
+                //
+                // 1 If the previous member ended on a character boundary, then
+                // we can emit an
+                //   anonymous member starting at the most recent character
+                //   boundary.
+                //
+                // 2 If the previous member did not end on a character boundary
+                // and the distance
+                //   from the end of the previous member to the current member
+                //   is less than a
+                //   word width, then we can emit an anonymous member starting
+                //   right after the
+                //   previous member and right before this member.
+                //
+                // 3 If the previous member did not end on a character boundary
+                // and the distance
+                //   from the end of the previous member to the current member
+                //   is greater than
+                //   or equal a word width, then we act as in Case 1.
+
+                const uint64_t character_width = 8;
+                const uint64_t word_width = 32;
+
+                // Objective-C has invalid DW_AT_bit_offset values in older
+                // versions
+                // of clang, so we have to be careful and only insert unnamed
+                // bitfields
+                // if we have a new enough clang.
+                bool detect_unnamed_bitfields = true;
+
+                if (class_language == eLanguageTypeObjC ||
+                    class_language == eLanguageTypeObjC_plus_plus)
+                  detect_unnamed_bitfields =
+                      die.GetCU()->Supports_unnamed_objc_bitfields();
+
+                if (detect_unnamed_bitfields) {
+                  BitfieldInfo anon_field_info;
+
+                  if ((this_field_info.bit_offset % character_width) !=
+                      0) // not char aligned
+                  {
+                    uint64_t last_field_end = 0;
+
+                    if (last_field_info.IsValid())
+                      last_field_end =
+                          last_field_info.bit_offset + last_field_info.bit_size;
+
+                    if (this_field_info.bit_offset != last_field_end) {
+                      if (((last_field_end % character_width) == 0) || // case 1
+                          (this_field_info.bit_offset - last_field_end >=
+                           word_width)) // case 3
+                      {
+                        anon_field_info.bit_size =
+                            this_field_info.bit_offset % character_width;
+                        anon_field_info.bit_offset =
+                            this_field_info.bit_offset -
+                            anon_field_info.bit_size;
+                      } else // case 2
+                      {
+                        anon_field_info.bit_size =
+                            this_field_info.bit_offset - last_field_end;
+                        anon_field_info.bit_offset = last_field_end;
+                      }
+                    }
+                  }
+
+                  if (anon_field_info.IsValid()) {
+                    clang::FieldDecl *unnamed_bitfield_decl =
+                        ClangASTContext::AddFieldToRecordType(
+                            class_clang_type, NULL,
+                            m_ast.GetBuiltinTypeForEncodingAndBitSize(
+                                eEncodingSint, word_width),
+                            accessibility, anon_field_info.bit_size);
+
+                    layout_info.field_offsets.insert(std::make_pair(
+                        unnamed_bitfield_decl, anon_field_info.bit_offset));
+                  }
+                }
+                last_field_info = this_field_info;
+              } else {
+                last_field_info.Clear();
+              }
+
+              CompilerType member_clang_type =
+                  member_type->GetLayoutCompilerType();
+              if (!member_clang_type.IsCompleteType())
+                member_clang_type.GetCompleteType();
+
+              {
+                // Older versions of clang emit array[0] and array[1] in the
+                // same way (<rdar://problem/12566646>).
+                // If the current field is at the end of the structure, then
+                // there is definitely no room for extra
+                // elements and we override the type to array[0].
+
+                CompilerType member_array_element_type;
+                uint64_t member_array_size;
+                bool member_array_is_incomplete;
+
+                if (member_clang_type.IsArrayType(
+                        &member_array_element_type, &member_array_size,
+                        &member_array_is_incomplete) &&
+                    !member_array_is_incomplete) {
+                  uint64_t parent_byte_size =
+                      parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size,
+                                                             UINT64_MAX);
+
+                  if (member_byte_offset >= parent_byte_size) {
+                    if (member_array_size != 1 &&
+                        (member_array_size != 0 ||
+                         member_byte_offset > parent_byte_size)) {
+                      module_sp->ReportError(
+                          "0x%8.8" PRIx64
+                          ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64
+                          " which extends beyond the bounds of 0x%8.8" PRIx64,
+                          die.GetID(), name, encoding_form.Reference(),
+                          parent_die.GetID());
+                    }
+
+                    member_clang_type = m_ast.CreateArrayType(
+                        member_array_element_type, 0, false);
+                  }
+                }
+              }
+
+              if (ClangASTContext::IsCXXClassType(member_clang_type) &&
+                  member_clang_type.GetCompleteType() == false) {
+                if (die.GetCU()->GetProducer() ==
+                    DWARFCompileUnit::eProducerClang)
+                  module_sp->ReportError(
+                      "DWARF DIE at 0x%8.8x (class %s) has a member variable "
+                      "0x%8.8x (%s) whose type is a forward declaration, not a "
+                      "complete definition.\nTry compiling the source file "
+                      "with -fno-limit-debug-info",
+                      parent_die.GetOffset(), parent_die.GetName(),
+                      die.GetOffset(), name);
                 else
-                {
-                    dwarf->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                     "ASTContext => %p: 0x%8.8" PRIx64 ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p (original = %p)",
-                                                                     static_cast<void*>(m_ast.getASTContext()),
-                                                                     die.GetID(),
-                                                                     static_cast<void*>(namespace_decl),
-                                                                     static_cast<void*>(namespace_decl->getOriginalNamespace()));
-                }
+                  module_sp->ReportError(
+                      "DWARF DIE at 0x%8.8x (class %s) has a member variable "
+                      "0x%8.8x (%s) whose type is a forward declaration, not a "
+                      "complete definition.\nPlease file a bug against the "
+                      "compiler and include the preprocessed output for %s",
+                      parent_die.GetOffset(), parent_die.GetName(),
+                      die.GetOffset(), name,
+                      sc.comp_unit ? sc.comp_unit->GetPath().c_str()
+                                   : "the source file");
+                // We have no choice other than to pretend that the member class
+                // is complete. If we don't do this, clang will crash when
+                // trying
+                // to layout the class. Since we provide layout assistance, all
+                // ivars in this class and other classes will be fine, this is
+                // the best we can do short of crashing.
+                if (ClangASTContext::StartTagDeclarationDefinition(
+                        member_clang_type)) {
+                  ClangASTContext::CompleteTagDeclarationDefinition(
+                      member_clang_type);
+                } else {
+                  module_sp->ReportError(
+                      "DWARF DIE at 0x%8.8x (class %s) has a member variable "
+                      "0x%8.8x (%s) whose type claims to be a C++ class but we "
+                      "were not able to start its definition.\nPlease file a "
+                      "bug and attach the file at the start of this error "
+                      "message",
+                      parent_die.GetOffset(), parent_die.GetName(),
+                      die.GetOffset(), name);
+                }
+              }
+
+              field_decl = ClangASTContext::AddFieldToRecordType(
+                  class_clang_type, name, member_clang_type, accessibility,
+                  bit_size);
+
+              m_ast.SetMetadataAsUserID(field_decl, die.GetID());
+
+              layout_info.field_offsets.insert(
+                  std::make_pair(field_decl, field_bit_offset));
+            } else {
+              if (name)
+                module_sp->ReportError(
+                    "0x%8.8" PRIx64
+                    ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64
+                    " which was unable to be parsed",
+                    die.GetID(), name, encoding_form.Reference());
+              else
+                module_sp->ReportError(
+                    "0x%8.8" PRIx64
+                    ": DW_TAG_member refers to type 0x%8.8" PRIx64
+                    " which was unable to be parsed",
+                    die.GetID(), encoding_form.Reference());
+            }
+          }
+
+          if (prop_name != NULL && member_type) {
+            clang::ObjCIvarDecl *ivar_decl = NULL;
+
+            if (field_decl) {
+              ivar_decl = clang::dyn_cast<clang::ObjCIvarDecl>(field_decl);
+              assert(ivar_decl != NULL);
+            }
+
+            ClangASTMetadata metadata;
+            metadata.SetUserID(die.GetID());
+            delayed_properties.push_back(DelayedAddObjCClassProperty(
+                class_clang_type, prop_name,
+                member_type->GetLayoutCompilerType(), ivar_decl,
+                prop_setter_name, prop_getter_name, prop_attributes,
+                &metadata));
+
+            if (ivar_decl)
+              m_ast.SetMetadataAsUserID(ivar_decl, die.GetID());
+          }
+        }
+      }
+      ++member_idx;
+    } break;
+
+    case DW_TAG_subprogram:
+      // Let the type parsing code handle this one for us.
+      member_function_dies.Append(die);
+      break;
+
+    case DW_TAG_inheritance: {
+      is_a_class = true;
+      if (default_accessibility == eAccessNone)
+        default_accessibility = eAccessPrivate;
+      // TODO: implement DW_TAG_inheritance type parsing
+      DWARFAttributes attributes;
+      const size_t num_attributes = die.GetAttributes(attributes);
+      if (num_attributes > 0) {
+        Declaration decl;
+        DWARFExpression location(die.GetCU());
+        DWARFFormValue encoding_form;
+        AccessType accessibility = default_accessibility;
+        bool is_virtual = false;
+        bool is_base_of_class = true;
+        off_t member_byte_offset = 0;
+        uint32_t i;
+        for (i = 0; i < num_attributes; ++i) {
+          const dw_attr_t attr = attributes.AttributeAtIndex(i);
+          DWARFFormValue form_value;
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            switch (attr) {
+            case DW_AT_decl_file:
+              decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+                  form_value.Unsigned()));
+              break;
+            case DW_AT_decl_line:
+              decl.SetLine(form_value.Unsigned());
+              break;
+            case DW_AT_decl_column:
+              decl.SetColumn(form_value.Unsigned());
+              break;
+            case DW_AT_type:
+              encoding_form = form_value;
+              break;
+            case DW_AT_data_member_location:
+              if (form_value.BlockData()) {
+                Value initialValue(0);
+                Value memberOffset(0);
+                const DWARFDataExtractor &debug_info_data =
+                    die.GetDWARF()->get_debug_info_data();
+                uint32_t block_length = form_value.Unsigned();
+                uint32_t block_offset =
+                    form_value.BlockData() - debug_info_data.GetDataStart();
+                if (DWARFExpression::Evaluate(
+                        nullptr, nullptr, nullptr, nullptr, module_sp,
+                        debug_info_data, die.GetCU(), block_offset,
+                        block_length, eRegisterKindDWARF, &initialValue,
+                        nullptr, memberOffset, nullptr)) {
+                  member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
+                }
+              } else {
+                // With DWARF 3 and later, if the value is an integer constant,
+                // this form value is the offset in bytes from the beginning
+                // of the containing entity.
+                member_byte_offset = form_value.Unsigned();
+              }
+              break;
+
+            case DW_AT_accessibility:
+              accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
+              break;
+
+            case DW_AT_virtuality:
+              is_virtual = form_value.Boolean();
+              break;
+
+            case DW_AT_sibling:
+              break;
+
+            default:
+              break;
             }
+          }
+        }
 
-            if (namespace_decl)
-                LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, die);
-            return namespace_decl;
+        Type *base_class_type = die.ResolveTypeUID(DIERef(encoding_form));
+        if (base_class_type == NULL) {
+          module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to "
+                                 "resolve the base class at 0x%8.8" PRIx64
+                                 " from enclosing type 0x%8.8x. \nPlease file "
+                                 "a bug and attach the file at the start of "
+                                 "this error message",
+                                 die.GetOffset(), encoding_form.Reference(),
+                                 parent_die.GetOffset());
+          break;
+        }
+
+        CompilerType base_class_clang_type =
+            base_class_type->GetFullCompilerType();
+        assert(base_class_clang_type);
+        if (class_language == eLanguageTypeObjC) {
+          ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
+        } else {
+          base_classes.push_back(ast->CreateBaseClassSpecifier(
+              base_class_clang_type.GetOpaqueQualType(), accessibility,
+              is_virtual, is_base_of_class));
+
+          if (is_virtual) {
+            // Do not specify any offset for virtual inheritance. The DWARF
+            // produced by clang doesn't
+            // give us a constant offset, but gives us a DWARF expressions that
+            // requires an actual object
+            // in memory. the DW_AT_data_member_location for a virtual base
+            // class looks like:
+            //      DW_AT_data_member_location( DW_OP_dup, DW_OP_deref,
+            //      DW_OP_constu(0x00000018), DW_OP_minus, DW_OP_deref,
+            //      DW_OP_plus )
+            // Given this, there is really no valid response we can give to
+            // clang for virtual base
+            // class offsets, and this should eventually be removed from
+            // LayoutRecordType() in the external
+            // AST source in clang.
+          } else {
+            layout_info.base_offsets.insert(std::make_pair(
+                ast->GetAsCXXRecordDecl(
+                    base_class_clang_type.GetOpaqueQualType()),
+                clang::CharUnits::fromQuantity(member_byte_offset)));
+          }
+        }
+      }
+    } break;
+
+    default:
+      break;
+    }
+  }
+
+  return true;
+}
+
+size_t DWARFASTParserClang::ParseChildParameters(
+    const SymbolContext &sc, clang::DeclContext *containing_decl_ctx,
+    const DWARFDIE &parent_die, bool skip_artificial, bool &is_static,
+    bool &is_variadic, bool &has_template_params,
+    std::vector<CompilerType> &function_param_types,
+    std::vector<clang::ParmVarDecl *> &function_param_decls,
+    unsigned &type_quals) {
+  if (!parent_die)
+    return 0;
+
+  size_t arg_idx = 0;
+  for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
+       die = die.GetSibling()) {
+    const dw_tag_t tag = die.Tag();
+    switch (tag) {
+    case DW_TAG_formal_parameter: {
+      DWARFAttributes attributes;
+      const size_t num_attributes = die.GetAttributes(attributes);
+      if (num_attributes > 0) {
+        const char *name = NULL;
+        Declaration decl;
+        DWARFFormValue param_type_die_form;
+        bool is_artificial = false;
+        // one of None, Auto, Register, Extern, Static, PrivateExtern
+
+        clang::StorageClass storage = clang::SC_None;
+        uint32_t i;
+        for (i = 0; i < num_attributes; ++i) {
+          const dw_attr_t attr = attributes.AttributeAtIndex(i);
+          DWARFFormValue form_value;
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            switch (attr) {
+            case DW_AT_decl_file:
+              decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+                  form_value.Unsigned()));
+              break;
+            case DW_AT_decl_line:
+              decl.SetLine(form_value.Unsigned());
+              break;
+            case DW_AT_decl_column:
+              decl.SetColumn(form_value.Unsigned());
+              break;
+            case DW_AT_name:
+              name = form_value.AsCString();
+              break;
+            case DW_AT_type:
+              param_type_die_form = form_value;
+              break;
+            case DW_AT_artificial:
+              is_artificial = form_value.Boolean();
+              break;
+            case DW_AT_location:
+            //                          if (form_value.BlockData())
+            //                          {
+            //                              const DWARFDataExtractor&
+            //                              debug_info_data = debug_info();
+            //                              uint32_t block_length =
+            //                              form_value.Unsigned();
+            //                              DWARFDataExtractor
+            //                              location(debug_info_data,
+            //                              form_value.BlockData() -
+            //                              debug_info_data.GetDataStart(),
+            //                              block_length);
+            //                          }
+            //                          else
+            //                          {
+            //                          }
+            //                          break;
+            case DW_AT_const_value:
+            case DW_AT_default_value:
+            case DW_AT_description:
+            case DW_AT_endianity:
+            case DW_AT_is_optional:
+            case DW_AT_segment:
+            case DW_AT_variable_parameter:
+            default:
+            case DW_AT_abstract_origin:
+            case DW_AT_sibling:
+              break;
+            }
+          }
+        }
+
+        bool skip = false;
+        if (skip_artificial) {
+          if (is_artificial) {
+            // In order to determine if a C++ member function is
+            // "const" we have to look at the const-ness of "this"...
+            // Ugly, but that
+            if (arg_idx == 0) {
+              if (DeclKindIsCXXClass(containing_decl_ctx->getDeclKind())) {
+                // Often times compilers omit the "this" name for the
+                // specification DIEs, so we can't rely upon the name
+                // being in the formal parameter DIE...
+                if (name == NULL || ::strcmp(name, "this") == 0) {
+                  Type *this_type =
+                      die.ResolveTypeUID(DIERef(param_type_die_form));
+                  if (this_type) {
+                    uint32_t encoding_mask = this_type->GetEncodingMask();
+                    if (encoding_mask & Type::eEncodingIsPointerUID) {
+                      is_static = false;
+
+                      if (encoding_mask & (1u << Type::eEncodingIsConstUID))
+                        type_quals |= clang::Qualifiers::Const;
+                      if (encoding_mask & (1u << Type::eEncodingIsVolatileUID))
+                        type_quals |= clang::Qualifiers::Volatile;
+                    }
+                  }
+                }
+              }
+            }
+            skip = true;
+          } else {
+
+            // HACK: Objective C formal parameters "self" and "_cmd"
+            // are not marked as artificial in the DWARF...
+            CompileUnit *comp_unit = die.GetLLDBCompileUnit();
+            if (comp_unit) {
+              switch (comp_unit->GetLanguage()) {
+              case eLanguageTypeObjC:
+              case eLanguageTypeObjC_plus_plus:
+                if (name && name[0] &&
+                    (strcmp(name, "self") == 0 || strcmp(name, "_cmd") == 0))
+                  skip = true;
+                break;
+              default:
+                break;
+              }
+            }
+          }
         }
-    }
-    return nullptr;
-}
 
-clang::DeclContext *
-DWARFASTParserClang::GetClangDeclContextContainingDIE (const DWARFDIE &die,
-                                                       DWARFDIE *decl_ctx_die_copy)
-{
-    SymbolFileDWARF *dwarf = die.GetDWARF();
+        if (!skip) {
+          Type *type = die.ResolveTypeUID(DIERef(param_type_die_form));
+          if (type) {
+            function_param_types.push_back(type->GetForwardCompilerType());
+
+            clang::ParmVarDecl *param_var_decl =
+                m_ast.CreateParameterDeclaration(
+                    name, type->GetForwardCompilerType(), storage);
+            assert(param_var_decl);
+            function_param_decls.push_back(param_var_decl);
+
+            m_ast.SetMetadataAsUserID(param_var_decl, die.GetID());
+          }
+        }
+      }
+      arg_idx++;
+    } break;
+
+    case DW_TAG_unspecified_parameters:
+      is_variadic = true;
+      break;
+
+    case DW_TAG_template_type_parameter:
+    case DW_TAG_template_value_parameter:
+      // The one caller of this was never using the template_param_infos,
+      // and the local variable was taking up a large amount of stack space
+      // in SymbolFileDWARF::ParseType() so this was removed. If we ever need
+      // the template params back, we can add them back.
+      // ParseTemplateDIE (dwarf_cu, die, template_param_infos);
+      has_template_params = true;
+      break;
+
+    default:
+      break;
+    }
+  }
+  return arg_idx;
+}
+
+void DWARFASTParserClang::ParseChildArrayInfo(
+    const SymbolContext &sc, const DWARFDIE &parent_die, int64_t &first_index,
+    std::vector<uint64_t> &element_orders, uint32_t &byte_stride,
+    uint32_t &bit_stride) {
+  if (!parent_die)
+    return;
 
-    DWARFDIE decl_ctx_die = dwarf->GetDeclContextDIEContainingDIE (die);
+  for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
+       die = die.GetSibling()) {
+    const dw_tag_t tag = die.Tag();
+    switch (tag) {
+    case DW_TAG_subrange_type: {
+      DWARFAttributes attributes;
+      const size_t num_child_attributes = die.GetAttributes(attributes);
+      if (num_child_attributes > 0) {
+        uint64_t num_elements = 0;
+        uint64_t lower_bound = 0;
+        uint64_t upper_bound = 0;
+        bool upper_bound_valid = false;
+        uint32_t i;
+        for (i = 0; i < num_child_attributes; ++i) {
+          const dw_attr_t attr = attributes.AttributeAtIndex(i);
+          DWARFFormValue form_value;
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            switch (attr) {
+            case DW_AT_name:
+              break;
+
+            case DW_AT_count:
+              num_elements = form_value.Unsigned();
+              break;
+
+            case DW_AT_bit_stride:
+              bit_stride = form_value.Unsigned();
+              break;
+
+            case DW_AT_byte_stride:
+              byte_stride = form_value.Unsigned();
+              break;
+
+            case DW_AT_lower_bound:
+              lower_bound = form_value.Unsigned();
+              break;
+
+            case DW_AT_upper_bound:
+              upper_bound_valid = true;
+              upper_bound = form_value.Unsigned();
+              break;
 
-    if (decl_ctx_die_copy)
-        *decl_ctx_die_copy = decl_ctx_die;
+            default:
+            case DW_AT_abstract_origin:
+            case DW_AT_accessibility:
+            case DW_AT_allocated:
+            case DW_AT_associated:
+            case DW_AT_data_location:
+            case DW_AT_declaration:
+            case DW_AT_description:
+            case DW_AT_sibling:
+            case DW_AT_threads_scaled:
+            case DW_AT_type:
+            case DW_AT_visibility:
+              break;
+            }
+          }
+        }
 
-    if (decl_ctx_die)
-    {
-        clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE (decl_ctx_die);
-        if (clang_decl_ctx)
-            return clang_decl_ctx;
-    }
-    return m_ast.GetTranslationUnitDecl();
-}
+        if (num_elements == 0) {
+          if (upper_bound_valid && upper_bound >= lower_bound)
+            num_elements = upper_bound - lower_bound + 1;
+        }
 
-clang::DeclContext *
-DWARFASTParserClang::GetCachedClangDeclContextForDIE (const DWARFDIE &die)
-{
-    if (die)
-    {
-        DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die.GetDIE());
-        if (pos != m_die_to_decl_ctx.end())
-            return pos->second;
+        element_orders.push_back(num_elements);
+      }
+    } break;
     }
-    return nullptr;
-}
-
-void
-DWARFASTParserClang::LinkDeclContextToDIE (clang::DeclContext *decl_ctx, const DWARFDIE &die)
-{
-    m_die_to_decl_ctx[die.GetDIE()] = decl_ctx;
-    // There can be many DIEs for a single decl context
-    //m_decl_ctx_to_die[decl_ctx].insert(die.GetDIE());
-    m_decl_ctx_to_die.insert(std::make_pair(decl_ctx, die));
+  }
 }
 
-bool
-DWARFASTParserClang::CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die,
-                                                 const DWARFDIE &dst_class_die,
-                                                 lldb_private::Type *class_type,
-                                                 DWARFDIECollection &failures)
-{
-    if (!class_type || !src_class_die || !dst_class_die)
-        return false;
-    if (src_class_die.Tag() != dst_class_die.Tag())
-        return false;
+Type *DWARFASTParserClang::GetTypeForDIE(const DWARFDIE &die) {
+  if (die) {
+    SymbolFileDWARF *dwarf = die.GetDWARF();
+    DWARFAttributes attributes;
+    const size_t num_attributes = die.GetAttributes(attributes);
+    if (num_attributes > 0) {
+      DWARFFormValue type_die_form;
+      for (size_t i = 0; i < num_attributes; ++i) {
+        dw_attr_t attr = attributes.AttributeAtIndex(i);
+        DWARFFormValue form_value;
 
-    // We need to complete the class type so we can get all of the method types
-    // parsed so we can then unique those types to their equivalent counterparts
-    // in "dst_cu" and "dst_class_die"
-    class_type->GetFullCompilerType ();
-
-    DWARFDIE src_die;
-    DWARFDIE dst_die;
-    UniqueCStringMap<DWARFDIE> src_name_to_die;
-    UniqueCStringMap<DWARFDIE> dst_name_to_die;
-    UniqueCStringMap<DWARFDIE> src_name_to_die_artificial;
-    UniqueCStringMap<DWARFDIE> dst_name_to_die_artificial;
-    for (src_die = src_class_die.GetFirstChild(); src_die.IsValid(); src_die = src_die.GetSibling())
-    {
-        if (src_die.Tag() == DW_TAG_subprogram)
-        {
-            // Make sure this is a declaration and not a concrete instance by looking
-            // for DW_AT_declaration set to 1. Sometimes concrete function instances
-            // are placed inside the class definitions and shouldn't be included in
-            // the list of things are are tracking here.
-            if (src_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1)
-            {
-                const char *src_name = src_die.GetMangledName ();
-                if (src_name)
-                {
-                    ConstString src_const_name(src_name);
-                    if (src_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
-                        src_name_to_die_artificial.Append(src_const_name.GetCString(), src_die);
-                    else
-                        src_name_to_die.Append(src_const_name.GetCString(), src_die);
-                }
-            }
-        }
+        if (attr == DW_AT_type &&
+            attributes.ExtractFormValueAtIndex(i, form_value))
+          return dwarf->ResolveTypeUID(dwarf->GetDIE(DIERef(form_value)), true);
+      }
     }
-    for (dst_die = dst_class_die.GetFirstChild(); dst_die.IsValid(); dst_die = dst_die.GetSibling())
-    {
-        if (dst_die.Tag() == DW_TAG_subprogram)
-        {
-            // Make sure this is a declaration and not a concrete instance by looking
-            // for DW_AT_declaration set to 1. Sometimes concrete function instances
-            // are placed inside the class definitions and shouldn't be included in
-            // the list of things are are tracking here.
-            if (dst_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1)
-            {
-                const char *dst_name =  dst_die.GetMangledName ();
-                if (dst_name)
-                {
-                    ConstString dst_const_name(dst_name);
-                    if ( dst_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
-                        dst_name_to_die_artificial.Append(dst_const_name.GetCString(), dst_die);
-                    else
-                        dst_name_to_die.Append(dst_const_name.GetCString(), dst_die);
-                }
-            }
-        }
-    }
-    const uint32_t src_size = src_name_to_die.GetSize ();
-    const uint32_t dst_size = dst_name_to_die.GetSize ();
-    Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | DWARF_LOG_TYPE_COMPLETION));
+  }
 
-    // Is everything kosher so we can go through the members at top speed?
-    bool fast_path = true;
+  return nullptr;
+}
 
-    if (src_size != dst_size)
-    {
-        if (src_size != 0 && dst_size != 0)
-        {
-            if (log)
-                log->Printf("warning: trying to unique class DIE 0x%8.8x to 0x%8.8x, but they didn't have the same size (src=%d, dst=%d)",
-                            src_class_die.GetOffset(),
-                            dst_class_die.GetOffset(),
-                            src_size,
-                            dst_size);
-        }
+clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
+  if (!die)
+    return nullptr;
 
-        fast_path = false;
-    }
+  switch (die.Tag()) {
+  case DW_TAG_variable:
+  case DW_TAG_constant:
+  case DW_TAG_formal_parameter:
+  case DW_TAG_imported_declaration:
+  case DW_TAG_imported_module:
+    break;
+  default:
+    return nullptr;
+  }
 
-    uint32_t idx;
+  DIEToDeclMap::iterator cache_pos = m_die_to_decl.find(die.GetDIE());
+  if (cache_pos != m_die_to_decl.end())
+    return cache_pos->second;
 
-    if (fast_path)
-    {
-        for (idx = 0; idx < src_size; ++idx)
-        {
-            src_die = src_name_to_die.GetValueAtIndexUnchecked (idx);
-            dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx);
+  if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification)) {
+    clang::Decl *decl = GetClangDeclForDIE(spec_die);
+    m_die_to_decl[die.GetDIE()] = decl;
+    m_decl_to_die[decl].insert(die.GetDIE());
+    return decl;
+  }
 
-            if (src_die.Tag() != dst_die.Tag())
-            {
-                if (log)
-                    log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, but 0x%8.8x (%s) tags didn't match 0x%8.8x (%s)",
-                                src_class_die.GetOffset(),
-                                dst_class_die.GetOffset(),
-                                src_die.GetOffset(),
-                                src_die.GetTagAsCString(),
-                                dst_die.GetOffset(),
-                                dst_die.GetTagAsCString());
-                fast_path = false;
-            }
-
-            const char *src_name = src_die.GetMangledName ();
-            const char *dst_name = dst_die.GetMangledName ();
-
-            // Make sure the names match
-            if (src_name == dst_name || (strcmp (src_name, dst_name) == 0))
-                continue;
+  if (DWARFDIE abstract_origin_die =
+          die.GetReferencedDIE(DW_AT_abstract_origin)) {
+    clang::Decl *decl = GetClangDeclForDIE(abstract_origin_die);
+    m_die_to_decl[die.GetDIE()] = decl;
+    m_decl_to_die[decl].insert(die.GetDIE());
+    return decl;
+  }
 
-            if (log)
-                log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, but 0x%8.8x (%s) names didn't match 0x%8.8x (%s)",
-                            src_class_die.GetOffset(),
-                            dst_class_die.GetOffset(),
-                            src_die.GetOffset(),
-                            src_name,
-                            dst_die.GetOffset(),
-                            dst_name);
+  clang::Decl *decl = nullptr;
+  switch (die.Tag()) {
+  case DW_TAG_variable:
+  case DW_TAG_constant:
+  case DW_TAG_formal_parameter: {
+    SymbolFileDWARF *dwarf = die.GetDWARF();
+    Type *type = GetTypeForDIE(die);
+    if (dwarf && type) {
+      const char *name = die.GetName();
+      clang::DeclContext *decl_context =
+          ClangASTContext::DeclContextGetAsDeclContext(
+              dwarf->GetDeclContextContainingUID(die.GetID()));
+      decl = m_ast.CreateVariableDeclaration(
+          decl_context, name,
+          ClangUtil::GetQualType(type->GetForwardCompilerType()));
+    }
+    break;
+  }
+  case DW_TAG_imported_declaration: {
+    SymbolFileDWARF *dwarf = die.GetDWARF();
+    DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
+    if (imported_uid) {
+      CompilerDecl imported_decl = imported_uid.GetDecl();
+      if (imported_decl) {
+        clang::DeclContext *decl_context =
+            ClangASTContext::DeclContextGetAsDeclContext(
+                dwarf->GetDeclContextContainingUID(die.GetID()));
+        if (clang::NamedDecl *clang_imported_decl =
+                llvm::dyn_cast<clang::NamedDecl>(
+                    (clang::Decl *)imported_decl.GetOpaqueDecl()))
+          decl =
+              m_ast.CreateUsingDeclaration(decl_context, clang_imported_decl);
+      }
+    }
+    break;
+  }
+  case DW_TAG_imported_module: {
+    SymbolFileDWARF *dwarf = die.GetDWARF();
+    DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
 
-            fast_path = false;
-        }
-    }
+    if (imported_uid) {
+      CompilerDeclContext imported_decl_ctx = imported_uid.GetDeclContext();
+      if (imported_decl_ctx) {
+        clang::DeclContext *decl_context =
+            ClangASTContext::DeclContextGetAsDeclContext(
+                dwarf->GetDeclContextContainingUID(die.GetID()));
+        if (clang::NamespaceDecl *ns_decl =
+                ClangASTContext::DeclContextGetAsNamespaceDecl(
+                    imported_decl_ctx))
+          decl = m_ast.CreateUsingDirectiveDeclaration(decl_context, ns_decl);
+      }
+    }
+    break;
+  }
+  default:
+    break;
+  }
 
-    DWARFASTParserClang *src_dwarf_ast_parser = (DWARFASTParserClang *)src_die.GetDWARFParser();
-    DWARFASTParserClang *dst_dwarf_ast_parser = (DWARFASTParserClang *)dst_die.GetDWARFParser();
+  m_die_to_decl[die.GetDIE()] = decl;
+  m_decl_to_die[decl].insert(die.GetDIE());
 
-    // Now do the work of linking the DeclContexts and Types.
-    if (fast_path)
-    {
-        // We can do this quickly.  Just run across the tables index-for-index since
-        // we know each node has matching names and tags.
-        for (idx = 0; idx < src_size; ++idx)
-        {
-            src_die = src_name_to_die.GetValueAtIndexUnchecked (idx);
-            dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx);
+  return decl;
+}
 
-            clang::DeclContext *src_decl_ctx = src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()];
-            if (src_decl_ctx)
-            {
-                if (log)
-                    log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
-                                 static_cast<void*>(src_decl_ctx),
-                                 src_die.GetOffset(), dst_die.GetOffset());
-                dst_dwarf_ast_parser->LinkDeclContextToDIE (src_decl_ctx, dst_die);
-            }
-            else
-            {
-                if (log)
-                    log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found",
-                                 src_die.GetOffset(), dst_die.GetOffset());
-            }
+clang::DeclContext *
+DWARFASTParserClang::GetClangDeclContextForDIE(const DWARFDIE &die) {
+  if (die) {
+    clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE(die);
+    if (decl_ctx)
+      return decl_ctx;
+
+    bool try_parsing_type = true;
+    switch (die.Tag()) {
+    case DW_TAG_compile_unit:
+      decl_ctx = m_ast.GetTranslationUnitDecl();
+      try_parsing_type = false;
+      break;
+
+    case DW_TAG_namespace:
+      decl_ctx = ResolveNamespaceDIE(die);
+      try_parsing_type = false;
+      break;
+
+    case DW_TAG_lexical_block:
+      decl_ctx = (clang::DeclContext *)ResolveBlockDIE(die);
+      try_parsing_type = false;
+      break;
+
+    default:
+      break;
+    }
+
+    if (decl_ctx == nullptr && try_parsing_type) {
+      Type *type = die.GetDWARF()->ResolveType(die);
+      if (type)
+        decl_ctx = GetCachedClangDeclContextForDIE(die);
+    }
+
+    if (decl_ctx) {
+      LinkDeclContextToDIE(decl_ctx, die);
+      return decl_ctx;
+    }
+  }
+  return nullptr;
+}
+
+clang::BlockDecl *DWARFASTParserClang::ResolveBlockDIE(const DWARFDIE &die) {
+  if (die && die.Tag() == DW_TAG_lexical_block) {
+    clang::BlockDecl *decl =
+        llvm::cast_or_null<clang::BlockDecl>(m_die_to_decl_ctx[die.GetDIE()]);
+
+    if (!decl) {
+      DWARFDIE decl_context_die;
+      clang::DeclContext *decl_context =
+          GetClangDeclContextContainingDIE(die, &decl_context_die);
+      decl = m_ast.CreateBlockDeclaration(decl_context);
 
-            Type *src_child_type = dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()];
-            if (src_child_type)
-            {
-                if (log)
-                    log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
-                                 static_cast<void*>(src_child_type),
-                                 src_child_type->GetID(),
-                                 src_die.GetOffset(), dst_die.GetOffset());
-                dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type;
-            }
-            else
-            {
-                if (log)
-                    log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
-            }
-        }
+      if (decl)
+        LinkDeclContextToDIE((clang::DeclContext *)decl, die);
     }
-    else
-    {
-        // We must do this slowly.  For each member of the destination, look
-        // up a member in the source with the same name, check its tag, and
-        // unique them if everything matches up.  Report failures.
-
-        if (!src_name_to_die.IsEmpty() && !dst_name_to_die.IsEmpty())
-        {
-            src_name_to_die.Sort();
-
-            for (idx = 0; idx < dst_size; ++idx)
-            {
-                const char *dst_name = dst_name_to_die.GetCStringAtIndex(idx);
-                dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx);
-                src_die = src_name_to_die.Find(dst_name, DWARFDIE());
-
-                if (src_die && (src_die.Tag() == dst_die.Tag()))
-                {
-                    clang::DeclContext *src_decl_ctx = src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()];
-                    if (src_decl_ctx)
-                    {
-                        if (log)
-                            log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
-                                         static_cast<void*>(src_decl_ctx),
-                                         src_die.GetOffset(),
-                                         dst_die.GetOffset());
-                        dst_dwarf_ast_parser->LinkDeclContextToDIE (src_decl_ctx, dst_die);
-                    }
-                    else
-                    {
-                        if (log)
-                            log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
-                    }
-
-                    Type *src_child_type = dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()];
-                    if (src_child_type)
-                    {
-                        if (log)
-                            log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
-                                         static_cast<void*>(src_child_type),
-                                         src_child_type->GetID(),
-                                         src_die.GetOffset(),
-                                         dst_die.GetOffset());
-                        dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type;
-                    }
-                    else
-                    {
-                        if (log)
-                            log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
-                    }
-                }
-                else
-                {
-                    if (log)
-                        log->Printf ("warning: couldn't find a match for 0x%8.8x", dst_die.GetOffset());
 
-                    failures.Append(dst_die);
-                }
-            }
-        }
-    }
+    return decl;
+  }
+  return nullptr;
+}
 
-    const uint32_t src_size_artificial = src_name_to_die_artificial.GetSize ();
-    const uint32_t dst_size_artificial = dst_name_to_die_artificial.GetSize ();
+clang::NamespaceDecl *
+DWARFASTParserClang::ResolveNamespaceDIE(const DWARFDIE &die) {
+  if (die && die.Tag() == DW_TAG_namespace) {
+    // See if we already parsed this namespace DIE and associated it with a
+    // uniqued namespace declaration
+    clang::NamespaceDecl *namespace_decl =
+        static_cast<clang::NamespaceDecl *>(m_die_to_decl_ctx[die.GetDIE()]);
+    if (namespace_decl)
+      return namespace_decl;
+    else {
+      const char *namespace_name = die.GetName();
+      clang::DeclContext *containing_decl_ctx =
+          GetClangDeclContextContainingDIE(die, nullptr);
+      namespace_decl = m_ast.GetUniqueNamespaceDeclaration(namespace_name,
+                                                           containing_decl_ctx);
+      Log *log =
+          nullptr; // (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
+      if (log) {
+        SymbolFileDWARF *dwarf = die.GetDWARF();
+        if (namespace_name) {
+          dwarf->GetObjectFile()->GetModule()->LogMessage(
+              log, "ASTContext => %p: 0x%8.8" PRIx64
+                   ": DW_TAG_namespace with DW_AT_name(\"%s\") => "
+                   "clang::NamespaceDecl *%p (original = %p)",
+              static_cast<void *>(m_ast.getASTContext()), die.GetID(),
+              namespace_name, static_cast<void *>(namespace_decl),
+              static_cast<void *>(namespace_decl->getOriginalNamespace()));
+        } else {
+          dwarf->GetObjectFile()->GetModule()->LogMessage(
+              log, "ASTContext => %p: 0x%8.8" PRIx64
+                   ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p "
+                   "(original = %p)",
+              static_cast<void *>(m_ast.getASTContext()), die.GetID(),
+              static_cast<void *>(namespace_decl),
+              static_cast<void *>(namespace_decl->getOriginalNamespace()));
+        }
+      }
+
+      if (namespace_decl)
+        LinkDeclContextToDIE((clang::DeclContext *)namespace_decl, die);
+      return namespace_decl;
+    }
+  }
+  return nullptr;
+}
+
+clang::DeclContext *DWARFASTParserClang::GetClangDeclContextContainingDIE(
+    const DWARFDIE &die, DWARFDIE *decl_ctx_die_copy) {
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+
+  DWARFDIE decl_ctx_die = dwarf->GetDeclContextDIEContainingDIE(die);
+
+  if (decl_ctx_die_copy)
+    *decl_ctx_die_copy = decl_ctx_die;
+
+  if (decl_ctx_die) {
+    clang::DeclContext *clang_decl_ctx =
+        GetClangDeclContextForDIE(decl_ctx_die);
+    if (clang_decl_ctx)
+      return clang_decl_ctx;
+  }
+  return m_ast.GetTranslationUnitDecl();
+}
 
-    if (src_size_artificial && dst_size_artificial)
-    {
-        dst_name_to_die_artificial.Sort();
+clang::DeclContext *
+DWARFASTParserClang::GetCachedClangDeclContextForDIE(const DWARFDIE &die) {
+  if (die) {
+    DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die.GetDIE());
+    if (pos != m_die_to_decl_ctx.end())
+      return pos->second;
+  }
+  return nullptr;
+}
+
+void DWARFASTParserClang::LinkDeclContextToDIE(clang::DeclContext *decl_ctx,
+                                               const DWARFDIE &die) {
+  m_die_to_decl_ctx[die.GetDIE()] = decl_ctx;
+  // There can be many DIEs for a single decl context
+  // m_decl_ctx_to_die[decl_ctx].insert(die.GetDIE());
+  m_decl_ctx_to_die.insert(std::make_pair(decl_ctx, die));
+}
+
+bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
+    const DWARFDIE &src_class_die, const DWARFDIE &dst_class_die,
+    lldb_private::Type *class_type, DWARFDIECollection &failures) {
+  if (!class_type || !src_class_die || !dst_class_die)
+    return false;
+  if (src_class_die.Tag() != dst_class_die.Tag())
+    return false;
 
-        for (idx = 0; idx < src_size_artificial; ++idx)
-        {
-            const char *src_name_artificial = src_name_to_die_artificial.GetCStringAtIndex(idx);
-            src_die = src_name_to_die_artificial.GetValueAtIndexUnchecked (idx);
-            dst_die = dst_name_to_die_artificial.Find(src_name_artificial, DWARFDIE());
+  // We need to complete the class type so we can get all of the method types
+  // parsed so we can then unique those types to their equivalent counterparts
+  // in "dst_cu" and "dst_class_die"
+  class_type->GetFullCompilerType();
+
+  DWARFDIE src_die;
+  DWARFDIE dst_die;
+  UniqueCStringMap<DWARFDIE> src_name_to_die;
+  UniqueCStringMap<DWARFDIE> dst_name_to_die;
+  UniqueCStringMap<DWARFDIE> src_name_to_die_artificial;
+  UniqueCStringMap<DWARFDIE> dst_name_to_die_artificial;
+  for (src_die = src_class_die.GetFirstChild(); src_die.IsValid();
+       src_die = src_die.GetSibling()) {
+    if (src_die.Tag() == DW_TAG_subprogram) {
+      // Make sure this is a declaration and not a concrete instance by looking
+      // for DW_AT_declaration set to 1. Sometimes concrete function instances
+      // are placed inside the class definitions and shouldn't be included in
+      // the list of things are are tracking here.
+      if (src_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) {
+        const char *src_name = src_die.GetMangledName();
+        if (src_name) {
+          ConstString src_const_name(src_name);
+          if (src_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
+            src_name_to_die_artificial.Append(src_const_name.GetCString(),
+                                              src_die);
+          else
+            src_name_to_die.Append(src_const_name.GetCString(), src_die);
+        }
+      }
+    }
+  }
+  for (dst_die = dst_class_die.GetFirstChild(); dst_die.IsValid();
+       dst_die = dst_die.GetSibling()) {
+    if (dst_die.Tag() == DW_TAG_subprogram) {
+      // Make sure this is a declaration and not a concrete instance by looking
+      // for DW_AT_declaration set to 1. Sometimes concrete function instances
+      // are placed inside the class definitions and shouldn't be included in
+      // the list of things are are tracking here.
+      if (dst_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) {
+        const char *dst_name = dst_die.GetMangledName();
+        if (dst_name) {
+          ConstString dst_const_name(dst_name);
+          if (dst_die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0))
+            dst_name_to_die_artificial.Append(dst_const_name.GetCString(),
+                                              dst_die);
+          else
+            dst_name_to_die.Append(dst_const_name.GetCString(), dst_die);
+        }
+      }
+    }
+  }
+  const uint32_t src_size = src_name_to_die.GetSize();
+  const uint32_t dst_size = dst_name_to_die.GetSize();
+  Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO |
+                      // DWARF_LOG_TYPE_COMPLETION));
+
+  // Is everything kosher so we can go through the members at top speed?
+  bool fast_path = true;
+
+  if (src_size != dst_size) {
+    if (src_size != 0 && dst_size != 0) {
+      if (log)
+        log->Printf("warning: trying to unique class DIE 0x%8.8x to 0x%8.8x, "
+                    "but they didn't have the same size (src=%d, dst=%d)",
+                    src_class_die.GetOffset(), dst_class_die.GetOffset(),
+                    src_size, dst_size);
+    }
+
+    fast_path = false;
+  }
+
+  uint32_t idx;
+
+  if (fast_path) {
+    for (idx = 0; idx < src_size; ++idx) {
+      src_die = src_name_to_die.GetValueAtIndexUnchecked(idx);
+      dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx);
 
-            if (dst_die)
-            {
-                // Both classes have the artificial types, link them
-                clang::DeclContext *src_decl_ctx = src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()];
-                if (src_decl_ctx)
-                {
-                    if (log)
-                        log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
-                                     static_cast<void*>(src_decl_ctx),
-                                     src_die.GetOffset(), dst_die.GetOffset());
-                    dst_dwarf_ast_parser->LinkDeclContextToDIE (src_decl_ctx, dst_die);
-                }
-                else
-                {
-                    if (log)
-                        log->Printf ("warning: tried to unique decl context from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
-                }
+      if (src_die.Tag() != dst_die.Tag()) {
+        if (log)
+          log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, "
+                      "but 0x%8.8x (%s) tags didn't match 0x%8.8x (%s)",
+                      src_class_die.GetOffset(), dst_class_die.GetOffset(),
+                      src_die.GetOffset(), src_die.GetTagAsCString(),
+                      dst_die.GetOffset(), dst_die.GetTagAsCString());
+        fast_path = false;
+      }
 
-                Type *src_child_type = dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()];
-                if (src_child_type)
-                {
-                    if (log)
-                        log->Printf ("uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
-                                     static_cast<void*>(src_child_type),
-                                     src_child_type->GetID(),
-                                     src_die.GetOffset(), dst_die.GetOffset());
-                    dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type;
-                }
-                else
-                {
-                    if (log)
-                        log->Printf ("warning: tried to unique lldb_private::Type from 0x%8.8x for 0x%8.8x, but none was found", src_die.GetOffset(), dst_die.GetOffset());
-                }
-            }
-        }
-    }
+      const char *src_name = src_die.GetMangledName();
+      const char *dst_name = dst_die.GetMangledName();
 
-    if (dst_size_artificial)
-    {
-        for (idx = 0; idx < dst_size_artificial; ++idx)
-        {
-            const char *dst_name_artificial = dst_name_to_die_artificial.GetCStringAtIndex(idx);
-            dst_die = dst_name_to_die_artificial.GetValueAtIndexUnchecked (idx);
+      // Make sure the names match
+      if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
+        continue;
+
+      if (log)
+        log->Printf("warning: tried to unique class DIE 0x%8.8x to 0x%8.8x, "
+                    "but 0x%8.8x (%s) names didn't match 0x%8.8x (%s)",
+                    src_class_die.GetOffset(), dst_class_die.GetOffset(),
+                    src_die.GetOffset(), src_name, dst_die.GetOffset(),
+                    dst_name);
+
+      fast_path = false;
+    }
+  }
+
+  DWARFASTParserClang *src_dwarf_ast_parser =
+      (DWARFASTParserClang *)src_die.GetDWARFParser();
+  DWARFASTParserClang *dst_dwarf_ast_parser =
+      (DWARFASTParserClang *)dst_die.GetDWARFParser();
+
+  // Now do the work of linking the DeclContexts and Types.
+  if (fast_path) {
+    // We can do this quickly.  Just run across the tables index-for-index since
+    // we know each node has matching names and tags.
+    for (idx = 0; idx < src_size; ++idx) {
+      src_die = src_name_to_die.GetValueAtIndexUnchecked(idx);
+      dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx);
+
+      clang::DeclContext *src_decl_ctx =
+          src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()];
+      if (src_decl_ctx) {
+        if (log)
+          log->Printf("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
+                      static_cast<void *>(src_decl_ctx), src_die.GetOffset(),
+                      dst_die.GetOffset());
+        dst_dwarf_ast_parser->LinkDeclContextToDIE(src_decl_ctx, dst_die);
+      } else {
+        if (log)
+          log->Printf("warning: tried to unique decl context from 0x%8.8x for "
+                      "0x%8.8x, but none was found",
+                      src_die.GetOffset(), dst_die.GetOffset());
+      }
+
+      Type *src_child_type =
+          dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()];
+      if (src_child_type) {
+        if (log)
+          log->Printf(
+              "uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
+              static_cast<void *>(src_child_type), src_child_type->GetID(),
+              src_die.GetOffset(), dst_die.GetOffset());
+        dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type;
+      } else {
+        if (log)
+          log->Printf("warning: tried to unique lldb_private::Type from "
+                      "0x%8.8x for 0x%8.8x, but none was found",
+                      src_die.GetOffset(), dst_die.GetOffset());
+      }
+    }
+  } else {
+    // We must do this slowly.  For each member of the destination, look
+    // up a member in the source with the same name, check its tag, and
+    // unique them if everything matches up.  Report failures.
+
+    if (!src_name_to_die.IsEmpty() && !dst_name_to_die.IsEmpty()) {
+      src_name_to_die.Sort();
+
+      for (idx = 0; idx < dst_size; ++idx) {
+        const char *dst_name = dst_name_to_die.GetCStringAtIndex(idx);
+        dst_die = dst_name_to_die.GetValueAtIndexUnchecked(idx);
+        src_die = src_name_to_die.Find(dst_name, DWARFDIE());
+
+        if (src_die && (src_die.Tag() == dst_die.Tag())) {
+          clang::DeclContext *src_decl_ctx =
+              src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()];
+          if (src_decl_ctx) {
+            if (log)
+              log->Printf("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
+                          static_cast<void *>(src_decl_ctx),
+                          src_die.GetOffset(), dst_die.GetOffset());
+            dst_dwarf_ast_parser->LinkDeclContextToDIE(src_decl_ctx, dst_die);
+          } else {
             if (log)
-                log->Printf ("warning: need to create artificial method for 0x%8.8x for method '%s'", dst_die.GetOffset(), dst_name_artificial);
+              log->Printf("warning: tried to unique decl context from 0x%8.8x "
+                          "for 0x%8.8x, but none was found",
+                          src_die.GetOffset(), dst_die.GetOffset());
+          }
+
+          Type *src_child_type =
+              dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()];
+          if (src_child_type) {
+            if (log)
+              log->Printf("uniquing type %p (uid=0x%" PRIx64
+                          ") from 0x%8.8x for 0x%8.8x",
+                          static_cast<void *>(src_child_type),
+                          src_child_type->GetID(), src_die.GetOffset(),
+                          dst_die.GetOffset());
+            dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] =
+                src_child_type;
+          } else {
+            if (log)
+              log->Printf("warning: tried to unique lldb_private::Type from "
+                          "0x%8.8x for 0x%8.8x, but none was found",
+                          src_die.GetOffset(), dst_die.GetOffset());
+          }
+        } else {
+          if (log)
+            log->Printf("warning: couldn't find a match for 0x%8.8x",
+                        dst_die.GetOffset());
+
+          failures.Append(dst_die);
+        }
+      }
+    }
+  }
+
+  const uint32_t src_size_artificial = src_name_to_die_artificial.GetSize();
+  const uint32_t dst_size_artificial = dst_name_to_die_artificial.GetSize();
+
+  if (src_size_artificial && dst_size_artificial) {
+    dst_name_to_die_artificial.Sort();
+
+    for (idx = 0; idx < src_size_artificial; ++idx) {
+      const char *src_name_artificial =
+          src_name_to_die_artificial.GetCStringAtIndex(idx);
+      src_die = src_name_to_die_artificial.GetValueAtIndexUnchecked(idx);
+      dst_die =
+          dst_name_to_die_artificial.Find(src_name_artificial, DWARFDIE());
+
+      if (dst_die) {
+        // Both classes have the artificial types, link them
+        clang::DeclContext *src_decl_ctx =
+            src_dwarf_ast_parser->m_die_to_decl_ctx[src_die.GetDIE()];
+        if (src_decl_ctx) {
+          if (log)
+            log->Printf("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
+                        static_cast<void *>(src_decl_ctx), src_die.GetOffset(),
+                        dst_die.GetOffset());
+          dst_dwarf_ast_parser->LinkDeclContextToDIE(src_decl_ctx, dst_die);
+        } else {
+          if (log)
+            log->Printf("warning: tried to unique decl context from 0x%8.8x "
+                        "for 0x%8.8x, but none was found",
+                        src_die.GetOffset(), dst_die.GetOffset());
+        }
+
+        Type *src_child_type =
+            dst_die.GetDWARF()->GetDIEToType()[src_die.GetDIE()];
+        if (src_child_type) {
+          if (log)
+            log->Printf(
+                "uniquing type %p (uid=0x%" PRIx64 ") from 0x%8.8x for 0x%8.8x",
+                static_cast<void *>(src_child_type), src_child_type->GetID(),
+                src_die.GetOffset(), dst_die.GetOffset());
+          dst_die.GetDWARF()->GetDIEToType()[dst_die.GetDIE()] = src_child_type;
+        } else {
+          if (log)
+            log->Printf("warning: tried to unique lldb_private::Type from "
+                        "0x%8.8x for 0x%8.8x, but none was found",
+                        src_die.GetOffset(), dst_die.GetOffset());
+        }
+      }
+    }
+  }
+
+  if (dst_size_artificial) {
+    for (idx = 0; idx < dst_size_artificial; ++idx) {
+      const char *dst_name_artificial =
+          dst_name_to_die_artificial.GetCStringAtIndex(idx);
+      dst_die = dst_name_to_die_artificial.GetValueAtIndexUnchecked(idx);
+      if (log)
+        log->Printf("warning: need to create artificial method for 0x%8.8x for "
+                    "method '%s'",
+                    dst_die.GetOffset(), dst_name_artificial);
 
-            failures.Append(dst_die);
-        }
+      failures.Append(dst_die);
     }
+  }
 
-    return (failures.Size() != 0);
+  return (failures.Size() != 0);
 }
-

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Tue Sep  6 15:57:50 2016
@@ -13,10 +13,10 @@
 // C Includes
 // C++ Includes
 // Other libraries and framework includes
+#include "clang/AST/CharUnits.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
-#include "clang/AST/CharUnits.h"
 
 // Project includes
 #include "DWARFASTParser.h"
@@ -29,149 +29,131 @@
 class DWARFDebugInfoEntry;
 class DWARFDIECollection;
 
-class DWARFASTParserClang : public DWARFASTParser
-{
+class DWARFASTParserClang : public DWARFASTParser {
 public:
-    DWARFASTParserClang (lldb_private::ClangASTContext &ast);
-
-    ~DWARFASTParserClang() override;
+  DWARFASTParserClang(lldb_private::ClangASTContext &ast);
 
-    // DWARFASTParser interface.
-    lldb::TypeSP
-    ParseTypeFromDWARF (const lldb_private::SymbolContext& sc,
-                        const DWARFDIE &die,
-                        lldb_private::Log *log,
-                        bool *type_is_new_ptr) override;
+  ~DWARFASTParserClang() override;
 
+  // DWARFASTParser interface.
+  lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
+                                  const DWARFDIE &die, lldb_private::Log *log,
+                                  bool *type_is_new_ptr) override;
 
-    lldb_private::Function *
-    ParseFunctionFromDWARF (const lldb_private::SymbolContext& sc,
-                            const DWARFDIE &die) override;
+  lldb_private::Function *
+  ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc,
+                         const DWARFDIE &die) override;
 
-    bool
-    CompleteTypeFromDWARF (const DWARFDIE &die,
-                           lldb_private::Type *type,
-                           lldb_private::CompilerType &compiler_type) override;
+  bool
+  CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
+                        lldb_private::CompilerType &compiler_type) override;
 
-    lldb_private::CompilerDecl
-    GetDeclForUIDFromDWARF (const DWARFDIE &die) override;
+  lldb_private::CompilerDecl
+  GetDeclForUIDFromDWARF(const DWARFDIE &die) override;
 
-    std::vector<DWARFDIE>
-    GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) override;
+  std::vector<DWARFDIE>
+  GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context) override;
 
-    lldb_private::CompilerDeclContext
-    GetDeclContextForUIDFromDWARF (const DWARFDIE &die) override;
+  lldb_private::CompilerDeclContext
+  GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override;
 
-    lldb_private::CompilerDeclContext
-    GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) override;
+  lldb_private::CompilerDeclContext
+  GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override;
 
-    lldb_private::ClangASTImporter &
-    GetClangASTImporter();
+  lldb_private::ClangASTImporter &GetClangASTImporter();
 
 protected:
-    class DelayedAddObjCClassProperty;
-    typedef std::vector <DelayedAddObjCClassProperty> DelayedPropertyList;
+  class DelayedAddObjCClassProperty;
+  typedef std::vector<DelayedAddObjCClassProperty> DelayedPropertyList;
 
-    clang::BlockDecl *
-    ResolveBlockDIE (const DWARFDIE &die);
+  clang::BlockDecl *ResolveBlockDIE(const DWARFDIE &die);
 
-    clang::NamespaceDecl *
-    ResolveNamespaceDIE (const DWARFDIE &die);
+  clang::NamespaceDecl *ResolveNamespaceDIE(const DWARFDIE &die);
 
-    bool
-    ParseTemplateDIE (const DWARFDIE &die,
-                      lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
-    bool
-    ParseTemplateParameterInfos (const DWARFDIE &parent_die,
-                                 lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
-
-    bool
-    ParseChildMembers(const lldb_private::SymbolContext &sc, const DWARFDIE &die,
-                      lldb_private::CompilerType &class_compiler_type, const lldb::LanguageType class_language,
-                      std::vector<clang::CXXBaseSpecifier *> &base_classes, std::vector<int> &member_accessibilities,
-                      DWARFDIECollection &member_function_dies, DelayedPropertyList &delayed_properties,
-                      lldb::AccessType &default_accessibility, bool &is_a_class,
-                      lldb_private::ClangASTImporter::LayoutInfo &layout_info);
-
-    size_t
-    ParseChildParameters (const lldb_private::SymbolContext& sc,
-                          clang::DeclContext *containing_decl_ctx,
-                          const DWARFDIE &parent_die,
-                          bool skip_artificial,
-                          bool &is_static,
-                          bool &is_variadic,
-                          bool &has_template_params,
-                          std::vector<lldb_private::CompilerType>& function_args,
-                          std::vector<clang::ParmVarDecl*>& function_param_decls,
-                          unsigned &type_quals);
-
-    void
-    ParseChildArrayInfo (const lldb_private::SymbolContext& sc,
-                         const DWARFDIE &parent_die,
-                         int64_t& first_index,
-                         std::vector<uint64_t>& element_orders,
-                         uint32_t& byte_stride,
-                         uint32_t& bit_stride);
-
-    size_t
-    ParseChildEnumerators (const lldb_private::SymbolContext& sc,
-                           lldb_private::CompilerType &compiler_type,
-                           bool is_signed,
-                           uint32_t enumerator_byte_size,
-                           const DWARFDIE &parent_die);
-
-    lldb_private::Type *
-    GetTypeForDIE (const DWARFDIE &die);
-
-    clang::Decl *
-    GetClangDeclForDIE (const DWARFDIE &die);
-
-    clang::DeclContext *
-    GetClangDeclContextForDIE (const DWARFDIE &die);
-
-    clang::DeclContext *
-    GetClangDeclContextContainingDIE (const DWARFDIE &die,
-                                      DWARFDIE *decl_ctx_die);
-
-    bool
-    CopyUniqueClassMethodTypes (const DWARFDIE &src_class_die,
-                                const DWARFDIE &dst_class_die,
-                                lldb_private::Type *class_type,
-                                DWARFDIECollection &failures);
-
-    clang::DeclContext *
-    GetCachedClangDeclContextForDIE (const DWARFDIE &die);
-
-    void
-    LinkDeclContextToDIE (clang::DeclContext *decl_ctx,
-                          const DWARFDIE &die);
-
-    void
-    LinkDeclToDIE (clang::Decl *decl, const DWARFDIE &die);
-
-    lldb::TypeSP
-    ParseTypeFromDWO (const DWARFDIE &die, lldb_private::Log *log);
-
-    //----------------------------------------------------------------------
-    // Return true if this type is a declaration to a type in an external
-    // module.
-    //----------------------------------------------------------------------
-    lldb::ModuleSP
-    GetModuleForType (const DWARFDIE &die);
-
-    typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
-    typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
-    //typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap;
-    typedef std::multimap<const clang::DeclContext *, const DWARFDIE> DeclContextToDIEMap;
-    typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::Decl *> DIEToDeclMap;
-    typedef llvm::DenseMap<const clang::Decl *, DIEPointerSet> DeclToDIEMap;
-
-    lldb_private::ClangASTContext &m_ast;
-    DIEToDeclMap m_die_to_decl;
-    DeclToDIEMap m_decl_to_die;
-    DIEToDeclContextMap m_die_to_decl_ctx;
-    DeclContextToDIEMap m_decl_ctx_to_die;
-    std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_ap;
+  bool ParseTemplateDIE(const DWARFDIE &die,
+                        lldb_private::ClangASTContext::TemplateParameterInfos
+                            &template_param_infos);
+  bool ParseTemplateParameterInfos(
+      const DWARFDIE &parent_die,
+      lldb_private::ClangASTContext::TemplateParameterInfos
+          &template_param_infos);
+
+  bool
+  ParseChildMembers(const lldb_private::SymbolContext &sc, const DWARFDIE &die,
+                    lldb_private::CompilerType &class_compiler_type,
+                    const lldb::LanguageType class_language,
+                    std::vector<clang::CXXBaseSpecifier *> &base_classes,
+                    std::vector<int> &member_accessibilities,
+                    DWARFDIECollection &member_function_dies,
+                    DelayedPropertyList &delayed_properties,
+                    lldb::AccessType &default_accessibility, bool &is_a_class,
+                    lldb_private::ClangASTImporter::LayoutInfo &layout_info);
+
+  size_t
+  ParseChildParameters(const lldb_private::SymbolContext &sc,
+                       clang::DeclContext *containing_decl_ctx,
+                       const DWARFDIE &parent_die, bool skip_artificial,
+                       bool &is_static, bool &is_variadic,
+                       bool &has_template_params,
+                       std::vector<lldb_private::CompilerType> &function_args,
+                       std::vector<clang::ParmVarDecl *> &function_param_decls,
+                       unsigned &type_quals);
+
+  void ParseChildArrayInfo(const lldb_private::SymbolContext &sc,
+                           const DWARFDIE &parent_die, int64_t &first_index,
+                           std::vector<uint64_t> &element_orders,
+                           uint32_t &byte_stride, uint32_t &bit_stride);
+
+  size_t ParseChildEnumerators(const lldb_private::SymbolContext &sc,
+                               lldb_private::CompilerType &compiler_type,
+                               bool is_signed, uint32_t enumerator_byte_size,
+                               const DWARFDIE &parent_die);
+
+  lldb_private::Type *GetTypeForDIE(const DWARFDIE &die);
+
+  clang::Decl *GetClangDeclForDIE(const DWARFDIE &die);
+
+  clang::DeclContext *GetClangDeclContextForDIE(const DWARFDIE &die);
+
+  clang::DeclContext *GetClangDeclContextContainingDIE(const DWARFDIE &die,
+                                                       DWARFDIE *decl_ctx_die);
+
+  bool CopyUniqueClassMethodTypes(const DWARFDIE &src_class_die,
+                                  const DWARFDIE &dst_class_die,
+                                  lldb_private::Type *class_type,
+                                  DWARFDIECollection &failures);
+
+  clang::DeclContext *GetCachedClangDeclContextForDIE(const DWARFDIE &die);
+
+  void LinkDeclContextToDIE(clang::DeclContext *decl_ctx, const DWARFDIE &die);
+
+  void LinkDeclToDIE(clang::Decl *decl, const DWARFDIE &die);
+
+  lldb::TypeSP ParseTypeFromDWO(const DWARFDIE &die, lldb_private::Log *log);
+
+  //----------------------------------------------------------------------
+  // Return true if this type is a declaration to a type in an external
+  // module.
+  //----------------------------------------------------------------------
+  lldb::ModuleSP GetModuleForType(const DWARFDIE &die);
+
+  typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
+  typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *>
+      DIEToDeclContextMap;
+  // typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet>
+  // DeclContextToDIEMap;
+  typedef std::multimap<const clang::DeclContext *, const DWARFDIE>
+      DeclContextToDIEMap;
+  typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::Decl *>
+      DIEToDeclMap;
+  typedef llvm::DenseMap<const clang::Decl *, DIEPointerSet> DeclToDIEMap;
+
+  lldb_private::ClangASTContext &m_ast;
+  DIEToDeclMap m_die_to_decl;
+  DeclToDIEMap m_decl_to_die;
+  DIEToDeclContextMap m_die_to_decl_ctx;
+  DeclContextToDIEMap m_decl_ctx_to_die;
+  std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_ap;
 };
 
 #endif // SymbolFileDWARF_DWARFASTParserClang_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp Tue Sep  6 15:57:50 2016
@@ -11,11 +11,11 @@
 
 #include "DWARFASTParserGo.h"
 #include "DWARFCompileUnit.h"
+#include "DWARFDIE.h"
+#include "DWARFDIECollection.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
-#include "DWARFDIE.h"
-#include "DWARFDIECollection.h"
 #include "SymbolFileDWARF.h"
 #include "SymbolFileDWARFDebugMap.h"
 #include "UniqueDWARFASTType.h"
@@ -44,787 +44,732 @@
 
 using namespace lldb;
 using namespace lldb_private;
-DWARFASTParserGo::DWARFASTParserGo(GoASTContext &ast)
-    : m_ast(ast)
-{
-}
+DWARFASTParserGo::DWARFASTParserGo(GoASTContext &ast) : m_ast(ast) {}
 
-DWARFASTParserGo::~DWARFASTParserGo()
-{
-}
+DWARFASTParserGo::~DWARFASTParserGo() {}
 
-TypeSP
-DWARFASTParserGo::ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die, lldb_private::Log *log,
-                                     bool *type_is_new_ptr)
-{
-    TypeSP type_sp;
+TypeSP DWARFASTParserGo::ParseTypeFromDWARF(
+    const lldb_private::SymbolContext &sc, const DWARFDIE &die,
+    lldb_private::Log *log, bool *type_is_new_ptr) {
+  TypeSP type_sp;
 
-    if (type_is_new_ptr)
-        *type_is_new_ptr = false;
+  if (type_is_new_ptr)
+    *type_is_new_ptr = false;
 
-    if (die)
-    {
-        SymbolFileDWARF *dwarf = die.GetDWARF();
-        if (log)
-        {
-            dwarf->GetObjectFile()->GetModule()->LogMessage(
-                log, "DWARFASTParserGo::ParseTypeFromDWARF (die = 0x%8.8x) %s name = '%s')", die.GetOffset(),
-                DW_TAG_value_to_name(die.Tag()), die.GetName());
-        }
-
-        Type *type_ptr = dwarf->m_die_to_type.lookup(die.GetDIE());
-        TypeList *type_list = dwarf->GetTypeList();
-        if (type_ptr == NULL)
-        {
-            if (type_is_new_ptr)
-                *type_is_new_ptr = true;
-
-            const dw_tag_t tag = die.Tag();
-
-            bool is_forward_declaration = false;
-            DWARFAttributes attributes;
-            const char *type_name_cstr = NULL;
-            ConstString type_name_const_str;
-            Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
-            uint64_t byte_size = 0;
-            uint64_t go_kind = 0;
-            Declaration decl;
-
-            Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
-            CompilerType compiler_type;
-            DWARFFormValue form_value;
-
-            dw_attr_t attr;
-
-            switch (tag)
-            {
-                case DW_TAG_base_type:
-                case DW_TAG_pointer_type:
-                case DW_TAG_typedef:
-                case DW_TAG_unspecified_type:
-                {
-                    // Set a bit that lets us know that we are currently parsing this
-                    dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-                    const size_t num_attributes = die.GetAttributes(attributes);
-                    lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
-
-                    if (num_attributes > 0)
-                    {
-                        uint32_t i;
-                        for (i = 0; i < num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_name:
-                                        type_name_cstr = form_value.AsCString();
-                                        if (type_name_cstr)
-                                            type_name_const_str.SetCString(type_name_cstr);
-                                        break;
-                                    case DW_AT_byte_size:
-                                        byte_size = form_value.Unsigned();
-                                        break;
-                                    case DW_AT_encoding:
-                                        // = form_value.Unsigned();
-                                        break;
-                                    case DW_AT_type:
-                                        encoding_uid = form_value.Reference();
-                                        break;
-                                    case DW_AT_go_kind:
-                                        go_kind = form_value.Unsigned();
-                                        break;
-                                    default:
-                                        // Do we care about DW_AT_go_key or DW_AT_go_elem?
-                                        break;
-                                }
-                            }
-                        }
-                    }
-
-                    DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n", die.GetID(),
-                                 DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid);
-
-                    switch (tag)
-                    {
-                        default:
-                            break;
-
-                        case DW_TAG_unspecified_type:
-                            resolve_state = Type::eResolveStateFull;
-                            compiler_type = m_ast.CreateVoidType(type_name_const_str);
-                            break;
-
-                        case DW_TAG_base_type:
-                            resolve_state = Type::eResolveStateFull;
-                            compiler_type = m_ast.CreateBaseType(go_kind, type_name_const_str, byte_size);
-                            break;
-
-                        case DW_TAG_pointer_type:
-                            encoding_data_type = Type::eEncodingIsPointerUID;
-                            break;
-                        case DW_TAG_typedef:
-                            encoding_data_type = Type::eEncodingIsTypedefUID;
-                            CompilerType impl;
-                            Type *type = dwarf->ResolveTypeUID(encoding_uid);
-                            if (type)
-                            {
-                                if (go_kind == 0 && type->GetName() == type_name_const_str)
-                                {
-                                    // Go emits extra typedefs as a forward declaration. Ignore these.
-                                    dwarf->m_die_to_type[die.GetDIE()] = type;
-                                    return type->shared_from_this();
-                                }
-                                impl = type->GetForwardCompilerType();
-                                compiler_type = m_ast.CreateTypedefType (go_kind, type_name_const_str, impl);
-                            }
-                            break;
-                    }
-
-                    type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, byte_size,
-                                           NULL, encoding_uid, encoding_data_type, &decl, compiler_type, resolve_state));
+  if (die) {
+    SymbolFileDWARF *dwarf = die.GetDWARF();
+    if (log) {
+      dwarf->GetObjectFile()->GetModule()->LogMessage(
+          log, "DWARFASTParserGo::ParseTypeFromDWARF (die = 0x%8.8x) %s name = "
+               "'%s')",
+          die.GetOffset(), DW_TAG_value_to_name(die.Tag()), die.GetName());
+    }
 
-                    dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
-                }
+    Type *type_ptr = dwarf->m_die_to_type.lookup(die.GetDIE());
+    TypeList *type_list = dwarf->GetTypeList();
+    if (type_ptr == NULL) {
+      if (type_is_new_ptr)
+        *type_is_new_ptr = true;
+
+      const dw_tag_t tag = die.Tag();
+
+      bool is_forward_declaration = false;
+      DWARFAttributes attributes;
+      const char *type_name_cstr = NULL;
+      ConstString type_name_const_str;
+      Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
+      uint64_t byte_size = 0;
+      uint64_t go_kind = 0;
+      Declaration decl;
+
+      Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
+      CompilerType compiler_type;
+      DWARFFormValue form_value;
+
+      dw_attr_t attr;
+
+      switch (tag) {
+      case DW_TAG_base_type:
+      case DW_TAG_pointer_type:
+      case DW_TAG_typedef:
+      case DW_TAG_unspecified_type: {
+        // Set a bit that lets us know that we are currently parsing this
+        dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+        const size_t num_attributes = die.GetAttributes(attributes);
+        lldb::user_id_t encoding_uid = LLDB_INVALID_UID;
+
+        if (num_attributes > 0) {
+          uint32_t i;
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_name:
+                type_name_cstr = form_value.AsCString();
+                if (type_name_cstr)
+                  type_name_const_str.SetCString(type_name_cstr);
                 break;
-
-                case DW_TAG_structure_type:
-                {
-                    // Set a bit that lets us know that we are currently parsing this
-                    dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
-                    bool byte_size_valid = false;
-
-                    const size_t num_attributes = die.GetAttributes(attributes);
-                    if (num_attributes > 0)
-                    {
-                        uint32_t i;
-                        for (i = 0; i < num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_name:
-                                        type_name_cstr = form_value.AsCString();
-                                        type_name_const_str.SetCString(type_name_cstr);
-                                        break;
-
-                                    case DW_AT_byte_size:
-                                        byte_size = form_value.Unsigned();
-                                        byte_size_valid = true;
-                                        break;
-
-                                    case DW_AT_go_kind:
-                                        go_kind = form_value.Unsigned();
-                                        break;
-
-                                    // TODO: Should we use SLICETYPE's DW_AT_go_elem?
-                                    default:
-                                        break;
-                                }
-                            }
-                        }
-                    }
-
-                    // TODO(ribrdb): Do we need this?
-
-                    // UniqueDWARFASTType is large, so don't create a local variables on the
-                    // stack, put it on the heap. This function is often called recursively
-                    // and clang isn't good and sharing the stack space for variables in different blocks.
-                    std::unique_ptr<UniqueDWARFASTType> unique_ast_entry_ap(new UniqueDWARFASTType());
-
-                    // Only try and unique the type if it has a name.
-                    if (type_name_const_str &&
-                        dwarf->GetUniqueDWARFASTTypeMap().Find(type_name_const_str, die, decl,
-                                                               byte_size_valid ? byte_size : -1, *unique_ast_entry_ap))
-                    {
-                        // We have already parsed this type or from another
-                        // compile unit. GCC loves to use the "one definition
-                        // rule" which can result in multiple definitions
-                        // of the same class over and over in each compile
-                        // unit.
-                        type_sp = unique_ast_entry_ap->m_type_sp;
-                        if (type_sp)
-                        {
-                            dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
-                            return type_sp;
-                        }
-                    }
-
-                    DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
-                                 DW_TAG_value_to_name(tag), type_name_cstr);
-
-                    bool compiler_type_was_created = false;
-                    compiler_type.SetCompilerType(&m_ast, dwarf->m_forward_decl_die_to_clang_type.lookup(die.GetDIE()));
-                    if (!compiler_type)
-                    {
-                        compiler_type_was_created = true;
-                        compiler_type = m_ast.CreateStructType(go_kind, type_name_const_str, byte_size);
-                    }
-
-                    type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, byte_size,
-                                           NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, compiler_type,
-                                           Type::eResolveStateForward));
-
-                    // Add our type to the unique type map so we don't
-                    // end up creating many copies of the same type over
-                    // and over in the ASTContext for our module
-                    unique_ast_entry_ap->m_type_sp = type_sp;
-                    unique_ast_entry_ap->m_die = die;
-                    unique_ast_entry_ap->m_declaration = decl;
-                    unique_ast_entry_ap->m_byte_size = byte_size;
-                    dwarf->GetUniqueDWARFASTTypeMap().Insert(type_name_const_str, *unique_ast_entry_ap);
-
-                    if (!is_forward_declaration)
-                    {
-                        // Always start the definition for a class type so that
-                        // if the class has child classes or types that require
-                        // the class to be created for use as their decl contexts
-                        // the class will be ready to accept these child definitions.
-                        if (die.HasChildren() == false)
-                        {
-                            // No children for this struct/union/class, lets finish it
-                            m_ast.CompleteStructType(compiler_type);
-                        }
-                        else if (compiler_type_was_created)
-                        {
-                            // Leave this as a forward declaration until we need
-                            // to know the details of the type. lldb_private::Type
-                            // will automatically call the SymbolFile virtual function
-                            // "SymbolFileDWARF::CompleteType(Type *)"
-                            // When the definition needs to be defined.
-                            dwarf->m_forward_decl_die_to_clang_type[die.GetDIE()] = compiler_type.GetOpaqueQualType();
-                            dwarf->m_forward_decl_clang_type_to_die[compiler_type.GetOpaqueQualType()] = die.GetDIERef();
-                            // SetHasExternalStorage (compiler_type.GetOpaqueQualType(), true);
-                        }
-                    }
-                }
+              case DW_AT_byte_size:
+                byte_size = form_value.Unsigned();
                 break;
-
-                case DW_TAG_subprogram:
-                case DW_TAG_subroutine_type:
-                {
-                    // Set a bit that lets us know that we are currently parsing this
-                    dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-                    bool is_variadic = false;
-                    clang::StorageClass storage = clang::SC_None; //, Extern, Static, PrivateExtern
-
-                    const size_t num_attributes = die.GetAttributes(attributes);
-                    if (num_attributes > 0)
-                    {
-                        uint32_t i;
-                        for (i = 0; i < num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_name:
-                                        type_name_cstr = form_value.AsCString();
-                                        type_name_const_str.SetCString(type_name_cstr);
-                                        break;
-
-                                    case DW_AT_external:
-                                        if (form_value.Unsigned())
-                                        {
-                                            if (storage == clang::SC_None)
-                                                storage = clang::SC_Extern;
-                                            else
-                                                storage = clang::SC_PrivateExtern;
-                                        }
-                                        break;
-
-                                    case DW_AT_high_pc:
-                                    case DW_AT_low_pc:
-                                        break;
-                                }
-                            }
-                        }
-                    }
-
-                    DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
-                                 DW_TAG_value_to_name(tag), type_name_cstr);
-
-                    std::vector<CompilerType> function_param_types;
-
-                    // Parse the function children for the parameters
-
-                    if (die.HasChildren())
-                    {
-                        ParseChildParameters(sc, die, is_variadic, function_param_types);
-                    }
-
-                    // compiler_type will get the function prototype clang type after this call
-                    compiler_type = m_ast.CreateFunctionType(type_name_const_str, function_param_types.data(),
-                                                          function_param_types.size(), is_variadic);
-
-                    type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, 0, NULL,
-                                           LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, compiler_type,
-                                           Type::eResolveStateFull));
-                    assert(type_sp.get());
-                }
+              case DW_AT_encoding:
+                // = form_value.Unsigned();
                 break;
-
-                case DW_TAG_array_type:
-                {
-                    // Set a bit that lets us know that we are currently parsing this
-                    dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-                    lldb::user_id_t type_die_offset = DW_INVALID_OFFSET;
-                    int64_t first_index = 0;
-                    uint32_t byte_stride = 0;
-                    uint32_t bit_stride = 0;
-                    const size_t num_attributes = die.GetAttributes(attributes);
-
-                    if (num_attributes > 0)
-                    {
-                        uint32_t i;
-                        for (i = 0; i < num_attributes; ++i)
-                        {
-                            attr = attributes.AttributeAtIndex(i);
-                            if (attributes.ExtractFormValueAtIndex(i, form_value))
-                            {
-                                switch (attr)
-                                {
-                                    case DW_AT_name:
-                                        type_name_cstr = form_value.AsCString();
-                                        type_name_const_str.SetCString(type_name_cstr);
-                                        break;
-
-                                    case DW_AT_type:
-                                        type_die_offset = form_value.Reference();
-                                        break;
-                                    case DW_AT_byte_size:
-                                        break; // byte_size = form_value.Unsigned(); break;
-                                    case DW_AT_go_kind:
-                                        go_kind = form_value.Unsigned();
-                                        break;
-                                    default:
-                                        break;
-                                }
-                            }
-                        }
-
-                        DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
-                                     DW_TAG_value_to_name(tag), type_name_cstr);
-
-                        Type *element_type = dwarf->ResolveTypeUID(type_die_offset);
-
-                        if (element_type)
-                        {
-                            std::vector<uint64_t> element_orders;
-                            ParseChildArrayInfo(sc, die, first_index, element_orders, byte_stride, bit_stride);
-                            if (byte_stride == 0)
-                                byte_stride = element_type->GetByteSize();
-                            CompilerType array_element_type = element_type->GetForwardCompilerType();
-                            if (element_orders.size() > 0)
-                            {
-                                if (element_orders.size() > 1)
-                                    printf("golang: unsupported multi-dimensional array %s\n", type_name_cstr);
-                                compiler_type =
-                                    m_ast.CreateArrayType(type_name_const_str, array_element_type, element_orders[0]);
-                            }
-                            else
-                            {
-                                compiler_type = m_ast.CreateArrayType(type_name_const_str, array_element_type, 0);
-                            }
-                            type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
-                                                   byte_stride, NULL, type_die_offset, Type::eEncodingIsUID, &decl,
-                                                   compiler_type, Type::eResolveStateFull));
-                            type_sp->SetEncodingType(element_type);
-                        }
-                    }
-                }
+              case DW_AT_type:
+                encoding_uid = form_value.Reference();
+                break;
+              case DW_AT_go_kind:
+                go_kind = form_value.Unsigned();
+                break;
+              default:
+                // Do we care about DW_AT_go_key or DW_AT_go_elem?
                 break;
+              }
+            }
+          }
+        }
+
+        DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n",
+                     die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr,
+                     encoding_uid);
 
-                default:
-                    dwarf->GetObjectFile()->GetModule()->ReportError("{0x%8.8x}: unhandled type tag 0x%4.4x (%s), "
-                                                                     "please file a bug and attach the file at the "
-                                                                     "start of this error message",
-                                                                     die.GetOffset(), tag, DW_TAG_value_to_name(tag));
-                    break;
+        switch (tag) {
+        default:
+          break;
+
+        case DW_TAG_unspecified_type:
+          resolve_state = Type::eResolveStateFull;
+          compiler_type = m_ast.CreateVoidType(type_name_const_str);
+          break;
+
+        case DW_TAG_base_type:
+          resolve_state = Type::eResolveStateFull;
+          compiler_type =
+              m_ast.CreateBaseType(go_kind, type_name_const_str, byte_size);
+          break;
+
+        case DW_TAG_pointer_type:
+          encoding_data_type = Type::eEncodingIsPointerUID;
+          break;
+        case DW_TAG_typedef:
+          encoding_data_type = Type::eEncodingIsTypedefUID;
+          CompilerType impl;
+          Type *type = dwarf->ResolveTypeUID(encoding_uid);
+          if (type) {
+            if (go_kind == 0 && type->GetName() == type_name_const_str) {
+              // Go emits extra typedefs as a forward declaration. Ignore these.
+              dwarf->m_die_to_type[die.GetDIE()] = type;
+              return type->shared_from_this();
             }
+            impl = type->GetForwardCompilerType();
+            compiler_type =
+                m_ast.CreateTypedefType(go_kind, type_name_const_str, impl);
+          }
+          break;
+        }
 
-            if (type_sp.get())
-            {
-                DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die);
-                dw_tag_t sc_parent_tag = sc_parent_die.Tag();
-
-                SymbolContextScope *symbol_context_scope = NULL;
-                if (sc_parent_tag == DW_TAG_compile_unit)
-                {
-                    symbol_context_scope = sc.comp_unit;
-                }
-                else if (sc.function != NULL && sc_parent_die)
-                {
-                    symbol_context_scope =
-                        sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
-                    if (symbol_context_scope == NULL)
-                        symbol_context_scope = sc.function;
-                }
+        type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
+                               byte_size, NULL, encoding_uid,
+                               encoding_data_type, &decl, compiler_type,
+                               resolve_state));
+
+        dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
+      } break;
+
+      case DW_TAG_structure_type: {
+        // Set a bit that lets us know that we are currently parsing this
+        dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+        bool byte_size_valid = false;
+
+        const size_t num_attributes = die.GetAttributes(attributes);
+        if (num_attributes > 0) {
+          uint32_t i;
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_name:
+                type_name_cstr = form_value.AsCString();
+                type_name_const_str.SetCString(type_name_cstr);
+                break;
 
-                if (symbol_context_scope != NULL)
-                {
-                    type_sp->SetSymbolContextScope(symbol_context_scope);
-                }
+              case DW_AT_byte_size:
+                byte_size = form_value.Unsigned();
+                byte_size_valid = true;
+                break;
 
-                // We are ready to put this type into the uniqued list up at the module level
-                type_list->Insert(type_sp);
+              case DW_AT_go_kind:
+                go_kind = form_value.Unsigned();
+                break;
 
-                dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
+              // TODO: Should we use SLICETYPE's DW_AT_go_elem?
+              default:
+                break;
+              }
             }
+          }
         }
-        else if (type_ptr != DIE_IS_BEING_PARSED)
-        {
-            type_sp = type_ptr->shared_from_this();
+
+        // TODO(ribrdb): Do we need this?
+
+        // UniqueDWARFASTType is large, so don't create a local variables on the
+        // stack, put it on the heap. This function is often called recursively
+        // and clang isn't good and sharing the stack space for variables in
+        // different blocks.
+        std::unique_ptr<UniqueDWARFASTType> unique_ast_entry_ap(
+            new UniqueDWARFASTType());
+
+        // Only try and unique the type if it has a name.
+        if (type_name_const_str &&
+            dwarf->GetUniqueDWARFASTTypeMap().Find(
+                type_name_const_str, die, decl,
+                byte_size_valid ? byte_size : -1, *unique_ast_entry_ap)) {
+          // We have already parsed this type or from another
+          // compile unit. GCC loves to use the "one definition
+          // rule" which can result in multiple definitions
+          // of the same class over and over in each compile
+          // unit.
+          type_sp = unique_ast_entry_ap->m_type_sp;
+          if (type_sp) {
+            dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
+            return type_sp;
+          }
         }
-    }
-    return type_sp;
-}
 
-size_t
-DWARFASTParserGo::ParseChildParameters(const SymbolContext &sc,
+        DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+                     DW_TAG_value_to_name(tag), type_name_cstr);
 
-                                       const DWARFDIE &parent_die, bool &is_variadic,
-                                       std::vector<CompilerType> &function_param_types)
-{
-    if (!parent_die)
-        return 0;
+        bool compiler_type_was_created = false;
+        compiler_type.SetCompilerType(
+            &m_ast,
+            dwarf->m_forward_decl_die_to_clang_type.lookup(die.GetDIE()));
+        if (!compiler_type) {
+          compiler_type_was_created = true;
+          compiler_type =
+              m_ast.CreateStructType(go_kind, type_name_const_str, byte_size);
+        }
 
-    size_t arg_idx = 0;
-    for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
-    {
+        type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
+                               byte_size, NULL, LLDB_INVALID_UID,
+                               Type::eEncodingIsUID, &decl, compiler_type,
+                               Type::eResolveStateForward));
+
+        // Add our type to the unique type map so we don't
+        // end up creating many copies of the same type over
+        // and over in the ASTContext for our module
+        unique_ast_entry_ap->m_type_sp = type_sp;
+        unique_ast_entry_ap->m_die = die;
+        unique_ast_entry_ap->m_declaration = decl;
+        unique_ast_entry_ap->m_byte_size = byte_size;
+        dwarf->GetUniqueDWARFASTTypeMap().Insert(type_name_const_str,
+                                                 *unique_ast_entry_ap);
+
+        if (!is_forward_declaration) {
+          // Always start the definition for a class type so that
+          // if the class has child classes or types that require
+          // the class to be created for use as their decl contexts
+          // the class will be ready to accept these child definitions.
+          if (die.HasChildren() == false) {
+            // No children for this struct/union/class, lets finish it
+            m_ast.CompleteStructType(compiler_type);
+          } else if (compiler_type_was_created) {
+            // Leave this as a forward declaration until we need
+            // to know the details of the type. lldb_private::Type
+            // will automatically call the SymbolFile virtual function
+            // "SymbolFileDWARF::CompleteType(Type *)"
+            // When the definition needs to be defined.
+            dwarf->m_forward_decl_die_to_clang_type[die.GetDIE()] =
+                compiler_type.GetOpaqueQualType();
+            dwarf->m_forward_decl_clang_type_to_die[compiler_type
+                                                        .GetOpaqueQualType()] =
+                die.GetDIERef();
+            // SetHasExternalStorage (compiler_type.GetOpaqueQualType(), true);
+          }
+        }
+      } break;
+
+      case DW_TAG_subprogram:
+      case DW_TAG_subroutine_type: {
+        // Set a bit that lets us know that we are currently parsing this
+        dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+        bool is_variadic = false;
+        clang::StorageClass storage =
+            clang::SC_None; //, Extern, Static, PrivateExtern
+
+        const size_t num_attributes = die.GetAttributes(attributes);
+        if (num_attributes > 0) {
+          uint32_t i;
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_name:
+                type_name_cstr = form_value.AsCString();
+                type_name_const_str.SetCString(type_name_cstr);
+                break;
 
-        dw_tag_t tag = die.Tag();
-        switch (tag)
-        {
-            case DW_TAG_formal_parameter:
-            {
-                DWARFAttributes attributes;
-                const size_t num_attributes = die.GetAttributes(attributes);
-                if (num_attributes > 0)
-                {
-                    Declaration decl;
-                    DWARFFormValue param_type_die_offset;
-
-                    uint32_t i;
-                    for (i = 0; i < num_attributes; ++i)
-                    {
-                        const dw_attr_t attr = attributes.AttributeAtIndex(i);
-                        DWARFFormValue form_value;
-                        if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        {
-                            switch (attr)
-                            {
-                                case DW_AT_name:
-                                    // = form_value.AsCString();
-                                    break;
-                                case DW_AT_type:
-                                    param_type_die_offset = form_value;
-                                    break;
-                                case DW_AT_location:
-                                //                          if (form_value.BlockData())
-                                //                          {
-                                //                              const DWARFDataExtractor& debug_info_data =
-                                //                              debug_info();
-                                //                              uint32_t block_length = form_value.Unsigned();
-                                //                              DWARFDataExtractor location(debug_info_data,
-                                //                              form_value.BlockData() - debug_info_data.GetDataStart(),
-                                //                              block_length);
-                                //                          }
-                                //                          else
-                                //                          {
-                                //                          }
-                                //                          break;
-                                default:
-                                    break;
-                            }
-                        }
-                    }
-
-                    Type *type = parent_die.ResolveTypeUID(DIERef(param_type_die_offset));
-                    if (type)
-                    {
-                        function_param_types.push_back(type->GetForwardCompilerType());
-                    }
+              case DW_AT_external:
+                if (form_value.Unsigned()) {
+                  if (storage == clang::SC_None)
+                    storage = clang::SC_Extern;
+                  else
+                    storage = clang::SC_PrivateExtern;
                 }
-                arg_idx++;
+                break;
+
+              case DW_AT_high_pc:
+              case DW_AT_low_pc:
+                break;
+              }
             }
-            break;
+          }
+        }
+
+        DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+                     DW_TAG_value_to_name(tag), type_name_cstr);
+
+        std::vector<CompilerType> function_param_types;
+
+        // Parse the function children for the parameters
+
+        if (die.HasChildren()) {
+          ParseChildParameters(sc, die, is_variadic, function_param_types);
+        }
 
-            case DW_TAG_unspecified_parameters:
-                is_variadic = true;
+        // compiler_type will get the function prototype clang type after this
+        // call
+        compiler_type = m_ast.CreateFunctionType(
+            type_name_const_str, function_param_types.data(),
+            function_param_types.size(), is_variadic);
+
+        type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, 0, NULL,
+                               LLDB_INVALID_UID, Type::eEncodingIsUID, &decl,
+                               compiler_type, Type::eResolveStateFull));
+        assert(type_sp.get());
+      } break;
+
+      case DW_TAG_array_type: {
+        // Set a bit that lets us know that we are currently parsing this
+        dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+        lldb::user_id_t type_die_offset = DW_INVALID_OFFSET;
+        int64_t first_index = 0;
+        uint32_t byte_stride = 0;
+        uint32_t bit_stride = 0;
+        const size_t num_attributes = die.GetAttributes(attributes);
+
+        if (num_attributes > 0) {
+          uint32_t i;
+          for (i = 0; i < num_attributes; ++i) {
+            attr = attributes.AttributeAtIndex(i);
+            if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+              switch (attr) {
+              case DW_AT_name:
+                type_name_cstr = form_value.AsCString();
+                type_name_const_str.SetCString(type_name_cstr);
                 break;
 
-            default:
+              case DW_AT_type:
+                type_die_offset = form_value.Reference();
+                break;
+              case DW_AT_byte_size:
+                break; // byte_size = form_value.Unsigned(); break;
+              case DW_AT_go_kind:
+                go_kind = form_value.Unsigned();
+                break;
+              default:
                 break;
+              }
+            }
+          }
+
+          DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+                       DW_TAG_value_to_name(tag), type_name_cstr);
+
+          Type *element_type = dwarf->ResolveTypeUID(type_die_offset);
+
+          if (element_type) {
+            std::vector<uint64_t> element_orders;
+            ParseChildArrayInfo(sc, die, first_index, element_orders,
+                                byte_stride, bit_stride);
+            if (byte_stride == 0)
+              byte_stride = element_type->GetByteSize();
+            CompilerType array_element_type =
+                element_type->GetForwardCompilerType();
+            if (element_orders.size() > 0) {
+              if (element_orders.size() > 1)
+                printf("golang: unsupported multi-dimensional array %s\n",
+                       type_name_cstr);
+              compiler_type = m_ast.CreateArrayType(
+                  type_name_const_str, array_element_type, element_orders[0]);
+            } else {
+              compiler_type = m_ast.CreateArrayType(type_name_const_str,
+                                                    array_element_type, 0);
+            }
+            type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
+                                   byte_stride, NULL, type_die_offset,
+                                   Type::eEncodingIsUID, &decl, compiler_type,
+                                   Type::eResolveStateFull));
+            type_sp->SetEncodingType(element_type);
+          }
+        }
+      } break;
+
+      default:
+        dwarf->GetObjectFile()->GetModule()->ReportError(
+            "{0x%8.8x}: unhandled type tag 0x%4.4x (%s), "
+            "please file a bug and attach the file at the "
+            "start of this error message",
+            die.GetOffset(), tag, DW_TAG_value_to_name(tag));
+        break;
+      }
+
+      if (type_sp.get()) {
+        DWARFDIE sc_parent_die =
+            SymbolFileDWARF::GetParentSymbolContextDIE(die);
+        dw_tag_t sc_parent_tag = sc_parent_die.Tag();
+
+        SymbolContextScope *symbol_context_scope = NULL;
+        if (sc_parent_tag == DW_TAG_compile_unit) {
+          symbol_context_scope = sc.comp_unit;
+        } else if (sc.function != NULL && sc_parent_die) {
+          symbol_context_scope =
+              sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
+          if (symbol_context_scope == NULL)
+            symbol_context_scope = sc.function;
+        }
+
+        if (symbol_context_scope != NULL) {
+          type_sp->SetSymbolContextScope(symbol_context_scope);
         }
+
+        // We are ready to put this type into the uniqued list up at the module
+        // level
+        type_list->Insert(type_sp);
+
+        dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
+      }
+    } else if (type_ptr != DIE_IS_BEING_PARSED) {
+      type_sp = type_ptr->shared_from_this();
     }
-    return arg_idx;
+  }
+  return type_sp;
 }
 
-void
-DWARFASTParserGo::ParseChildArrayInfo(const SymbolContext &sc, const DWARFDIE &parent_die, int64_t &first_index,
-                                      std::vector<uint64_t> &element_orders, uint32_t &byte_stride,
-                                      uint32_t &bit_stride)
-{
-    if (!parent_die)
-        return;
-
-    for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
-    {
-        const dw_tag_t tag = die.Tag();
-        switch (tag)
-        {
-            case DW_TAG_subrange_type:
-            {
-                DWARFAttributes attributes;
-                const size_t num_child_attributes = die.GetAttributes(attributes);
-                if (num_child_attributes > 0)
-                {
-                    uint64_t num_elements = 0;
-                    uint32_t i;
-                    for (i = 0; i < num_child_attributes; ++i)
-                    {
-                        const dw_attr_t attr = attributes.AttributeAtIndex(i);
-                        DWARFFormValue form_value;
-                        if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        {
-                            switch (attr)
-                            {
-                                case DW_AT_count:
-                                    num_elements = form_value.Unsigned();
-                                    break;
-
-                                default:
-                                case DW_AT_type:
-                                    break;
-                            }
-                        }
-                    }
+size_t DWARFASTParserGo::ParseChildParameters(
+    const SymbolContext &sc,
 
-                    element_orders.push_back(num_elements);
-                }
+    const DWARFDIE &parent_die, bool &is_variadic,
+    std::vector<CompilerType> &function_param_types) {
+  if (!parent_die)
+    return 0;
+
+  size_t arg_idx = 0;
+  for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
+       die = die.GetSibling()) {
+
+    dw_tag_t tag = die.Tag();
+    switch (tag) {
+    case DW_TAG_formal_parameter: {
+      DWARFAttributes attributes;
+      const size_t num_attributes = die.GetAttributes(attributes);
+      if (num_attributes > 0) {
+        Declaration decl;
+        DWARFFormValue param_type_die_offset;
+
+        uint32_t i;
+        for (i = 0; i < num_attributes; ++i) {
+          const dw_attr_t attr = attributes.AttributeAtIndex(i);
+          DWARFFormValue form_value;
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            switch (attr) {
+            case DW_AT_name:
+              // = form_value.AsCString();
+              break;
+            case DW_AT_type:
+              param_type_die_offset = form_value;
+              break;
+            case DW_AT_location:
+            //                          if (form_value.BlockData())
+            //                          {
+            //                              const DWARFDataExtractor&
+            //                              debug_info_data =
+            //                              debug_info();
+            //                              uint32_t block_length =
+            //                              form_value.Unsigned();
+            //                              DWARFDataExtractor
+            //                              location(debug_info_data,
+            //                              form_value.BlockData() -
+            //                              debug_info_data.GetDataStart(),
+            //                              block_length);
+            //                          }
+            //                          else
+            //                          {
+            //                          }
+            //                          break;
+            default:
+              break;
             }
-            break;
+          }
+        }
+
+        Type *type = parent_die.ResolveTypeUID(DIERef(param_type_die_offset));
+        if (type) {
+          function_param_types.push_back(type->GetForwardCompilerType());
         }
+      }
+      arg_idx++;
+    } break;
+
+    case DW_TAG_unspecified_parameters:
+      is_variadic = true;
+      break;
+
+    default:
+      break;
     }
+  }
+  return arg_idx;
 }
 
-bool
-DWARFASTParserGo::CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type, CompilerType &compiler_type)
-{
-    if (!die)
-        return false;
+void DWARFASTParserGo::ParseChildArrayInfo(
+    const SymbolContext &sc, const DWARFDIE &parent_die, int64_t &first_index,
+    std::vector<uint64_t> &element_orders, uint32_t &byte_stride,
+    uint32_t &bit_stride) {
+  if (!parent_die)
+    return;
 
+  for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
+       die = die.GetSibling()) {
     const dw_tag_t tag = die.Tag();
+    switch (tag) {
+    case DW_TAG_subrange_type: {
+      DWARFAttributes attributes;
+      const size_t num_child_attributes = die.GetAttributes(attributes);
+      if (num_child_attributes > 0) {
+        uint64_t num_elements = 0;
+        uint32_t i;
+        for (i = 0; i < num_child_attributes; ++i) {
+          const dw_attr_t attr = attributes.AttributeAtIndex(i);
+          DWARFFormValue form_value;
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            switch (attr) {
+            case DW_AT_count:
+              num_elements = form_value.Unsigned();
+              break;
 
-    SymbolFileDWARF *dwarf = die.GetDWARF();
-    Log *log = nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
-    if (log)
-        dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace(
-            log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...", die.GetID(),
-            DW_TAG_value_to_name(tag), type->GetName().AsCString());
-    assert(compiler_type);
-    DWARFAttributes attributes;
-
-    switch (tag)
-    {
-        case DW_TAG_structure_type:
-        {
-            {
-                if (die.HasChildren())
-                {
-                    SymbolContext sc(die.GetLLDBCompileUnit());
-
-                    ParseChildMembers(sc, die, compiler_type);
-                }
+            default:
+            case DW_AT_type:
+              break;
             }
-            m_ast.CompleteStructType(compiler_type);
-            return (bool)compiler_type;
+          }
         }
 
-        default:
-            assert(false && "not a forward go type decl!");
-            break;
+        element_orders.push_back(num_elements);
+      }
+    } break;
     }
+  }
+}
 
+bool DWARFASTParserGo::CompleteTypeFromDWARF(const DWARFDIE &die,
+                                             lldb_private::Type *type,
+                                             CompilerType &compiler_type) {
+  if (!die)
     return false;
-}
 
-size_t
-DWARFASTParserGo::ParseChildMembers(const SymbolContext &sc, const DWARFDIE &parent_die, CompilerType &class_compiler_type)
-{
-    size_t count = 0;
-    uint32_t member_idx = 0;
-
-    ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
-    GoASTContext *ast = llvm::dyn_cast_or_null<GoASTContext>(class_compiler_type.GetTypeSystem());
-    if (ast == nullptr)
-        return 0;
+  const dw_tag_t tag = die.Tag();
+
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+  Log *log =
+      nullptr; // (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
+  if (log)
+    dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace(
+        log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...",
+        die.GetID(), DW_TAG_value_to_name(tag), type->GetName().AsCString());
+  assert(compiler_type);
+  DWARFAttributes attributes;
 
-    for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
+  switch (tag) {
+  case DW_TAG_structure_type: {
     {
-        dw_tag_t tag = die.Tag();
+      if (die.HasChildren()) {
+        SymbolContext sc(die.GetLLDBCompileUnit());
 
-        switch (tag)
-        {
-            case DW_TAG_member:
-            {
-                DWARFAttributes attributes;
-                const size_t num_attributes = die.GetAttributes(attributes);
-                if (num_attributes > 0)
-                {
-                    Declaration decl;
-                    const char *name = NULL;
-
-                    DWARFFormValue encoding_uid;
-                    uint32_t member_byte_offset = UINT32_MAX;
-                    uint32_t i;
-                    for (i = 0; i < num_attributes; ++i)
-                    {
-                        const dw_attr_t attr = attributes.AttributeAtIndex(i);
-                        DWARFFormValue form_value;
-                        if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        {
-                            switch (attr)
-                            {
-                                case DW_AT_name:
-                                    name = form_value.AsCString();
-                                    break;
-                                case DW_AT_type:
-                                    encoding_uid = form_value;
-                                    break;
-                                case DW_AT_data_member_location:
-                                    if (form_value.BlockData())
-                                    {
-                                        Value initialValue(0);
-                                        Value memberOffset(0);
-                                        const DWARFDataExtractor &debug_info_data =
-                                            die.GetDWARF()->get_debug_info_data();
-                                        uint32_t block_length = form_value.Unsigned();
-                                        uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
-                                        if (DWARFExpression::Evaluate(NULL, // ExecutionContext *
-                                                                      NULL, // ClangExpressionVariableList *
-                                                                      NULL, // ClangExpressionDeclMap *
-                                                                      NULL, // RegisterContext *
-                                                                      module_sp, debug_info_data, die.GetCU(),
-                                                                      block_offset, block_length, eRegisterKindDWARF,
-                                                                      &initialValue, NULL, memberOffset, NULL))
-                                        {
-                                            member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
-                                        }
-                                    }
-                                    else
-                                    {
-                                        // With DWARF 3 and later, if the value is an integer constant,
-                                        // this form value is the offset in bytes from the beginning
-                                        // of the containing entity.
-                                        member_byte_offset = form_value.Unsigned();
-                                    }
-                                    break;
-
-                                default:
-                                    break;
-                            }
-                        }
-                    }
-
-                    Type *member_type = die.ResolveTypeUID(DIERef(encoding_uid));
-                    if (member_type)
-                    {
-                        CompilerType member_go_type = member_type->GetFullCompilerType();
-                        ConstString name_const_str(name);
-                        m_ast.AddFieldToStruct(class_compiler_type, name_const_str, member_go_type, member_byte_offset);
-                    }
-                }
-                ++member_idx;
-            }
-            break;
+        ParseChildMembers(sc, die, compiler_type);
+      }
+    }
+    m_ast.CompleteStructType(compiler_type);
+    return (bool)compiler_type;
+  }
+
+  default:
+    assert(false && "not a forward go type decl!");
+    break;
+  }
+
+  return false;
+}
+
+size_t DWARFASTParserGo::ParseChildMembers(const SymbolContext &sc,
+                                           const DWARFDIE &parent_die,
+                                           CompilerType &class_compiler_type) {
+  size_t count = 0;
+  uint32_t member_idx = 0;
+
+  ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
+  GoASTContext *ast =
+      llvm::dyn_cast_or_null<GoASTContext>(class_compiler_type.GetTypeSystem());
+  if (ast == nullptr)
+    return 0;
+
+  for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
+       die = die.GetSibling()) {
+    dw_tag_t tag = die.Tag();
+
+    switch (tag) {
+    case DW_TAG_member: {
+      DWARFAttributes attributes;
+      const size_t num_attributes = die.GetAttributes(attributes);
+      if (num_attributes > 0) {
+        Declaration decl;
+        const char *name = NULL;
+
+        DWARFFormValue encoding_uid;
+        uint32_t member_byte_offset = UINT32_MAX;
+        uint32_t i;
+        for (i = 0; i < num_attributes; ++i) {
+          const dw_attr_t attr = attributes.AttributeAtIndex(i);
+          DWARFFormValue form_value;
+          if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+            switch (attr) {
+            case DW_AT_name:
+              name = form_value.AsCString();
+              break;
+            case DW_AT_type:
+              encoding_uid = form_value;
+              break;
+            case DW_AT_data_member_location:
+              if (form_value.BlockData()) {
+                Value initialValue(0);
+                Value memberOffset(0);
+                const DWARFDataExtractor &debug_info_data =
+                    die.GetDWARF()->get_debug_info_data();
+                uint32_t block_length = form_value.Unsigned();
+                uint32_t block_offset =
+                    form_value.BlockData() - debug_info_data.GetDataStart();
+                if (DWARFExpression::Evaluate(
+                        NULL, // ExecutionContext *
+                        NULL, // ClangExpressionVariableList *
+                        NULL, // ClangExpressionDeclMap *
+                        NULL, // RegisterContext *
+                        module_sp, debug_info_data, die.GetCU(), block_offset,
+                        block_length, eRegisterKindDWARF, &initialValue, NULL,
+                        memberOffset, NULL)) {
+                  member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
+                }
+              } else {
+                // With DWARF 3 and later, if the value is an integer constant,
+                // this form value is the offset in bytes from the beginning
+                // of the containing entity.
+                member_byte_offset = form_value.Unsigned();
+              }
+              break;
 
             default:
-                break;
+              break;
+            }
+          }
+        }
+
+        Type *member_type = die.ResolveTypeUID(DIERef(encoding_uid));
+        if (member_type) {
+          CompilerType member_go_type = member_type->GetFullCompilerType();
+          ConstString name_const_str(name);
+          m_ast.AddFieldToStruct(class_compiler_type, name_const_str,
+                                 member_go_type, member_byte_offset);
         }
+      }
+      ++member_idx;
+    } break;
+
+    default:
+      break;
     }
+  }
 
-    return count;
+  return count;
 }
 
-Function *
-DWARFASTParserGo::ParseFunctionFromDWARF(const SymbolContext &sc, const DWARFDIE &die)
-{
-    DWARFRangeList func_ranges;
-    const char *name = NULL;
-    const char *mangled = NULL;
-    int decl_file = 0;
-    int decl_line = 0;
-    int decl_column = 0;
-    int call_file = 0;
-    int call_line = 0;
-    int call_column = 0;
-    DWARFExpression frame_base(die.GetCU());
+Function *DWARFASTParserGo::ParseFunctionFromDWARF(const SymbolContext &sc,
+                                                   const DWARFDIE &die) {
+  DWARFRangeList func_ranges;
+  const char *name = NULL;
+  const char *mangled = NULL;
+  int decl_file = 0;
+  int decl_line = 0;
+  int decl_column = 0;
+  int call_file = 0;
+  int call_line = 0;
+  int call_column = 0;
+  DWARFExpression frame_base(die.GetCU());
+
+  assert(die.Tag() == DW_TAG_subprogram);
 
-    assert(die.Tag() == DW_TAG_subprogram);
+  if (die.Tag() != DW_TAG_subprogram)
+    return NULL;
 
-    if (die.Tag() != DW_TAG_subprogram)
-        return NULL;
+  if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line,
+                               decl_column, call_file, call_line, call_column,
+                               &frame_base)) {
+    // Union of all ranges in the function DIE (if the function is
+    // discontiguous)
+    AddressRange func_range;
+    lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
+    lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
+    if (lowest_func_addr != LLDB_INVALID_ADDRESS &&
+        lowest_func_addr <= highest_func_addr) {
+      ModuleSP module_sp(die.GetModule());
+      func_range.GetBaseAddress().ResolveAddressUsingFileSections(
+          lowest_func_addr, module_sp->GetSectionList());
+      if (func_range.GetBaseAddress().IsValid())
+        func_range.SetByteSize(highest_func_addr - lowest_func_addr);
+    }
 
-    if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line, decl_column, call_file, call_line,
-                                 call_column, &frame_base))
-    {
-        // Union of all ranges in the function DIE (if the function is discontiguous)
-        AddressRange func_range;
-        lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
-        lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
-        if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr)
-        {
-            ModuleSP module_sp(die.GetModule());
-            func_range.GetBaseAddress().ResolveAddressUsingFileSections(lowest_func_addr, module_sp->GetSectionList());
-            if (func_range.GetBaseAddress().IsValid())
-                func_range.SetByteSize(highest_func_addr - lowest_func_addr);
-        }
-
-        if (func_range.GetBaseAddress().IsValid())
-        {
-            Mangled func_name;
-            func_name.SetValue(ConstString(name), false);
-
-            FunctionSP func_sp;
-            std::unique_ptr<Declaration> decl_ap;
-            if (decl_file != 0 || decl_line != 0 || decl_column != 0)
-                decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line,
-                                              decl_column));
-
-            SymbolFileDWARF *dwarf = die.GetDWARF();
-            // Supply the type _only_ if it has already been parsed
-            Type *func_type = dwarf->m_die_to_type.lookup(die.GetDIE());
-
-            assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
-
-            if (dwarf->FixupAddress(func_range.GetBaseAddress()))
-            {
-                const user_id_t func_user_id = die.GetID();
-                func_sp.reset(new Function(sc.comp_unit,
-                                           func_user_id, // UserID is the DIE offset
-                                           func_user_id,
-                                           func_name,
-                                           func_type,
-                                           func_range)); // first address range
-
-                if (func_sp.get() != NULL)
-                {
-                    if (frame_base.IsValid())
-                        func_sp->GetFrameBaseExpression() = frame_base;
-                    sc.comp_unit->AddFunction(func_sp);
-                    return func_sp.get();
-                }
-            }
+    if (func_range.GetBaseAddress().IsValid()) {
+      Mangled func_name;
+      func_name.SetValue(ConstString(name), false);
+
+      FunctionSP func_sp;
+      std::unique_ptr<Declaration> decl_ap;
+      if (decl_file != 0 || decl_line != 0 || decl_column != 0)
+        decl_ap.reset(new Declaration(
+            sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file),
+            decl_line, decl_column));
+
+      SymbolFileDWARF *dwarf = die.GetDWARF();
+      // Supply the type _only_ if it has already been parsed
+      Type *func_type = dwarf->m_die_to_type.lookup(die.GetDIE());
+
+      assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
+
+      if (dwarf->FixupAddress(func_range.GetBaseAddress())) {
+        const user_id_t func_user_id = die.GetID();
+        func_sp.reset(new Function(sc.comp_unit,
+                                   func_user_id, // UserID is the DIE offset
+                                   func_user_id, func_name, func_type,
+                                   func_range)); // first address range
+
+        if (func_sp.get() != NULL) {
+          if (frame_base.IsValid())
+            func_sp->GetFrameBaseExpression() = frame_base;
+          sc.comp_unit->AddFunction(func_sp);
+          return func_sp.get();
         }
+      }
     }
-    return NULL;
+  }
+  return NULL;
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h Tue Sep  6 15:57:50 2016
@@ -18,67 +18,67 @@
 #include "llvm/ADT/SmallVector.h"
 
 // Project includes
-#include "lldb/Core/PluginInterface.h"
-#include "lldb/Symbol/GoASTContext.h"
-#include "DWARFDefines.h"
 #include "DWARFASTParser.h"
 #include "DWARFDIE.h"
+#include "DWARFDefines.h"
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/GoASTContext.h"
 
 class DWARFDebugInfoEntry;
 class DWARFDIECollection;
 
-class DWARFASTParserGo : public DWARFASTParser
-{
+class DWARFASTParserGo : public DWARFASTParser {
 public:
-    DWARFASTParserGo(lldb_private::GoASTContext &ast);
+  DWARFASTParserGo(lldb_private::GoASTContext &ast);
 
-    ~DWARFASTParserGo() override;
+  ~DWARFASTParserGo() override;
 
-    lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die, lldb_private::Log *log,
-                                    bool *type_is_new_ptr) override;
-
-    lldb_private::Function *
-    ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc,
-                           const DWARFDIE &die) override;
-
-    bool
-    CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
-                          lldb_private::CompilerType &go_type) override;
-
-    lldb_private::CompilerDeclContext
-    GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override
-    {
-        return lldb_private::CompilerDeclContext();
-    }
-
-    lldb_private::CompilerDeclContext
-    GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override
-    {
-        return lldb_private::CompilerDeclContext();
-    }
-
-    lldb_private::CompilerDecl
-    GetDeclForUIDFromDWARF (const DWARFDIE &die) override
-    {
-        return lldb_private::CompilerDecl();
-    }
-
-    std::vector<DWARFDIE>
-    GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) override
-    {
-        return std::vector<DWARFDIE>();
-    }
+  lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
+                                  const DWARFDIE &die, lldb_private::Log *log,
+                                  bool *type_is_new_ptr) override;
+
+  lldb_private::Function *
+  ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc,
+                         const DWARFDIE &die) override;
+
+  bool CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
+                             lldb_private::CompilerType &go_type) override;
+
+  lldb_private::CompilerDeclContext
+  GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override {
+    return lldb_private::CompilerDeclContext();
+  }
+
+  lldb_private::CompilerDeclContext
+  GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override {
+    return lldb_private::CompilerDeclContext();
+  }
+
+  lldb_private::CompilerDecl
+  GetDeclForUIDFromDWARF(const DWARFDIE &die) override {
+    return lldb_private::CompilerDecl();
+  }
+
+  std::vector<DWARFDIE> GetDIEForDeclContext(
+      lldb_private::CompilerDeclContext decl_context) override {
+    return std::vector<DWARFDIE>();
+  }
 
 private:
-    size_t ParseChildParameters(const lldb_private::SymbolContext &sc, const DWARFDIE &parent_die, bool &is_variadic,
-                                std::vector<lldb_private::CompilerType> &function_param_types);
-    void ParseChildArrayInfo(const lldb_private::SymbolContext &sc, const DWARFDIE &parent_die, int64_t &first_index,
-                             std::vector<uint64_t> &element_orders, uint32_t &byte_stride, uint32_t &bit_stride);
-
-    size_t ParseChildMembers(const lldb_private::SymbolContext &sc, const DWARFDIE &die,
-                             lldb_private::CompilerType &class_compiler_type);
+  size_t ParseChildParameters(
+      const lldb_private::SymbolContext &sc, const DWARFDIE &parent_die,
+      bool &is_variadic,
+      std::vector<lldb_private::CompilerType> &function_param_types);
+  void ParseChildArrayInfo(const lldb_private::SymbolContext &sc,
+                           const DWARFDIE &parent_die, int64_t &first_index,
+                           std::vector<uint64_t> &element_orders,
+                           uint32_t &byte_stride, uint32_t &bit_stride);
+
+  size_t ParseChildMembers(const lldb_private::SymbolContext &sc,
+                           const DWARFDIE &die,
+                           lldb_private::CompilerType &class_compiler_type);
 
-    lldb_private::GoASTContext &m_ast;
+  lldb_private::GoASTContext &m_ast;
 };
 
 #endif // SymbolFileDWARF_DWARFASTParserGo_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp Tue Sep  6 15:57:50 2016
@@ -23,533 +23,487 @@
 using namespace lldb;
 using namespace lldb_private;
 
-DWARFASTParserJava::DWARFASTParserJava(JavaASTContext &ast) : m_ast(ast)
-{
-}
+DWARFASTParserJava::DWARFASTParserJava(JavaASTContext &ast) : m_ast(ast) {}
+
+DWARFASTParserJava::~DWARFASTParserJava() {}
 
-DWARFASTParserJava::~DWARFASTParserJava()
-{
+TypeSP DWARFASTParserJava::ParseBaseTypeFromDIE(const DWARFDIE &die) {
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+  dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+  ConstString type_name;
+  uint64_t byte_size = 0;
+
+  DWARFAttributes attributes;
+  const size_t num_attributes = die.GetAttributes(attributes);
+  for (uint32_t i = 0; i < num_attributes; ++i) {
+    DWARFFormValue form_value;
+    dw_attr_t attr = attributes.AttributeAtIndex(i);
+    if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+      switch (attr) {
+      case DW_AT_name:
+        type_name.SetCString(form_value.AsCString());
+        break;
+      case DW_AT_byte_size:
+        byte_size = form_value.Unsigned();
+        break;
+      case DW_AT_encoding:
+        break;
+      default:
+        assert(false && "Unsupported attribute for DW_TAG_base_type");
+      }
+    }
+  }
+
+  Declaration decl;
+  CompilerType compiler_type = m_ast.CreateBaseType(type_name);
+  return std::make_shared<Type>(die.GetID(), dwarf, type_name, byte_size,
+                                nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID,
+                                decl, compiler_type, Type::eResolveStateFull);
 }
 
-TypeSP
-DWARFASTParserJava::ParseBaseTypeFromDIE(const DWARFDIE &die)
-{
-    SymbolFileDWARF *dwarf = die.GetDWARF();
-    dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-    ConstString type_name;
-    uint64_t byte_size = 0;
-
-    DWARFAttributes attributes;
-    const size_t num_attributes = die.GetAttributes(attributes);
-    for (uint32_t i = 0; i < num_attributes; ++i)
-    {
+TypeSP DWARFASTParserJava::ParseArrayTypeFromDIE(const DWARFDIE &die) {
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+  dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+  ConstString linkage_name;
+  DWARFFormValue type_attr_value;
+  lldb::addr_t data_offset = LLDB_INVALID_ADDRESS;
+  DWARFExpression length_expression(die.GetCU());
+
+  DWARFAttributes attributes;
+  const size_t num_attributes = die.GetAttributes(attributes);
+  for (uint32_t i = 0; i < num_attributes; ++i) {
+    DWARFFormValue form_value;
+    dw_attr_t attr = attributes.AttributeAtIndex(i);
+    if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+      switch (attr) {
+      case DW_AT_linkage_name:
+        linkage_name.SetCString(form_value.AsCString());
+        break;
+      case DW_AT_type:
+        type_attr_value = form_value;
+        break;
+      case DW_AT_data_member_location:
+        data_offset = form_value.Unsigned();
+        break;
+      case DW_AT_declaration:
+        break;
+      default:
+        assert(false && "Unsupported attribute for DW_TAG_array_type");
+      }
+    }
+  }
+
+  for (DWARFDIE child_die = die.GetFirstChild(); child_die.IsValid();
+       child_die = child_die.GetSibling()) {
+    if (child_die.Tag() == DW_TAG_subrange_type) {
+      DWARFAttributes attributes;
+      const size_t num_attributes = child_die.GetAttributes(attributes);
+      for (uint32_t i = 0; i < num_attributes; ++i) {
         DWARFFormValue form_value;
         dw_attr_t attr = attributes.AttributeAtIndex(i);
-        if (attributes.ExtractFormValueAtIndex(i, form_value))
-        {
-            switch (attr)
-            {
-                case DW_AT_name:
-                    type_name.SetCString(form_value.AsCString());
-                    break;
-                case DW_AT_byte_size:
-                    byte_size = form_value.Unsigned();
-                    break;
-                case DW_AT_encoding:
-                    break;
-                default:
-                    assert(false && "Unsupported attribute for DW_TAG_base_type");
-            }
-        }
-    }
+        if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+          switch (attr) {
+          case DW_AT_count:
+            if (form_value.BlockData())
+              length_expression.CopyOpcodeData(
+                  form_value.BlockData(), form_value.Unsigned(),
+                  child_die.GetCU()->GetByteOrder(),
+                  child_die.GetCU()->GetAddressByteSize());
+            break;
+          default:
+            assert(false && "Unsupported attribute for DW_TAG_subrange_type");
+          }
+        }
+      }
+    } else {
+      assert(false && "Unsupported child for DW_TAG_array_type");
+    }
+  }
+
+  DIERef type_die_ref(type_attr_value);
+  Type *element_type = dwarf->ResolveTypeUID(type_die_ref);
+  if (!element_type)
+    return nullptr;
 
-    Declaration decl;
-    CompilerType compiler_type = m_ast.CreateBaseType(type_name);
-    return std::make_shared<Type>(die.GetID(), dwarf, type_name, byte_size, nullptr, LLDB_INVALID_UID,
-                                  Type::eEncodingIsUID, decl, compiler_type, Type::eResolveStateFull);
+  CompilerType element_compiler_type = element_type->GetForwardCompilerType();
+  CompilerType array_compiler_type = m_ast.CreateArrayType(
+      linkage_name, element_compiler_type, length_expression, data_offset);
+
+  Declaration decl;
+  TypeSP type_sp(new Type(die.GetID(), dwarf, array_compiler_type.GetTypeName(),
+                          -1, nullptr, type_die_ref.GetUID(dwarf),
+                          Type::eEncodingIsUID, &decl, array_compiler_type,
+                          Type::eResolveStateFull));
+  type_sp->SetEncodingType(element_type);
+  return type_sp;
 }
 
-TypeSP
-DWARFASTParserJava::ParseArrayTypeFromDIE(const DWARFDIE &die)
-{
-    SymbolFileDWARF *dwarf = die.GetDWARF();
-    dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-    ConstString linkage_name;
-    DWARFFormValue type_attr_value;
-    lldb::addr_t data_offset = LLDB_INVALID_ADDRESS;
-    DWARFExpression length_expression(die.GetCU());
-
-    DWARFAttributes attributes;
-    const size_t num_attributes = die.GetAttributes(attributes);
-    for (uint32_t i = 0; i < num_attributes; ++i)
-    {
-        DWARFFormValue form_value;
-        dw_attr_t attr = attributes.AttributeAtIndex(i);
-        if (attributes.ExtractFormValueAtIndex(i, form_value))
-        {
-            switch (attr)
-            {
-                case DW_AT_linkage_name:
-                    linkage_name.SetCString(form_value.AsCString());
-                    break;
-                case DW_AT_type:
-                    type_attr_value = form_value;
-                    break;
-                case DW_AT_data_member_location:
-                    data_offset = form_value.Unsigned();
-                    break;
-                case DW_AT_declaration:
-                    break;
-                default:
-                    assert(false && "Unsupported attribute for DW_TAG_array_type");
-            }
-        }
-    }
-
-    for (DWARFDIE child_die = die.GetFirstChild(); child_die.IsValid(); child_die = child_die.GetSibling())
-    {
-        if (child_die.Tag() == DW_TAG_subrange_type)
-        {
-            DWARFAttributes attributes;
-            const size_t num_attributes = child_die.GetAttributes(attributes);
-            for (uint32_t i = 0; i < num_attributes; ++i)
-            {
-                DWARFFormValue form_value;
-                dw_attr_t attr = attributes.AttributeAtIndex(i);
-                if (attributes.ExtractFormValueAtIndex(i, form_value))
-                {
-                    switch (attr)
-                    {
-                        case DW_AT_count:
-                            if (form_value.BlockData())
-                                length_expression.CopyOpcodeData(form_value.BlockData(), form_value.Unsigned(),
-                                                                 child_die.GetCU()->GetByteOrder(),
-                                                                 child_die.GetCU()->GetAddressByteSize());
-                            break;
-                        default:
-                            assert(false && "Unsupported attribute for DW_TAG_subrange_type");
-                    }
-                }
-            }
-        }
-        else
-        {
-            assert(false && "Unsupported child for DW_TAG_array_type");
-        }
-    }
+TypeSP DWARFASTParserJava::ParseReferenceTypeFromDIE(const DWARFDIE &die) {
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+  dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+  Declaration decl;
+  DWARFFormValue type_attr_value;
+
+  DWARFAttributes attributes;
+  const size_t num_attributes = die.GetAttributes(attributes);
+  for (uint32_t i = 0; i < num_attributes; ++i) {
+    DWARFFormValue form_value;
+    dw_attr_t attr = attributes.AttributeAtIndex(i);
+    if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+      switch (attr) {
+      case DW_AT_type:
+        type_attr_value = form_value;
+        break;
+      default:
+        assert(false && "Unsupported attribute for DW_TAG_array_type");
+      }
+    }
+  }
+
+  DIERef type_die_ref(type_attr_value);
+  Type *pointee_type = dwarf->ResolveTypeUID(type_die_ref);
+  if (!pointee_type)
+    return nullptr;
 
-    DIERef type_die_ref(type_attr_value);
-    Type *element_type = dwarf->ResolveTypeUID(type_die_ref);
-    if (!element_type)
-        return nullptr;
-
-    CompilerType element_compiler_type = element_type->GetForwardCompilerType();
-    CompilerType array_compiler_type =
-        m_ast.CreateArrayType(linkage_name, element_compiler_type, length_expression, data_offset);
-
-    Declaration decl;
-    TypeSP type_sp(new Type(die.GetID(), dwarf, array_compiler_type.GetTypeName(), -1, nullptr,
-                            type_die_ref.GetUID(dwarf), Type::eEncodingIsUID, &decl,
-                            array_compiler_type, Type::eResolveStateFull));
-    type_sp->SetEncodingType(element_type);
-    return type_sp;
+  CompilerType pointee_compiler_type = pointee_type->GetForwardCompilerType();
+  CompilerType reference_compiler_type =
+      m_ast.CreateReferenceType(pointee_compiler_type);
+  TypeSP type_sp(
+      new Type(die.GetID(), dwarf, reference_compiler_type.GetTypeName(), -1,
+               nullptr, type_die_ref.GetUID(dwarf), Type::eEncodingIsUID, &decl,
+               reference_compiler_type, Type::eResolveStateFull));
+  type_sp->SetEncodingType(pointee_type);
+  return type_sp;
 }
 
-TypeSP
-DWARFASTParserJava::ParseReferenceTypeFromDIE(const DWARFDIE &die)
-{
-    SymbolFileDWARF *dwarf = die.GetDWARF();
-    dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-    Declaration decl;
-    DWARFFormValue type_attr_value;
-
-    DWARFAttributes attributes;
-    const size_t num_attributes = die.GetAttributes(attributes);
-    for (uint32_t i = 0; i < num_attributes; ++i)
-    {
-        DWARFFormValue form_value;
-        dw_attr_t attr = attributes.AttributeAtIndex(i);
-        if (attributes.ExtractFormValueAtIndex(i, form_value))
-        {
-            switch (attr)
-            {
-                case DW_AT_type:
-                    type_attr_value = form_value;
-                    break;
-                default:
-                    assert(false && "Unsupported attribute for DW_TAG_array_type");
-            }
-        }
-    }
-
-    DIERef type_die_ref(type_attr_value);
-    Type *pointee_type = dwarf->ResolveTypeUID(type_die_ref);
-    if (!pointee_type)
-        return nullptr;
-
-    CompilerType pointee_compiler_type = pointee_type->GetForwardCompilerType();
-    CompilerType reference_compiler_type = m_ast.CreateReferenceType(pointee_compiler_type);
-    TypeSP type_sp(new Type(die.GetID(), dwarf, reference_compiler_type.GetTypeName(), -1, nullptr,
-                            type_die_ref.GetUID(dwarf), Type::eEncodingIsUID, &decl,
-                            reference_compiler_type, Type::eResolveStateFull));
-    type_sp->SetEncodingType(pointee_type);
-    return type_sp;
+lldb::TypeSP DWARFASTParserJava::ParseClassTypeFromDIE(const DWARFDIE &die,
+                                                       bool &is_new_type) {
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+  dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+  Declaration decl;
+  ConstString name;
+  ConstString linkage_name;
+  bool is_forward_declaration = false;
+  uint32_t byte_size = 0;
+
+  DWARFAttributes attributes;
+  const size_t num_attributes = die.GetAttributes(attributes);
+  for (uint32_t i = 0; i < num_attributes; ++i) {
+    DWARFFormValue form_value;
+    dw_attr_t attr = attributes.AttributeAtIndex(i);
+    if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+      switch (attr) {
+      case DW_AT_name:
+        name.SetCString(form_value.AsCString());
+        break;
+      case DW_AT_declaration:
+        is_forward_declaration = form_value.Boolean();
+        break;
+      case DW_AT_byte_size:
+        byte_size = form_value.Unsigned();
+        break;
+      case DW_AT_linkage_name:
+        linkage_name.SetCString(form_value.AsCString());
+        break;
+      default:
+        assert(false && "Unsupported attribute for DW_TAG_class_type");
+      }
+    }
+  }
+
+  UniqueDWARFASTType unique_ast_entry;
+  if (name) {
+    std::string qualified_name;
+    if (die.GetQualifiedName(qualified_name)) {
+      name.SetCString(qualified_name.c_str());
+      if (dwarf->GetUniqueDWARFASTTypeMap().Find(name, die, Declaration(), -1,
+                                                 unique_ast_entry)) {
+        if (unique_ast_entry.m_type_sp) {
+          dwarf->GetDIEToType()[die.GetDIE()] =
+              unique_ast_entry.m_type_sp.get();
+          is_new_type = false;
+          return unique_ast_entry.m_type_sp;
+        }
+      }
+    }
+  }
+
+  if (is_forward_declaration) {
+    DWARFDeclContext die_decl_ctx;
+    die.GetDWARFDeclContext(die_decl_ctx);
+
+    TypeSP type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+    if (type_sp) {
+      // We found a real definition for this type elsewhere so lets use it
+      dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+      is_new_type = false;
+      return type_sp;
+    }
+  }
+
+  CompilerType compiler_type(
+      &m_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
+  if (!compiler_type)
+    compiler_type = m_ast.CreateObjectType(name, linkage_name, byte_size);
+
+  is_new_type = true;
+  TypeSP type_sp(new Type(die.GetID(), dwarf, name,
+                          -1, // byte size isn't specified
+                          nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID,
+                          &decl, compiler_type, Type::eResolveStateForward));
+
+  // Add our type to the unique type map
+  unique_ast_entry.m_type_sp = type_sp;
+  unique_ast_entry.m_die = die;
+  unique_ast_entry.m_declaration = decl;
+  unique_ast_entry.m_byte_size = -1;
+  dwarf->GetUniqueDWARFASTTypeMap().Insert(name, unique_ast_entry);
+
+  if (!is_forward_declaration) {
+    // Leave this as a forward declaration until we need to know the details of
+    // the type
+    dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
+        compiler_type.GetOpaqueQualType();
+    dwarf->GetForwardDeclClangTypeToDie()[compiler_type.GetOpaqueQualType()] =
+        die.GetDIERef();
+  }
+  return type_sp;
 }
 
-lldb::TypeSP
-DWARFASTParserJava::ParseClassTypeFromDIE(const DWARFDIE &die, bool &is_new_type)
-{
-    SymbolFileDWARF *dwarf = die.GetDWARF();
-    dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
-    Declaration decl;
-    ConstString name;
-    ConstString linkage_name;
-    bool is_forward_declaration = false;
-    uint32_t byte_size = 0;
-
-    DWARFAttributes attributes;
-    const size_t num_attributes = die.GetAttributes(attributes);
-    for (uint32_t i = 0; i < num_attributes; ++i)
-    {
-        DWARFFormValue form_value;
-        dw_attr_t attr = attributes.AttributeAtIndex(i);
-        if (attributes.ExtractFormValueAtIndex(i, form_value))
-        {
-            switch (attr)
-            {
-                case DW_AT_name:
-                    name.SetCString(form_value.AsCString());
-                    break;
-                case DW_AT_declaration:
-                    is_forward_declaration = form_value.Boolean();
-                    break;
-                case DW_AT_byte_size:
-                    byte_size = form_value.Unsigned();
-                    break;
-                case DW_AT_linkage_name:
-                    linkage_name.SetCString(form_value.AsCString());
-                    break;
-                default:
-                    assert(false && "Unsupported attribute for DW_TAG_class_type");
-            }
-        }
-    }
+lldb::TypeSP DWARFASTParserJava::ParseTypeFromDWARF(
+    const lldb_private::SymbolContext &sc, const DWARFDIE &die,
+    lldb_private::Log *log, bool *type_is_new_ptr) {
+  if (type_is_new_ptr)
+    *type_is_new_ptr = false;
 
-    UniqueDWARFASTType unique_ast_entry;
-    if (name)
-    {
-        std::string qualified_name;
-        if (die.GetQualifiedName(qualified_name))
-        {
-            name.SetCString(qualified_name.c_str());
-            if (dwarf->GetUniqueDWARFASTTypeMap().Find(name, die, Declaration(), -1, unique_ast_entry))
-            {
-                if (unique_ast_entry.m_type_sp)
-                {
-                    dwarf->GetDIEToType()[die.GetDIE()] = unique_ast_entry.m_type_sp.get();
-                    is_new_type = false;
-                    return unique_ast_entry.m_type_sp;
-                }
-            }
-        }
-    }
+  if (!die)
+    return nullptr;
 
-    if (is_forward_declaration)
-    {
-        DWARFDeclContext die_decl_ctx;
-        die.GetDWARFDeclContext(die_decl_ctx);
-
-        TypeSP type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
-        if (type_sp)
-        {
-            // We found a real definition for this type elsewhere so lets use it
-            dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
-            is_new_type = false;
-            return type_sp;
-        }
-    }
+  SymbolFileDWARF *dwarf = die.GetDWARF();
 
-    CompilerType compiler_type(&m_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
-    if (!compiler_type)
-        compiler_type = m_ast.CreateObjectType(name, linkage_name, byte_size);
-
-    is_new_type = true;
-    TypeSP type_sp(new Type(die.GetID(), dwarf, name,
-                            -1, // byte size isn't specified
-                            nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, compiler_type,
-                            Type::eResolveStateForward));
-
-    // Add our type to the unique type map
-    unique_ast_entry.m_type_sp = type_sp;
-    unique_ast_entry.m_die = die;
-    unique_ast_entry.m_declaration = decl;
-    unique_ast_entry.m_byte_size = -1;
-    dwarf->GetUniqueDWARFASTTypeMap().Insert(name, unique_ast_entry);
-
-    if (!is_forward_declaration)
-    {
-        // Leave this as a forward declaration until we need to know the details of the type
-        dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] = compiler_type.GetOpaqueQualType();
-        dwarf->GetForwardDeclClangTypeToDie()[compiler_type.GetOpaqueQualType()] = die.GetDIERef();
-    }
-    return type_sp;
-}
+  Type *type_ptr = dwarf->m_die_to_type.lookup(die.GetDIE());
+  if (type_ptr == DIE_IS_BEING_PARSED)
+    return nullptr;
+  if (type_ptr != nullptr)
+    return type_ptr->shared_from_this();
 
-lldb::TypeSP
-DWARFASTParserJava::ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die,
-                                       lldb_private::Log *log, bool *type_is_new_ptr)
-{
-    if (type_is_new_ptr)
-        *type_is_new_ptr = false;
-
-    if (!die)
-        return nullptr;
-
-    SymbolFileDWARF *dwarf = die.GetDWARF();
-
-    Type *type_ptr = dwarf->m_die_to_type.lookup(die.GetDIE());
-    if (type_ptr == DIE_IS_BEING_PARSED)
-        return nullptr;
-    if (type_ptr != nullptr)
-        return type_ptr->shared_from_this();
-
-    TypeSP type_sp;
-    if (type_is_new_ptr)
-        *type_is_new_ptr = true;
-
-    switch (die.Tag())
-    {
-        case DW_TAG_base_type:
-        {
-            type_sp = ParseBaseTypeFromDIE(die);
-            break;
-        }
-        case DW_TAG_array_type:
-        {
-            type_sp = ParseArrayTypeFromDIE(die);
-            break;
-        }
-        case DW_TAG_class_type:
-        {
-            bool is_new_type = false;
-            type_sp = ParseClassTypeFromDIE(die, is_new_type);
-            if (!is_new_type)
-                return type_sp;
-            break;
-        }
-        case DW_TAG_reference_type:
-        {
-            type_sp = ParseReferenceTypeFromDIE(die);
-            break;
-        }
-    }
+  TypeSP type_sp;
+  if (type_is_new_ptr)
+    *type_is_new_ptr = true;
+
+  switch (die.Tag()) {
+  case DW_TAG_base_type: {
+    type_sp = ParseBaseTypeFromDIE(die);
+    break;
+  }
+  case DW_TAG_array_type: {
+    type_sp = ParseArrayTypeFromDIE(die);
+    break;
+  }
+  case DW_TAG_class_type: {
+    bool is_new_type = false;
+    type_sp = ParseClassTypeFromDIE(die, is_new_type);
+    if (!is_new_type)
+      return type_sp;
+    break;
+  }
+  case DW_TAG_reference_type: {
+    type_sp = ParseReferenceTypeFromDIE(die);
+    break;
+  }
+  }
 
-    if (!type_sp)
-        return nullptr;
+  if (!type_sp)
+    return nullptr;
 
-    DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die);
-    dw_tag_t sc_parent_tag = sc_parent_die.Tag();
+  DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die);
+  dw_tag_t sc_parent_tag = sc_parent_die.Tag();
 
-    SymbolContextScope *symbol_context_scope = nullptr;
-    if (sc_parent_tag == DW_TAG_compile_unit)
-    {
-        symbol_context_scope = sc.comp_unit;
-    }
-    else if (sc.function != nullptr && sc_parent_die)
-    {
-        symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
-        if (symbol_context_scope == nullptr)
-            symbol_context_scope = sc.function;
-    }
+  SymbolContextScope *symbol_context_scope = nullptr;
+  if (sc_parent_tag == DW_TAG_compile_unit) {
+    symbol_context_scope = sc.comp_unit;
+  } else if (sc.function != nullptr && sc_parent_die) {
+    symbol_context_scope =
+        sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
+    if (symbol_context_scope == nullptr)
+      symbol_context_scope = sc.function;
+  }
 
-    if (symbol_context_scope != nullptr)
-        type_sp->SetSymbolContextScope(symbol_context_scope);
+  if (symbol_context_scope != nullptr)
+    type_sp->SetSymbolContextScope(symbol_context_scope);
 
-    dwarf->GetTypeList()->Insert(type_sp);
-    dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
+  dwarf->GetTypeList()->Insert(type_sp);
+  dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
 
-    return type_sp;
+  return type_sp;
 }
 
-lldb_private::Function *
-DWARFASTParserJava::ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die)
-{
-    assert(die.Tag() == DW_TAG_subprogram);
-
-    const char *name = nullptr;
-    const char *mangled = nullptr;
-    int decl_file = 0;
-    int decl_line = 0;
-    int decl_column = 0;
-    int call_file = 0;
-    int call_line = 0;
-    int call_column = 0;
-    DWARFRangeList func_ranges;
-    DWARFExpression frame_base(die.GetCU());
-
-    if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line, decl_column, call_file, call_line,
-                                 call_column, &frame_base))
-    {
-        // Union of all ranges in the function DIE (if the function is discontiguous)
-        AddressRange func_range;
-        lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
-        lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
-        if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr)
-        {
-            ModuleSP module_sp(die.GetModule());
-            func_range.GetBaseAddress().ResolveAddressUsingFileSections(lowest_func_addr, module_sp->GetSectionList());
-            if (func_range.GetBaseAddress().IsValid())
-                func_range.SetByteSize(highest_func_addr - lowest_func_addr);
-        }
-
-        if (func_range.GetBaseAddress().IsValid())
-        {
-            std::unique_ptr<Declaration> decl_ap;
-            if (decl_file != 0 || decl_line != 0 || decl_column != 0)
-                decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line,
-                                              decl_column));
-
-            if (die.GetDWARF()->FixupAddress(func_range.GetBaseAddress()))
-            {
-                FunctionSP func_sp(new Function(sc.comp_unit, die.GetID(), die.GetID(),
-                                                Mangled(ConstString(name), false),
-                                                nullptr, // No function types in java
-                                                func_range));
-                if (frame_base.IsValid())
-                    func_sp->GetFrameBaseExpression() = frame_base;
-                sc.comp_unit->AddFunction(func_sp);
+lldb_private::Function *DWARFASTParserJava::ParseFunctionFromDWARF(
+    const lldb_private::SymbolContext &sc, const DWARFDIE &die) {
+  assert(die.Tag() == DW_TAG_subprogram);
+
+  const char *name = nullptr;
+  const char *mangled = nullptr;
+  int decl_file = 0;
+  int decl_line = 0;
+  int decl_column = 0;
+  int call_file = 0;
+  int call_line = 0;
+  int call_column = 0;
+  DWARFRangeList func_ranges;
+  DWARFExpression frame_base(die.GetCU());
+
+  if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line,
+                               decl_column, call_file, call_line, call_column,
+                               &frame_base)) {
+    // Union of all ranges in the function DIE (if the function is
+    // discontiguous)
+    AddressRange func_range;
+    lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
+    lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
+    if (lowest_func_addr != LLDB_INVALID_ADDRESS &&
+        lowest_func_addr <= highest_func_addr) {
+      ModuleSP module_sp(die.GetModule());
+      func_range.GetBaseAddress().ResolveAddressUsingFileSections(
+          lowest_func_addr, module_sp->GetSectionList());
+      if (func_range.GetBaseAddress().IsValid())
+        func_range.SetByteSize(highest_func_addr - lowest_func_addr);
+    }
+
+    if (func_range.GetBaseAddress().IsValid()) {
+      std::unique_ptr<Declaration> decl_ap;
+      if (decl_file != 0 || decl_line != 0 || decl_column != 0)
+        decl_ap.reset(new Declaration(
+            sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file),
+            decl_line, decl_column));
+
+      if (die.GetDWARF()->FixupAddress(func_range.GetBaseAddress())) {
+        FunctionSP func_sp(new Function(sc.comp_unit, die.GetID(), die.GetID(),
+                                        Mangled(ConstString(name), false),
+                                        nullptr, // No function types in java
+                                        func_range));
+        if (frame_base.IsValid())
+          func_sp->GetFrameBaseExpression() = frame_base;
+        sc.comp_unit->AddFunction(func_sp);
 
-                return func_sp.get();
-            }
-        }
+        return func_sp.get();
+      }
     }
-    return nullptr;
+  }
+  return nullptr;
 }
 
-bool
-DWARFASTParserJava::CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
-                                          lldb_private::CompilerType &java_type)
-{
-    switch (die.Tag())
-    {
-        case DW_TAG_class_type:
-            {
-                if (die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 0)
-                {
-                    if (die.HasChildren())
-                        ParseChildMembers(die, java_type);
-                    m_ast.CompleteObjectType(java_type);
-                    return java_type.IsValid();
-                }
-            }
+bool DWARFASTParserJava::CompleteTypeFromDWARF(
+    const DWARFDIE &die, lldb_private::Type *type,
+    lldb_private::CompilerType &java_type) {
+  switch (die.Tag()) {
+  case DW_TAG_class_type: {
+    if (die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 0) {
+      if (die.HasChildren())
+        ParseChildMembers(die, java_type);
+      m_ast.CompleteObjectType(java_type);
+      return java_type.IsValid();
+    }
+  } break;
+  default:
+    assert(false && "Not a forward java type declaration!");
+    break;
+  }
+  return false;
+}
+
+void DWARFASTParserJava::ParseChildMembers(const DWARFDIE &parent_die,
+                                           CompilerType &compiler_type) {
+  DWARFCompileUnit *dwarf_cu = parent_die.GetCU();
+  for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
+       die = die.GetSibling()) {
+    switch (die.Tag()) {
+    case DW_TAG_member: {
+      const char *name = nullptr;
+      DWARFFormValue encoding_uid;
+      uint32_t member_byte_offset = UINT32_MAX;
+      DWARFExpression member_location_expression(dwarf_cu);
+
+      DWARFAttributes attributes;
+      size_t num_attributes = die.GetAttributes(attributes);
+      for (size_t i = 0; i < num_attributes; ++i) {
+        DWARFFormValue form_value;
+        if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+          switch (attributes.AttributeAtIndex(i)) {
+          case DW_AT_name:
+            name = form_value.AsCString();
             break;
-        default:
-            assert(false && "Not a forward java type declaration!");
+          case DW_AT_type:
+            encoding_uid = form_value;
             break;
-    }
-    return false;
-}
+          case DW_AT_data_member_location:
+            if (form_value.BlockData())
+              member_location_expression.CopyOpcodeData(
+                  form_value.BlockData(), form_value.Unsigned(),
+                  dwarf_cu->GetByteOrder(), dwarf_cu->GetAddressByteSize());
+            else
+              member_byte_offset = form_value.Unsigned();
+            break;
+          case DW_AT_artificial:
+            static_cast<void>(form_value.Boolean());
+            break;
+          case DW_AT_accessibility:
+            // TODO: Handle when needed
+            break;
+          default:
+            assert(false && "Unhandled attribute for DW_TAG_member");
+            break;
+          }
+        }
+      }
 
-void
-DWARFASTParserJava::ParseChildMembers(const DWARFDIE &parent_die, CompilerType &compiler_type)
-{
-    DWARFCompileUnit *dwarf_cu = parent_die.GetCU();
-    for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid(); die = die.GetSibling())
-    {
-        switch (die.Tag())
-        {
-            case DW_TAG_member:
-            {
-                const char *name = nullptr;
-                DWARFFormValue encoding_uid;
-                uint32_t member_byte_offset = UINT32_MAX;
-                DWARFExpression member_location_expression(dwarf_cu);
-
-                DWARFAttributes attributes;
-                size_t num_attributes = die.GetAttributes(attributes);
-                for (size_t i = 0; i < num_attributes; ++i)
-                {
-                    DWARFFormValue form_value;
-                    if (attributes.ExtractFormValueAtIndex(i, form_value))
-                    {
-                        switch (attributes.AttributeAtIndex(i))
-                        {
-                            case DW_AT_name:
-                                name = form_value.AsCString();
-                                break;
-                            case DW_AT_type:
-                                encoding_uid = form_value;
-                                break;
-                            case DW_AT_data_member_location:
-                                if (form_value.BlockData())
-                                    member_location_expression.CopyOpcodeData(
-                                        form_value.BlockData(), form_value.Unsigned(), dwarf_cu->GetByteOrder(),
-                                        dwarf_cu->GetAddressByteSize());
-                                else
-                                    member_byte_offset = form_value.Unsigned();
-                                break;
-                            case DW_AT_artificial:
-                                static_cast<void>(form_value.Boolean());
-                                break;
-                            case DW_AT_accessibility:
-                                // TODO: Handle when needed
-                                break;
-                            default:
-                                assert(false && "Unhandled attribute for DW_TAG_member");
-                                break;
-                        }
-                    }
-                }
-
-                if (strcmp(name, ".dynamic_type") == 0)
-                    m_ast.SetDynamicTypeId(compiler_type, member_location_expression);
-                else
-                {
-                    if (Type *member_type = die.ResolveTypeUID(DIERef(encoding_uid)))
-                        m_ast.AddMemberToObject(compiler_type, ConstString(name), member_type->GetFullCompilerType(),
-                                                member_byte_offset);
-                }
-                break;
-            }
-            case DW_TAG_inheritance:
-            {
-                DWARFFormValue encoding_uid;
-                uint32_t member_byte_offset = UINT32_MAX;
-
-                DWARFAttributes attributes;
-                size_t num_attributes = die.GetAttributes(attributes);
-                for (size_t i = 0; i < num_attributes; ++i)
-                {
-                    DWARFFormValue form_value;
-                    if (attributes.ExtractFormValueAtIndex(i, form_value))
-                    {
-                        switch (attributes.AttributeAtIndex(i))
-                        {
-                            case DW_AT_type:
-                                encoding_uid = form_value;
-                                break;
-                            case DW_AT_data_member_location:
-                                member_byte_offset = form_value.Unsigned();
-                                break;
-                            case DW_AT_accessibility:
-                                // In java all base class is public so we can ignore this attribute
-                                break;
-                            default:
-                                assert(false && "Unhandled attribute for DW_TAG_member");
-                                break;
-                        }
-                    }
-                }
-                if (Type *base_type = die.ResolveTypeUID(DIERef(encoding_uid)))
-                    m_ast.AddBaseClassToObject(compiler_type, base_type->GetFullCompilerType(), member_byte_offset);
-                break;
-            }
-            default:
-                break;
+      if (strcmp(name, ".dynamic_type") == 0)
+        m_ast.SetDynamicTypeId(compiler_type, member_location_expression);
+      else {
+        if (Type *member_type = die.ResolveTypeUID(DIERef(encoding_uid)))
+          m_ast.AddMemberToObject(compiler_type, ConstString(name),
+                                  member_type->GetFullCompilerType(),
+                                  member_byte_offset);
+      }
+      break;
+    }
+    case DW_TAG_inheritance: {
+      DWARFFormValue encoding_uid;
+      uint32_t member_byte_offset = UINT32_MAX;
+
+      DWARFAttributes attributes;
+      size_t num_attributes = die.GetAttributes(attributes);
+      for (size_t i = 0; i < num_attributes; ++i) {
+        DWARFFormValue form_value;
+        if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+          switch (attributes.AttributeAtIndex(i)) {
+          case DW_AT_type:
+            encoding_uid = form_value;
+            break;
+          case DW_AT_data_member_location:
+            member_byte_offset = form_value.Unsigned();
+            break;
+          case DW_AT_accessibility:
+            // In java all base class is public so we can ignore this attribute
+            break;
+          default:
+            assert(false && "Unhandled attribute for DW_TAG_member");
+            break;
+          }
         }
+      }
+      if (Type *base_type = die.ResolveTypeUID(DIERef(encoding_uid)))
+        m_ast.AddBaseClassToObject(compiler_type,
+                                   base_type->GetFullCompilerType(),
+                                   member_byte_offset);
+      break;
+    }
+    default:
+      break;
     }
+  }
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.h Tue Sep  6 15:57:50 2016
@@ -27,64 +27,55 @@
 class DWARFDebugInfoEntry;
 class DWARFDIECollection;
 
-class DWARFASTParserJava : public DWARFASTParser
-{
+class DWARFASTParserJava : public DWARFASTParser {
 public:
-    DWARFASTParserJava(lldb_private::JavaASTContext &ast);
-    ~DWARFASTParserJava() override;
+  DWARFASTParserJava(lldb_private::JavaASTContext &ast);
+  ~DWARFASTParserJava() override;
 
-    lldb::TypeSP
-    ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die, lldb_private::Log *log,
-                       bool *type_is_new_ptr) override;
-
-    lldb_private::Function *
-    ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die) override;
-
-    bool
-    CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
-                          lldb_private::CompilerType &java_type) override;
-
-    lldb_private::CompilerDeclContext
-    GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override
-    {
-        return lldb_private::CompilerDeclContext();
-    }
-
-    lldb_private::CompilerDeclContext
-    GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override
-    {
-        return lldb_private::CompilerDeclContext();
-    }
-
-    lldb_private::CompilerDecl
-    GetDeclForUIDFromDWARF(const DWARFDIE &die) override
-    {
-        return lldb_private::CompilerDecl();
-    }
-
-    std::vector<DWARFDIE>
-    GetDIEForDeclContext(lldb_private::CompilerDeclContext decl_context) override
-    {
-        return std::vector<DWARFDIE>();
-    }
+  lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
+                                  const DWARFDIE &die, lldb_private::Log *log,
+                                  bool *type_is_new_ptr) override;
+
+  lldb_private::Function *
+  ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc,
+                         const DWARFDIE &die) override;
+
+  bool CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
+                             lldb_private::CompilerType &java_type) override;
+
+  lldb_private::CompilerDeclContext
+  GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override {
+    return lldb_private::CompilerDeclContext();
+  }
+
+  lldb_private::CompilerDeclContext
+  GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override {
+    return lldb_private::CompilerDeclContext();
+  }
+
+  lldb_private::CompilerDecl
+  GetDeclForUIDFromDWARF(const DWARFDIE &die) override {
+    return lldb_private::CompilerDecl();
+  }
+
+  std::vector<DWARFDIE> GetDIEForDeclContext(
+      lldb_private::CompilerDeclContext decl_context) override {
+    return std::vector<DWARFDIE>();
+  }
 
-    void
-    ParseChildMembers(const DWARFDIE &parent_die, lldb_private::CompilerType &class_compiler_type);
+  void ParseChildMembers(const DWARFDIE &parent_die,
+                         lldb_private::CompilerType &class_compiler_type);
 
 private:
-    lldb_private::JavaASTContext &m_ast;
+  lldb_private::JavaASTContext &m_ast;
 
-    lldb::TypeSP
-    ParseBaseTypeFromDIE(const DWARFDIE &die);
+  lldb::TypeSP ParseBaseTypeFromDIE(const DWARFDIE &die);
 
-    lldb::TypeSP
-    ParseArrayTypeFromDIE(const DWARFDIE &die);
+  lldb::TypeSP ParseArrayTypeFromDIE(const DWARFDIE &die);
 
-    lldb::TypeSP
-    ParseReferenceTypeFromDIE(const DWARFDIE &die);
+  lldb::TypeSP ParseReferenceTypeFromDIE(const DWARFDIE &die);
 
-    lldb::TypeSP
-    ParseClassTypeFromDIE(const DWARFDIE &die, bool &is_new_type);
+  lldb::TypeSP ParseClassTypeFromDIE(const DWARFDIE &die, bool &is_new_type);
 };
 
 #endif // SymbolFileDWARF_DWARFASTParserJava_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp Tue Sep  6 15:57:50 2016
@@ -14,219 +14,196 @@
 using namespace lldb;
 using namespace lldb_private;
 
-DWARFASTParserOCaml::DWARFASTParserOCaml (OCamlASTContext &ast) :
-    m_ast (ast)
-{}
-
-DWARFASTParserOCaml::~DWARFASTParserOCaml () {}
-
-TypeSP
-DWARFASTParserOCaml::ParseBaseTypeFromDIE(const DWARFDIE &die)
-{
-    SymbolFileDWARF *dwarf = die.GetDWARF();
-    dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+DWARFASTParserOCaml::DWARFASTParserOCaml(OCamlASTContext &ast) : m_ast(ast) {}
 
-    ConstString type_name;
-    uint64_t byte_size = 0;
+DWARFASTParserOCaml::~DWARFASTParserOCaml() {}
 
-    DWARFAttributes attributes;
-    const size_t num_attributes = die.GetAttributes(attributes);
-    for (uint32_t i = 0; i < num_attributes; ++i)
-    {
-        DWARFFormValue form_value;
-        dw_attr_t attr = attributes.AttributeAtIndex(i);
-        if (attributes.ExtractFormValueAtIndex(i, form_value))
-        {
-            switch (attr)
-            {
-                case DW_AT_name:
-                    type_name.SetCString(form_value.AsCString());
-                    break;
-                case DW_AT_byte_size:
-                    byte_size = form_value.Unsigned();
-                    break;
-                case DW_AT_encoding:
-                    break;
-                default:
-                    assert(false && "Unsupported attribute for DW_TAG_base_type");
-            }
-        }
-    }
-
-    Declaration decl;
-    CompilerType compiler_type = m_ast.CreateBaseType(type_name, byte_size);
-    return std::make_shared<Type>(die.GetID(), dwarf, type_name, byte_size, nullptr, LLDB_INVALID_UID,
-            Type::eEncodingIsUID, decl, compiler_type, Type::eResolveStateFull);
+TypeSP DWARFASTParserOCaml::ParseBaseTypeFromDIE(const DWARFDIE &die) {
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+  dwarf->m_die_to_type[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+  ConstString type_name;
+  uint64_t byte_size = 0;
+
+  DWARFAttributes attributes;
+  const size_t num_attributes = die.GetAttributes(attributes);
+  for (uint32_t i = 0; i < num_attributes; ++i) {
+    DWARFFormValue form_value;
+    dw_attr_t attr = attributes.AttributeAtIndex(i);
+    if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+      switch (attr) {
+      case DW_AT_name:
+        type_name.SetCString(form_value.AsCString());
+        break;
+      case DW_AT_byte_size:
+        byte_size = form_value.Unsigned();
+        break;
+      case DW_AT_encoding:
+        break;
+      default:
+        assert(false && "Unsupported attribute for DW_TAG_base_type");
+      }
+    }
+  }
+
+  Declaration decl;
+  CompilerType compiler_type = m_ast.CreateBaseType(type_name, byte_size);
+  return std::make_shared<Type>(die.GetID(), dwarf, type_name, byte_size,
+                                nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID,
+                                decl, compiler_type, Type::eResolveStateFull);
 }
 
-lldb::TypeSP
-DWARFASTParserOCaml::ParseTypeFromDWARF (const SymbolContext& sc,
-                                         const DWARFDIE &die,
-                                         Log *log,
-                                         bool *type_is_new_ptr)
-{
-    if (type_is_new_ptr)
-        *type_is_new_ptr = false;
-
-    if (!die)
-        return nullptr;
-
-    SymbolFileDWARF *dwarf = die.GetDWARF();
-
-    Type *type_ptr = dwarf->m_die_to_type.lookup(die.GetDIE());
-    if (type_ptr == DIE_IS_BEING_PARSED)
-        return nullptr;
-    if (type_ptr != nullptr)
-        return type_ptr->shared_from_this();
-
-    TypeSP type_sp;
-    if (type_is_new_ptr)
-        *type_is_new_ptr = true;
-
-    switch (die.Tag())
-    {
-        case DW_TAG_base_type:
-            {
-                type_sp = ParseBaseTypeFromDIE(die);
-                break;
-            }
-        case DW_TAG_array_type:
-            {
-                break;
-            }
-        case DW_TAG_class_type:
-            {
-                break;
-            }
-        case DW_TAG_reference_type:
-            {
-                break;
-            }
-    }
-
-    if (!type_sp)
-        return nullptr;
+lldb::TypeSP DWARFASTParserOCaml::ParseTypeFromDWARF(const SymbolContext &sc,
+                                                     const DWARFDIE &die,
+                                                     Log *log,
+                                                     bool *type_is_new_ptr) {
+  if (type_is_new_ptr)
+    *type_is_new_ptr = false;
+
+  if (!die)
+    return nullptr;
+
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+
+  Type *type_ptr = dwarf->m_die_to_type.lookup(die.GetDIE());
+  if (type_ptr == DIE_IS_BEING_PARSED)
+    return nullptr;
+  if (type_ptr != nullptr)
+    return type_ptr->shared_from_this();
+
+  TypeSP type_sp;
+  if (type_is_new_ptr)
+    *type_is_new_ptr = true;
+
+  switch (die.Tag()) {
+  case DW_TAG_base_type: {
+    type_sp = ParseBaseTypeFromDIE(die);
+    break;
+  }
+  case DW_TAG_array_type: {
+    break;
+  }
+  case DW_TAG_class_type: {
+    break;
+  }
+  case DW_TAG_reference_type: {
+    break;
+  }
+  }
+
+  if (!type_sp)
+    return nullptr;
+
+  DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die);
+  dw_tag_t sc_parent_tag = sc_parent_die.Tag();
+
+  SymbolContextScope *symbol_context_scope = nullptr;
+  if (sc_parent_tag == DW_TAG_compile_unit) {
+    symbol_context_scope = sc.comp_unit;
+  } else if (sc.function != nullptr && sc_parent_die) {
+    symbol_context_scope =
+        sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
+    if (symbol_context_scope == nullptr)
+      symbol_context_scope = sc.function;
+  }
 
-    DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die);
-    dw_tag_t sc_parent_tag = sc_parent_die.Tag();
+  if (symbol_context_scope != nullptr)
+    type_sp->SetSymbolContextScope(symbol_context_scope);
 
-    SymbolContextScope *symbol_context_scope = nullptr;
-    if (sc_parent_tag == DW_TAG_compile_unit)
-    {
-        symbol_context_scope = sc.comp_unit;
-    }
-    else if (sc.function != nullptr && sc_parent_die)
-    {
-        symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
-        if (symbol_context_scope == nullptr)
-            symbol_context_scope = sc.function;
-    }
+  dwarf->GetTypeList()->Insert(type_sp);
+  dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
 
-    if (symbol_context_scope != nullptr)
-        type_sp->SetSymbolContextScope(symbol_context_scope);
+  return type_sp;
+}
 
-    dwarf->GetTypeList()->Insert(type_sp);
-    dwarf->m_die_to_type[die.GetDIE()] = type_sp.get();
+Function *DWARFASTParserOCaml::ParseFunctionFromDWARF(const SymbolContext &sc,
+                                                      const DWARFDIE &die) {
+  DWARFRangeList func_ranges;
+  const char *name = NULL;
+  const char *mangled = NULL;
+  int decl_file = 0;
+  int decl_line = 0;
+  int decl_column = 0;
+  int call_file = 0;
+  int call_line = 0;
+  int call_column = 0;
+  DWARFExpression frame_base(die.GetCU());
 
-    return type_sp;
-}
+  Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE));
 
-Function *
-DWARFASTParserOCaml::ParseFunctionFromDWARF (const SymbolContext& sc,
-                                             const DWARFDIE &die)
-{
-    DWARFRangeList func_ranges;
-    const char *name = NULL;
-    const char *mangled = NULL;
-    int decl_file = 0;
-    int decl_line = 0;
-    int decl_column = 0;
-    int call_file = 0;
-    int call_line = 0;
-    int call_column = 0;
-    DWARFExpression frame_base(die.GetCU());
-
-    Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_LANGUAGE));
-
-    if (die)
-    {
-        SymbolFileDWARF *dwarf = die.GetDWARF();
-        if (log)
-        {
-            dwarf->GetObjectFile()->GetModule()->LogMessage(
-                log, "DWARFASTParserOCaml::ParseFunctionFromDWARF (die = 0x%8.8x) %s name = '%s')", die.GetOffset(),
-                DW_TAG_value_to_name(die.Tag()), die.GetName());
-        }
+  if (die) {
+    SymbolFileDWARF *dwarf = die.GetDWARF();
+    if (log) {
+      dwarf->GetObjectFile()->GetModule()->LogMessage(
+          log, "DWARFASTParserOCaml::ParseFunctionFromDWARF (die = 0x%8.8x) %s "
+               "name = '%s')",
+          die.GetOffset(), DW_TAG_value_to_name(die.Tag()), die.GetName());
     }
+  }
 
-    assert(die.Tag() == DW_TAG_subprogram);
-
-    if (die.Tag() != DW_TAG_subprogram)
-        return NULL;
+  assert(die.Tag() == DW_TAG_subprogram);
 
-    if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line, decl_column, call_file, call_line,
-                                 call_column, &frame_base))
-    {
-        AddressRange func_range;
-        lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
-        lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
-        if (lowest_func_addr != LLDB_INVALID_ADDRESS && lowest_func_addr <= highest_func_addr)
-        {
-            ModuleSP module_sp(die.GetModule());
-            func_range.GetBaseAddress().ResolveAddressUsingFileSections(lowest_func_addr, module_sp->GetSectionList());
-            if (func_range.GetBaseAddress().IsValid())
-                func_range.SetByteSize(highest_func_addr - lowest_func_addr);
-        }
+  if (die.Tag() != DW_TAG_subprogram)
+    return NULL;
 
-        if (func_range.GetBaseAddress().IsValid())
-        {
-            Mangled func_name;
-
-            func_name.SetValue(ConstString(name), true);
-
-            FunctionSP func_sp;
-            std::unique_ptr<Declaration> decl_ap;
-            if (decl_file != 0 || decl_line != 0 || decl_column != 0)
-                decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line,
-                                              decl_column));
-
-            SymbolFileDWARF *dwarf = die.GetDWARF();
-            Type *func_type = dwarf->m_die_to_type.lookup(die.GetDIE());
-
-            assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
-
-            if (dwarf->FixupAddress(func_range.GetBaseAddress()))
-            {
-                const user_id_t func_user_id = die.GetID();
-                func_sp.reset(new Function(sc.comp_unit,
-                                           func_user_id, // UserID is the DIE offset
-                                           func_user_id,
-                                           func_name,
-                                           func_type,
-                                           func_range)); // first address range
-
-                if (func_sp.get() != NULL)
-                {
-                    if (frame_base.IsValid())
-                        func_sp->GetFrameBaseExpression() = frame_base;
-                    sc.comp_unit->AddFunction(func_sp);
-                    return func_sp.get();
-                }
-            }
+  if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line,
+                               decl_column, call_file, call_line, call_column,
+                               &frame_base)) {
+    AddressRange func_range;
+    lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase(0);
+    lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd(0);
+    if (lowest_func_addr != LLDB_INVALID_ADDRESS &&
+        lowest_func_addr <= highest_func_addr) {
+      ModuleSP module_sp(die.GetModule());
+      func_range.GetBaseAddress().ResolveAddressUsingFileSections(
+          lowest_func_addr, module_sp->GetSectionList());
+      if (func_range.GetBaseAddress().IsValid())
+        func_range.SetByteSize(highest_func_addr - lowest_func_addr);
+    }
+
+    if (func_range.GetBaseAddress().IsValid()) {
+      Mangled func_name;
+
+      func_name.SetValue(ConstString(name), true);
+
+      FunctionSP func_sp;
+      std::unique_ptr<Declaration> decl_ap;
+      if (decl_file != 0 || decl_line != 0 || decl_column != 0)
+        decl_ap.reset(new Declaration(
+            sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file),
+            decl_line, decl_column));
+
+      SymbolFileDWARF *dwarf = die.GetDWARF();
+      Type *func_type = dwarf->m_die_to_type.lookup(die.GetDIE());
+
+      assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
+
+      if (dwarf->FixupAddress(func_range.GetBaseAddress())) {
+        const user_id_t func_user_id = die.GetID();
+        func_sp.reset(new Function(sc.comp_unit,
+                                   func_user_id, // UserID is the DIE offset
+                                   func_user_id, func_name, func_type,
+                                   func_range)); // first address range
+
+        if (func_sp.get() != NULL) {
+          if (frame_base.IsValid())
+            func_sp->GetFrameBaseExpression() = frame_base;
+          sc.comp_unit->AddFunction(func_sp);
+          return func_sp.get();
         }
+      }
     }
+  }
 
-    return NULL;
+  return NULL;
 }
 
 lldb_private::CompilerDeclContext
-DWARFASTParserOCaml::GetDeclContextForUIDFromDWARF (const DWARFDIE &die)
-{
-    return CompilerDeclContext();
+DWARFASTParserOCaml::GetDeclContextForUIDFromDWARF(const DWARFDIE &die) {
+  return CompilerDeclContext();
 }
 
 lldb_private::CompilerDeclContext
-DWARFASTParserOCaml::GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die)
-{
-    return CompilerDeclContext();
+DWARFASTParserOCaml::GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) {
+  return CompilerDeclContext();
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.h Tue Sep  6 15:57:50 2016
@@ -5,8 +5,8 @@
 
 #include "DWARFASTParser.h"
 #include "DWARFCompileUnit.h"
-#include "DWARFDebugInfo.h"
 #include "DWARFDIE.h"
+#include "DWARFDebugInfo.h"
 #include "DWARFDefines.h"
 #include "SymbolFileDWARF.h"
 
@@ -15,46 +15,46 @@
 class DWARFDebugInfoEntry;
 class DWARFDIECollection;
 
-class DWARFASTParserOCaml : public DWARFASTParser
-{
+class DWARFASTParserOCaml : public DWARFASTParser {
 public:
-    DWARFASTParserOCaml (lldb_private::OCamlASTContext &ast);
+  DWARFASTParserOCaml(lldb_private::OCamlASTContext &ast);
 
-    virtual ~DWARFASTParserOCaml ();
+  virtual ~DWARFASTParserOCaml();
 
-    lldb::TypeSP
-    ParseBaseTypeFromDIE(const DWARFDIE &die);
+  lldb::TypeSP ParseBaseTypeFromDIE(const DWARFDIE &die);
 
-    lldb::TypeSP
-    ParseTypeFromDWARF (const lldb_private::SymbolContext& sc,
-                        const DWARFDIE &die,
-                        lldb_private::Log *log,
-                        bool *type_is_new_ptr) override;
+  lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc,
+                                  const DWARFDIE &die, lldb_private::Log *log,
+                                  bool *type_is_new_ptr) override;
 
-    lldb_private::Function *
-    ParseFunctionFromDWARF (const lldb_private::SymbolContext& sc,
-                            const DWARFDIE &die) override;
+  lldb_private::Function *
+  ParseFunctionFromDWARF(const lldb_private::SymbolContext &sc,
+                         const DWARFDIE &die) override;
 
-    bool
-    CompleteTypeFromDWARF (const DWARFDIE &die,
-                           lldb_private::Type *type,
-                           lldb_private::CompilerType &compiler_type) override { return false; }
+  bool
+  CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type,
+                        lldb_private::CompilerType &compiler_type) override {
+    return false;
+  }
 
-    lldb_private::CompilerDecl
-    GetDeclForUIDFromDWARF (const DWARFDIE &die) override { return lldb_private::CompilerDecl(); }
+  lldb_private::CompilerDecl
+  GetDeclForUIDFromDWARF(const DWARFDIE &die) override {
+    return lldb_private::CompilerDecl();
+  }
 
-    lldb_private::CompilerDeclContext
-    GetDeclContextForUIDFromDWARF (const DWARFDIE &die) override;
+  lldb_private::CompilerDeclContext
+  GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override;
 
-    lldb_private::CompilerDeclContext
-    GetDeclContextContainingUIDFromDWARF (const DWARFDIE &die) override;
+  lldb_private::CompilerDeclContext
+  GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override;
 
-    std::vector<DWARFDIE>
-    GetDIEForDeclContext (lldb_private::CompilerDeclContext decl_context) override { return {}; }
+  std::vector<DWARFDIE> GetDIEForDeclContext(
+      lldb_private::CompilerDeclContext decl_context) override {
+    return {};
+  }
 
 protected:
-
-    lldb_private::OCamlASTContext &m_ast;
+  lldb_private::OCamlASTContext &m_ast;
 };
 
-#endif  // SymbolFileDWARF_DWARFASTParserOCaml_h_
+#endif // SymbolFileDWARF_DWARFASTParserOCaml_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp Tue Sep  6 15:57:50 2016
@@ -15,103 +15,80 @@
 
 using namespace lldb_private;
 
-DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration() :
-    m_code  (InvalidCode),
-    m_tag   (0),
-    m_has_children (0),
-    m_attributes()
-{
-}
-
-DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration(dw_tag_t tag, uint8_t has_children) :
-    m_code  (InvalidCode),
-    m_tag   (tag),
-    m_has_children (has_children),
-    m_attributes()
-{
-}
-
-bool
-DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor& data, lldb::offset_t* offset_ptr)
-{
-    return Extract(data, offset_ptr, data.GetULEB128(offset_ptr));
-}
-
-bool
-DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor& data, lldb::offset_t *offset_ptr, dw_uleb128_t code)
-{
-    m_code = code;
-    m_attributes.clear();
-    if (m_code)
-    {
-        m_tag = data.GetULEB128(offset_ptr);
-        m_has_children = data.GetU8(offset_ptr);
-
-        while (data.ValidOffset(*offset_ptr))
-        {
-            dw_attr_t attr = data.GetULEB128(offset_ptr);
-            dw_form_t form = data.GetULEB128(offset_ptr);
-
-            if (attr && form)
-                m_attributes.push_back(DWARFAttribute(attr, form));
-            else
-                break;
-        }
+DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration()
+    : m_code(InvalidCode), m_tag(0), m_has_children(0), m_attributes() {}
 
-        return m_tag != 0;
-    }
-    else
-    {
-        m_tag = 0;
-        m_has_children = 0;
+DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration(dw_tag_t tag,
+                                                           uint8_t has_children)
+    : m_code(InvalidCode), m_tag(tag), m_has_children(has_children),
+      m_attributes() {}
+
+bool DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor &data,
+                                           lldb::offset_t *offset_ptr) {
+  return Extract(data, offset_ptr, data.GetULEB128(offset_ptr));
+}
+
+bool DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor &data,
+                                           lldb::offset_t *offset_ptr,
+                                           dw_uleb128_t code) {
+  m_code = code;
+  m_attributes.clear();
+  if (m_code) {
+    m_tag = data.GetULEB128(offset_ptr);
+    m_has_children = data.GetU8(offset_ptr);
+
+    while (data.ValidOffset(*offset_ptr)) {
+      dw_attr_t attr = data.GetULEB128(offset_ptr);
+      dw_form_t form = data.GetULEB128(offset_ptr);
+
+      if (attr && form)
+        m_attributes.push_back(DWARFAttribute(attr, form));
+      else
+        break;
     }
 
-    return false;
-}
+    return m_tag != 0;
+  } else {
+    m_tag = 0;
+    m_has_children = 0;
+  }
 
+  return false;
+}
 
-void
-DWARFAbbreviationDeclaration::Dump(Stream *s)  const
-{
-    s->Printf("Debug Abbreviation Declaration: code = 0x%4.4x, tag = %s, has_children = %s\n", m_code, DW_TAG_value_to_name(m_tag), DW_CHILDREN_value_to_name(m_has_children));
+void DWARFAbbreviationDeclaration::Dump(Stream *s) const {
+  s->Printf("Debug Abbreviation Declaration: code = 0x%4.4x, tag = %s, "
+            "has_children = %s\n",
+            m_code, DW_TAG_value_to_name(m_tag),
+            DW_CHILDREN_value_to_name(m_has_children));
 
-    DWARFAttribute::const_iterator pos;
+  DWARFAttribute::const_iterator pos;
 
-    for (pos = m_attributes.begin(); pos != m_attributes.end(); ++pos)
-        s->Printf("        attr = %s, form = %s\n", DW_AT_value_to_name(pos->get_attr()), DW_FORM_value_to_name(pos->get_form()));
+  for (pos = m_attributes.begin(); pos != m_attributes.end(); ++pos)
+    s->Printf("        attr = %s, form = %s\n",
+              DW_AT_value_to_name(pos->get_attr()),
+              DW_FORM_value_to_name(pos->get_form()));
 
-    s->Printf("\n");
+  s->Printf("\n");
 }
 
-
-
-bool
-DWARFAbbreviationDeclaration::IsValid()
-{
-    return m_code != 0 && m_tag != 0;
+bool DWARFAbbreviationDeclaration::IsValid() {
+  return m_code != 0 && m_tag != 0;
 }
 
-
-
 uint32_t
-DWARFAbbreviationDeclaration::FindAttributeIndex(dw_attr_t attr) const
-{
-    uint32_t i;
-    const uint32_t kNumAttributes = m_attributes.size();
-    for (i = 0; i < kNumAttributes; ++i)
-    {
-        if (m_attributes[i].get_attr() == attr)
-            return i;
-    }
-    return DW_INVALID_INDEX;
+DWARFAbbreviationDeclaration::FindAttributeIndex(dw_attr_t attr) const {
+  uint32_t i;
+  const uint32_t kNumAttributes = m_attributes.size();
+  for (i = 0; i < kNumAttributes; ++i) {
+    if (m_attributes[i].get_attr() == attr)
+      return i;
+  }
+  return DW_INVALID_INDEX;
 }
 
-
-bool
-DWARFAbbreviationDeclaration::operator == (const DWARFAbbreviationDeclaration& rhs) const
-{
-    return Tag()            == rhs.Tag()
-        && HasChildren()    == rhs.HasChildren()
-        && Attributes()     == rhs.Attributes();
+bool DWARFAbbreviationDeclaration::
+operator==(const DWARFAbbreviationDeclaration &rhs) const {
+  return Tag() == rhs.Tag() && HasChildren() == rhs.HasChildren() &&
+         Attributes() == rhs.Attributes();
 }
-

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h Tue Sep  6 15:57:50 2016
@@ -10,63 +10,66 @@
 #ifndef liblldb_DWARFAbbreviationDeclaration_h_
 #define liblldb_DWARFAbbreviationDeclaration_h_
 
-#include "SymbolFileDWARF.h"
 #include "DWARFAttribute.h"
+#include "SymbolFileDWARF.h"
 
 class DWARFCompileUnit;
 
-class DWARFAbbreviationDeclaration
-{
+class DWARFAbbreviationDeclaration {
 public:
-    enum { InvalidCode = 0 };
-                    DWARFAbbreviationDeclaration();
+  enum { InvalidCode = 0 };
+  DWARFAbbreviationDeclaration();
+
+  // For hand crafting an abbreviation declaration
+  DWARFAbbreviationDeclaration(dw_tag_t tag, uint8_t has_children);
+  void AddAttribute(const DWARFAttribute &attr) {
+    m_attributes.push_back(attr);
+  }
+
+  dw_uleb128_t Code() const { return m_code; }
+  void SetCode(dw_uleb128_t code) { m_code = code; }
+  dw_tag_t Tag() const { return m_tag; }
+  bool HasChildren() const { return m_has_children; }
+  size_t NumAttributes() const { return m_attributes.size(); }
+  dw_attr_t GetAttrByIndex(uint32_t idx) const {
+    return m_attributes.size() > idx ? m_attributes[idx].get_attr() : 0;
+  }
+  dw_form_t GetFormByIndex(uint32_t idx) const {
+    return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0;
+  }
+  bool GetAttrAndFormByIndex(uint32_t idx, dw_attr_t &attr,
+                             dw_form_t &form) const {
+    if (m_attributes.size() > idx) {
+      m_attributes[idx].get(attr, form);
+      return true;
+    }
+    attr = form = 0;
+    return false;
+  }
+
+  // idx is assumed to be valid when calling GetAttrAndFormByIndexUnchecked()
+  void GetAttrAndFormByIndexUnchecked(uint32_t idx, dw_attr_t &attr,
+                                      dw_form_t &form) const {
+    m_attributes[idx].get(attr, form);
+  }
+  dw_form_t GetFormByIndexUnchecked(uint32_t idx) const {
+    return m_attributes[idx].get_form();
+  }
+  uint32_t FindAttributeIndex(dw_attr_t attr) const;
+  bool Extract(const lldb_private::DWARFDataExtractor &data,
+               lldb::offset_t *offset_ptr);
+  bool Extract(const lldb_private::DWARFDataExtractor &data,
+               lldb::offset_t *offset_ptr, dw_uleb128_t code);
+  bool IsValid();
+  void Dump(lldb_private::Stream *s) const;
+  bool operator==(const DWARFAbbreviationDeclaration &rhs) const;
+  const DWARFAttribute::collection &Attributes() const { return m_attributes; }
 
-                    // For hand crafting an abbreviation declaration
-                    DWARFAbbreviationDeclaration(dw_tag_t tag, uint8_t has_children);
-    void            AddAttribute(const DWARFAttribute& attr)
-                    {
-                        m_attributes.push_back(attr);
-                    }
-
-    dw_uleb128_t    Code() const { return m_code; }
-    void            SetCode(dw_uleb128_t code) { m_code = code; }
-    dw_tag_t        Tag() const { return m_tag; }
-    bool            HasChildren() const { return m_has_children; }
-    size_t          NumAttributes() const { return m_attributes.size(); }
-    dw_attr_t       GetAttrByIndex(uint32_t idx) const { return m_attributes.size() > idx ? m_attributes[idx].get_attr() : 0; }
-    dw_form_t       GetFormByIndex(uint32_t idx) const { return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0; }
-    bool            GetAttrAndFormByIndex(uint32_t idx, dw_attr_t& attr, dw_form_t& form) const
-                    {
-                        if (m_attributes.size() > idx)
-                        {
-                            m_attributes[idx].get(attr, form);
-                            return true;
-                        }
-                        attr = form = 0;
-                        return false;
-                    }
-
-                    // idx is assumed to be valid when calling GetAttrAndFormByIndexUnchecked()
-    void            GetAttrAndFormByIndexUnchecked(uint32_t idx, dw_attr_t& attr, dw_form_t& form) const
-                    {
-                        m_attributes[idx].get(attr, form);
-                    }
-    dw_form_t       GetFormByIndexUnchecked (uint32_t idx) const
-                    {
-                        return m_attributes[idx].get_form();
-                    }
-    uint32_t        FindAttributeIndex(dw_attr_t attr) const;
-    bool            Extract(const lldb_private::DWARFDataExtractor& data, lldb::offset_t *offset_ptr);
-    bool            Extract(const lldb_private::DWARFDataExtractor& data, lldb::offset_t *offset_ptr, dw_uleb128_t code);
-    bool            IsValid();
-    void            Dump(lldb_private::Stream *s) const;
-    bool            operator == (const DWARFAbbreviationDeclaration& rhs) const;
-    const DWARFAttribute::collection& Attributes() const { return m_attributes; }
 protected:
-    dw_uleb128_t        m_code;
-    dw_tag_t            m_tag;
-    uint8_t             m_has_children;
-    DWARFAttribute::collection m_attributes;
+  dw_uleb128_t m_code;
+  dw_tag_t m_tag;
+  uint8_t m_has_children;
+  DWARFAttribute::collection m_attributes;
 };
 
-#endif  // liblldb_DWARFAbbreviationDeclaration_h_
+#endif // liblldb_DWARFAbbreviationDeclaration_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp Tue Sep  6 15:57:50 2016
@@ -8,83 +8,67 @@
 //===----------------------------------------------------------------------===//
 
 #include "DWARFAttribute.h"
-#include "DWARFDebugInfo.h"
 #include "DWARFCompileUnit.h"
+#include "DWARFDebugInfo.h"
 
-DWARFAttributes::DWARFAttributes() :
-    m_infos()
-{
-}
-
-DWARFAttributes::~DWARFAttributes()
-{
-}
+DWARFAttributes::DWARFAttributes() : m_infos() {}
 
+DWARFAttributes::~DWARFAttributes() {}
 
-uint32_t
-DWARFAttributes::FindAttributeIndex(dw_attr_t attr) const
-{
-    collection::const_iterator end = m_infos.end();
-    collection::const_iterator beg = m_infos.begin();
-    collection::const_iterator pos;
-    for (pos = beg; pos != end; ++pos)
-    {
-        if (pos->attr.get_attr() == attr)
-            return std::distance(beg, pos);
-    }
-    return UINT32_MAX;
-}
-
-void
-DWARFAttributes::Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form)
-{
-    AttributeValue attr_value = { cu, attr_die_offset, { attr, form } };
-    m_infos.push_back(attr_value);
-}
-
-bool
-DWARFAttributes::ContainsAttribute(dw_attr_t attr) const
-{
-    return FindAttributeIndex(attr) != UINT32_MAX;
-}
-
-bool
-DWARFAttributes::RemoveAttribute(dw_attr_t attr)
-{
-    uint32_t attr_index = FindAttributeIndex(attr);
-    if (attr_index != UINT32_MAX)
-    {
-        m_infos.erase(m_infos.begin() + attr_index);
-        return true;
-    }
-    return false;
-}
-
-bool
-DWARFAttributes::ExtractFormValueAtIndex (uint32_t i, DWARFFormValue &form_value) const
-{
-    const DWARFCompileUnit *cu = CompileUnitAtIndex(i);
-    form_value.SetCompileUnit(cu);
-    form_value.SetForm(FormAtIndex(i));
-    lldb::offset_t offset = DIEOffsetAtIndex(i);
-    return form_value.ExtractValue(cu->GetSymbolFileDWARF()->get_debug_info_data(), &offset);
+uint32_t DWARFAttributes::FindAttributeIndex(dw_attr_t attr) const {
+  collection::const_iterator end = m_infos.end();
+  collection::const_iterator beg = m_infos.begin();
+  collection::const_iterator pos;
+  for (pos = beg; pos != end; ++pos) {
+    if (pos->attr.get_attr() == attr)
+      return std::distance(beg, pos);
+  }
+  return UINT32_MAX;
+}
+
+void DWARFAttributes::Append(const DWARFCompileUnit *cu,
+                             dw_offset_t attr_die_offset, dw_attr_t attr,
+                             dw_form_t form) {
+  AttributeValue attr_value = {cu, attr_die_offset, {attr, form}};
+  m_infos.push_back(attr_value);
+}
+
+bool DWARFAttributes::ContainsAttribute(dw_attr_t attr) const {
+  return FindAttributeIndex(attr) != UINT32_MAX;
+}
+
+bool DWARFAttributes::RemoveAttribute(dw_attr_t attr) {
+  uint32_t attr_index = FindAttributeIndex(attr);
+  if (attr_index != UINT32_MAX) {
+    m_infos.erase(m_infos.begin() + attr_index);
+    return true;
+  }
+  return false;
+}
+
+bool DWARFAttributes::ExtractFormValueAtIndex(
+    uint32_t i, DWARFFormValue &form_value) const {
+  const DWARFCompileUnit *cu = CompileUnitAtIndex(i);
+  form_value.SetCompileUnit(cu);
+  form_value.SetForm(FormAtIndex(i));
+  lldb::offset_t offset = DIEOffsetAtIndex(i);
+  return form_value.ExtractValue(
+      cu->GetSymbolFileDWARF()->get_debug_info_data(), &offset);
+}
+
+uint64_t DWARFAttributes::FormValueAsUnsigned(dw_attr_t attr,
+                                              uint64_t fail_value) const {
+  const uint32_t attr_idx = FindAttributeIndex(attr);
+  if (attr_idx != UINT32_MAX)
+    return FormValueAsUnsignedAtIndex(attr_idx, fail_value);
+  return fail_value;
 }
 
 uint64_t
-DWARFAttributes::FormValueAsUnsigned (dw_attr_t attr, uint64_t fail_value) const
-{
-    const uint32_t attr_idx = FindAttributeIndex (attr);
-    if (attr_idx != UINT32_MAX)
-        return FormValueAsUnsignedAtIndex (attr_idx, fail_value);
-    return fail_value;
+DWARFAttributes::FormValueAsUnsignedAtIndex(uint32_t i,
+                                            uint64_t fail_value) const {
+  DWARFFormValue form_value;
+  if (ExtractFormValueAtIndex(i, form_value))
+    return form_value.Reference();
+  return fail_value;
 }
-
-uint64_t
-DWARFAttributes::FormValueAsUnsignedAtIndex(uint32_t i, uint64_t fail_value) const
-{
-    DWARFFormValue form_value;
-    if (ExtractFormValueAtIndex(i, form_value))
-        return form_value.Reference();
-    return fail_value;
-}
-

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h Tue Sep  6 15:57:50 2016
@@ -10,72 +10,76 @@
 #ifndef SymbolFileDWARF_DWARFAttribute_h_
 #define SymbolFileDWARF_DWARFAttribute_h_
 
-#include "llvm/ADT/SmallVector.h"
 #include "DWARFDefines.h"
+#include "llvm/ADT/SmallVector.h"
 #include <vector>
 
 class DWARFCompileUnit;
 class DWARFFormValue;
 
-class DWARFAttribute
-{
+class DWARFAttribute {
 public:
-    DWARFAttribute(dw_attr_t attr, dw_form_t form) :
-        m_attr (attr),
-        m_form (form)
-    {
-    }
-
-    void        set (dw_attr_t attr, dw_form_t form) { m_attr = attr; m_form = form; }
-    void        set_attr (dw_attr_t attr) { m_attr = attr; }
-    void        set_form (dw_form_t form) { m_form = form; }
-    dw_attr_t   get_attr () const { return m_attr; }
-    dw_form_t   get_form () const { return m_form; }
-    void        get (dw_attr_t& attr, dw_form_t& form)  const
-    {
-        attr = m_attr;
-        form = m_form;
-    }
-    bool operator == (const DWARFAttribute& rhs) const { return m_attr == rhs.m_attr && m_form == rhs.m_form; }
-    typedef std::vector<DWARFAttribute> collection;
-    typedef collection::iterator iterator;
-    typedef collection::const_iterator const_iterator;
+  DWARFAttribute(dw_attr_t attr, dw_form_t form) : m_attr(attr), m_form(form) {}
+
+  void set(dw_attr_t attr, dw_form_t form) {
+    m_attr = attr;
+    m_form = form;
+  }
+  void set_attr(dw_attr_t attr) { m_attr = attr; }
+  void set_form(dw_form_t form) { m_form = form; }
+  dw_attr_t get_attr() const { return m_attr; }
+  dw_form_t get_form() const { return m_form; }
+  void get(dw_attr_t &attr, dw_form_t &form) const {
+    attr = m_attr;
+    form = m_form;
+  }
+  bool operator==(const DWARFAttribute &rhs) const {
+    return m_attr == rhs.m_attr && m_form == rhs.m_form;
+  }
+  typedef std::vector<DWARFAttribute> collection;
+  typedef collection::iterator iterator;
+  typedef collection::const_iterator const_iterator;
 
 protected:
-    dw_attr_t m_attr;
-    dw_form_t m_form;
+  dw_attr_t m_attr;
+  dw_form_t m_form;
 };
 
-
-class DWARFAttributes
-{
+class DWARFAttributes {
 public:
-    DWARFAttributes();
-    ~DWARFAttributes();
+  DWARFAttributes();
+  ~DWARFAttributes();
 
-    void Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset, dw_attr_t attr, dw_form_t form);
-    const DWARFCompileUnit * CompileUnitAtIndex(uint32_t i) const { return m_infos[i].cu; }
-    dw_offset_t DIEOffsetAtIndex(uint32_t i) const { return m_infos[i].die_offset; }
-    dw_attr_t AttributeAtIndex(uint32_t i) const { return m_infos[i].attr.get_attr(); }
-    dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
-    bool ExtractFormValueAtIndex (uint32_t i, DWARFFormValue &form_value) const;
-    uint64_t FormValueAsUnsignedAtIndex (uint32_t i, uint64_t fail_value) const;
-    uint64_t FormValueAsUnsigned (dw_attr_t attr, uint64_t fail_value) const;
-    uint32_t FindAttributeIndex(dw_attr_t attr) const;
-    bool ContainsAttribute(dw_attr_t attr) const;
-    bool RemoveAttribute(dw_attr_t attr);
-    void Clear() { m_infos.clear(); }
-    size_t Size() const { return m_infos.size(); }
+  void Append(const DWARFCompileUnit *cu, dw_offset_t attr_die_offset,
+              dw_attr_t attr, dw_form_t form);
+  const DWARFCompileUnit *CompileUnitAtIndex(uint32_t i) const {
+    return m_infos[i].cu;
+  }
+  dw_offset_t DIEOffsetAtIndex(uint32_t i) const {
+    return m_infos[i].die_offset;
+  }
+  dw_attr_t AttributeAtIndex(uint32_t i) const {
+    return m_infos[i].attr.get_attr();
+  }
+  dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
+  bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const;
+  uint64_t FormValueAsUnsignedAtIndex(uint32_t i, uint64_t fail_value) const;
+  uint64_t FormValueAsUnsigned(dw_attr_t attr, uint64_t fail_value) const;
+  uint32_t FindAttributeIndex(dw_attr_t attr) const;
+  bool ContainsAttribute(dw_attr_t attr) const;
+  bool RemoveAttribute(dw_attr_t attr);
+  void Clear() { m_infos.clear(); }
+  size_t Size() const { return m_infos.size(); }
 
 protected:
-    struct AttributeValue
-    {
-        const DWARFCompileUnit *cu; // Keep the compile unit with each attribute in case we have DW_FORM_ref_addr values
-        dw_offset_t die_offset;
-        DWARFAttribute attr;
-    };
-    typedef llvm::SmallVector<AttributeValue, 8> collection;
-    collection m_infos;
+  struct AttributeValue {
+    const DWARFCompileUnit *cu; // Keep the compile unit with each attribute in
+                                // case we have DW_FORM_ref_addr values
+    dw_offset_t die_offset;
+    DWARFAttribute attr;
+  };
+  typedef llvm::SmallVector<AttributeValue, 8> collection;
+  collection m_infos;
 };
 
-#endif  // SymbolFileDWARF_DWARFAttribute_h_
+#endif // SymbolFileDWARF_DWARFAttribute_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Tue Sep  6 15:57:50 2016
@@ -9,6 +9,7 @@
 
 #include "DWARFCompileUnit.h"
 
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
 #include "lldb/Core/Mangled.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Stream.h"
@@ -18,130 +19,108 @@
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/ObjectFile.h"
-#include "Plugins/Language/ObjC/ObjCLanguage.h"
 
+#include "DWARFDIECollection.h"
 #include "DWARFDebugAbbrev.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
-#include "DWARFDIECollection.h"
 #include "DWARFFormValue.h"
 #include "LogChannelDWARF.h"
 #include "NameToDIE.h"
 #include "SymbolFileDWARF.h"
-#include "SymbolFileDWARFDwo.h"
 #include "SymbolFileDWARFDebugMap.h"
+#include "SymbolFileDWARFDwo.h"
 
 using namespace lldb;
 using namespace lldb_private;
 using namespace std;
 
-
 extern int g_verbose;
 
-DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF* dwarf2Data) :
-    m_dwarf2Data    (dwarf2Data),
-    m_abbrevs       (NULL),
-    m_user_data     (NULL),
-    m_die_array     (),
-    m_func_aranges_ap (),
-    m_base_addr     (0),
-    m_offset        (DW_INVALID_OFFSET),
-    m_length        (0),
-    m_version       (0),
-    m_addr_size     (DWARFCompileUnit::GetDefaultAddressSize()),
-    m_producer      (eProducerInvalid),
-    m_producer_version_major (0),
-    m_producer_version_minor (0),
-    m_producer_version_update (0),
-    m_language_type (eLanguageTypeUnknown),
-    m_is_dwarf64    (false),
-    m_is_optimized  (eLazyBoolCalculate),
-    m_addr_base (0),
-    m_base_obj_offset (DW_INVALID_OFFSET)
-{
-}
-
-DWARFCompileUnit::~DWARFCompileUnit()
-{}
-
-void
-DWARFCompileUnit::Clear()
-{
-    m_offset        = DW_INVALID_OFFSET;
-    m_length        = 0;
-    m_version       = 0;
-    m_abbrevs       = NULL;
-    m_addr_size     = DWARFCompileUnit::GetDefaultAddressSize();
-    m_base_addr     = 0;
-    m_die_array.clear();
-    m_func_aranges_ap.reset();
-    m_user_data     = NULL;
-    m_producer      = eProducerInvalid;
-    m_language_type = eLanguageTypeUnknown;
-    m_is_dwarf64    = false;
-    m_is_optimized  = eLazyBoolCalculate;
-    m_addr_base     = 0;
-    m_base_obj_offset = DW_INVALID_OFFSET;
-}
-
-bool
-DWARFCompileUnit::Extract(const DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr)
-{
-    Clear();
-
-    m_offset = *offset_ptr;
-
-    if (debug_info.ValidOffset(*offset_ptr))
-    {
-        dw_offset_t abbr_offset;
-        const DWARFDebugAbbrev *abbr = m_dwarf2Data->DebugAbbrev();
-        m_length        = debug_info.GetDWARFInitialLength(offset_ptr);
-        m_is_dwarf64    = debug_info.IsDWARF64();
-        m_version       = debug_info.GetU16(offset_ptr);
-        abbr_offset     = debug_info.GetDWARFOffset(offset_ptr);
-        m_addr_size     = debug_info.GetU8 (offset_ptr);
-
-        bool length_OK = debug_info.ValidOffset(GetNextCompileUnitOffset()-1);
-        bool version_OK = SymbolFileDWARF::SupportedVersion(m_version);
-        bool abbr_offset_OK = m_dwarf2Data->get_debug_abbrev_data().ValidOffset(abbr_offset);
-        bool addr_size_OK = ((m_addr_size == 4) || (m_addr_size == 8));
-
-        if (length_OK && version_OK && addr_size_OK && abbr_offset_OK && abbr != NULL)
-        {
-            m_abbrevs = abbr->GetAbbreviationDeclarationSet(abbr_offset);
-            return true;
-        }
-
-        // reset the offset to where we tried to parse from if anything went wrong
-        *offset_ptr = m_offset;
-    }
-
-    return false;
-}
+DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF *dwarf2Data)
+    : m_dwarf2Data(dwarf2Data), m_abbrevs(NULL), m_user_data(NULL),
+      m_die_array(), m_func_aranges_ap(), m_base_addr(0),
+      m_offset(DW_INVALID_OFFSET), m_length(0), m_version(0),
+      m_addr_size(DWARFCompileUnit::GetDefaultAddressSize()),
+      m_producer(eProducerInvalid), m_producer_version_major(0),
+      m_producer_version_minor(0), m_producer_version_update(0),
+      m_language_type(eLanguageTypeUnknown), m_is_dwarf64(false),
+      m_is_optimized(eLazyBoolCalculate), m_addr_base(0),
+      m_base_obj_offset(DW_INVALID_OFFSET) {}
+
+DWARFCompileUnit::~DWARFCompileUnit() {}
+
+void DWARFCompileUnit::Clear() {
+  m_offset = DW_INVALID_OFFSET;
+  m_length = 0;
+  m_version = 0;
+  m_abbrevs = NULL;
+  m_addr_size = DWARFCompileUnit::GetDefaultAddressSize();
+  m_base_addr = 0;
+  m_die_array.clear();
+  m_func_aranges_ap.reset();
+  m_user_data = NULL;
+  m_producer = eProducerInvalid;
+  m_language_type = eLanguageTypeUnknown;
+  m_is_dwarf64 = false;
+  m_is_optimized = eLazyBoolCalculate;
+  m_addr_base = 0;
+  m_base_obj_offset = DW_INVALID_OFFSET;
+}
+
+bool DWARFCompileUnit::Extract(const DWARFDataExtractor &debug_info,
+                               lldb::offset_t *offset_ptr) {
+  Clear();
+
+  m_offset = *offset_ptr;
+
+  if (debug_info.ValidOffset(*offset_ptr)) {
+    dw_offset_t abbr_offset;
+    const DWARFDebugAbbrev *abbr = m_dwarf2Data->DebugAbbrev();
+    m_length = debug_info.GetDWARFInitialLength(offset_ptr);
+    m_is_dwarf64 = debug_info.IsDWARF64();
+    m_version = debug_info.GetU16(offset_ptr);
+    abbr_offset = debug_info.GetDWARFOffset(offset_ptr);
+    m_addr_size = debug_info.GetU8(offset_ptr);
 
+    bool length_OK = debug_info.ValidOffset(GetNextCompileUnitOffset() - 1);
+    bool version_OK = SymbolFileDWARF::SupportedVersion(m_version);
+    bool abbr_offset_OK =
+        m_dwarf2Data->get_debug_abbrev_data().ValidOffset(abbr_offset);
+    bool addr_size_OK = ((m_addr_size == 4) || (m_addr_size == 8));
 
-void
-DWARFCompileUnit::ClearDIEs(bool keep_compile_unit_die)
-{
-    if (m_die_array.size() > 1)
-    {
-        // std::vectors never get any smaller when resized to a smaller size,
-        // or when clear() or erase() are called, the size will report that it
-        // is smaller, but the memory allocated remains intact (call capacity()
-        // to see this). So we need to create a temporary vector and swap the
-        // contents which will cause just the internal pointers to be swapped
-        // so that when "tmp_array" goes out of scope, it will destroy the
-        // contents.
-
-        // Save at least the compile unit DIE
-        DWARFDebugInfoEntry::collection tmp_array;
-        m_die_array.swap(tmp_array);
-        if (keep_compile_unit_die)
-            m_die_array.push_back(tmp_array.front());
-    }
+    if (length_OK && version_OK && addr_size_OK && abbr_offset_OK &&
+        abbr != NULL) {
+      m_abbrevs = abbr->GetAbbreviationDeclarationSet(abbr_offset);
+      return true;
+    }
+
+    // reset the offset to where we tried to parse from if anything went wrong
+    *offset_ptr = m_offset;
+  }
+
+  return false;
+}
+
+void DWARFCompileUnit::ClearDIEs(bool keep_compile_unit_die) {
+  if (m_die_array.size() > 1) {
+    // std::vectors never get any smaller when resized to a smaller size,
+    // or when clear() or erase() are called, the size will report that it
+    // is smaller, but the memory allocated remains intact (call capacity()
+    // to see this). So we need to create a temporary vector and swap the
+    // contents which will cause just the internal pointers to be swapped
+    // so that when "tmp_array" goes out of scope, it will destroy the
+    // contents.
+
+    // Save at least the compile unit DIE
+    DWARFDebugInfoEntry::collection tmp_array;
+    m_die_array.swap(tmp_array);
+    if (keep_compile_unit_die)
+      m_die_array.push_back(tmp_array.front());
+  }
 
-    if (m_dwo_symbol_file)
-        m_dwo_symbol_file->GetCompileUnit()->ClearDIEs(keep_compile_unit_die);
+  if (m_dwo_symbol_file)
+    m_dwo_symbol_file->GetCompileUnit()->ClearDIEs(keep_compile_unit_die);
 }
 
 //----------------------------------------------------------------------
@@ -150,454 +129,420 @@ DWARFCompileUnit::ClearDIEs(bool keep_co
 // Parses a compile unit and indexes its DIEs if it hasn't already been
 // done.
 //----------------------------------------------------------------------
-size_t
-DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only)
-{
-    const size_t initial_die_array_size = m_die_array.size();
-    if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 1)
-        return 0; // Already parsed
-
-    Timer scoped_timer (LLVM_PRETTY_FUNCTION,
-                        "%8.8x: DWARFCompileUnit::ExtractDIEsIfNeeded( cu_die_only = %i )",
-                        m_offset,
-                        cu_die_only);
-
-    // Set the offset to that of the first DIE and calculate the start of the
-    // next compilation unit header.
-    lldb::offset_t offset = GetFirstDIEOffset();
-    lldb::offset_t next_cu_offset = GetNextCompileUnitOffset();
-
-    DWARFDebugInfoEntry die;
-        // Keep a flat array of the DIE for binary lookup by DIE offset
-    if (!cu_die_only)
-    {
-        Log *log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | DWARF_LOG_LOOKUPS));
-        if (log)
-        {
-            m_dwarf2Data->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log,
-                                                                                    "DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at .debug_info[0x%8.8x]",
-                                                                                    GetOffset());
-        }
-    }
-
-    uint32_t depth = 0;
-    // We are in our compile unit, parse starting at the offset
-    // we were told to parse
-    const DWARFDataExtractor& debug_info_data = m_dwarf2Data->get_debug_info_data();
-    std::vector<uint32_t> die_index_stack;
-    die_index_stack.reserve(32);
-    die_index_stack.push_back(0);
-    bool prev_die_had_children = false;
-    DWARFFormValue::FixedFormSizes fixed_form_sizes =
-        DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), m_is_dwarf64);
-    while (offset < next_cu_offset &&
-           die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset))
-    {
-//        if (log)
-//            log->Printf("0x%8.8x: %*.*s%s%s",
-//                        die.GetOffset(),
-//                        depth * 2, depth * 2, "",
-//                        DW_TAG_value_to_name (die.Tag()),
-//                        die.HasChildren() ? " *" : "");
-
-        const bool null_die = die.IsNULL();
-        if (depth == 0)
-        {
-            if (initial_die_array_size == 0)
-                AddCompileUnitDIE(die);
-            uint64_t base_addr = die.GetAttributeValueAsAddress(m_dwarf2Data, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
-            if (base_addr == LLDB_INVALID_ADDRESS)
-                base_addr = die.GetAttributeValueAsAddress(m_dwarf2Data, this, DW_AT_entry_pc, 0);
-            SetBaseAddress (base_addr);
-            if (cu_die_only)
-                return 1;
+size_t DWARFCompileUnit::ExtractDIEsIfNeeded(bool cu_die_only) {
+  const size_t initial_die_array_size = m_die_array.size();
+  if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 1)
+    return 0; // Already parsed
+
+  Timer scoped_timer(
+      LLVM_PRETTY_FUNCTION,
+      "%8.8x: DWARFCompileUnit::ExtractDIEsIfNeeded( cu_die_only = %i )",
+      m_offset, cu_die_only);
+
+  // Set the offset to that of the first DIE and calculate the start of the
+  // next compilation unit header.
+  lldb::offset_t offset = GetFirstDIEOffset();
+  lldb::offset_t next_cu_offset = GetNextCompileUnitOffset();
+
+  DWARFDebugInfoEntry die;
+  // Keep a flat array of the DIE for binary lookup by DIE offset
+  if (!cu_die_only) {
+    Log *log(
+        LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | DWARF_LOG_LOOKUPS));
+    if (log) {
+      m_dwarf2Data->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace(
+          log, "DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at "
+               ".debug_info[0x%8.8x]",
+          GetOffset());
+    }
+  }
+
+  uint32_t depth = 0;
+  // We are in our compile unit, parse starting at the offset
+  // we were told to parse
+  const DWARFDataExtractor &debug_info_data =
+      m_dwarf2Data->get_debug_info_data();
+  std::vector<uint32_t> die_index_stack;
+  die_index_stack.reserve(32);
+  die_index_stack.push_back(0);
+  bool prev_die_had_children = false;
+  DWARFFormValue::FixedFormSizes fixed_form_sizes =
+      DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
+                                                      m_is_dwarf64);
+  while (offset < next_cu_offset &&
+         die.FastExtract(debug_info_data, this, fixed_form_sizes, &offset)) {
+    //        if (log)
+    //            log->Printf("0x%8.8x: %*.*s%s%s",
+    //                        die.GetOffset(),
+    //                        depth * 2, depth * 2, "",
+    //                        DW_TAG_value_to_name (die.Tag()),
+    //                        die.HasChildren() ? " *" : "");
+
+    const bool null_die = die.IsNULL();
+    if (depth == 0) {
+      if (initial_die_array_size == 0)
+        AddCompileUnitDIE(die);
+      uint64_t base_addr = die.GetAttributeValueAsAddress(
+          m_dwarf2Data, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
+      if (base_addr == LLDB_INVALID_ADDRESS)
+        base_addr = die.GetAttributeValueAsAddress(m_dwarf2Data, this,
+                                                   DW_AT_entry_pc, 0);
+      SetBaseAddress(base_addr);
+      if (cu_die_only)
+        return 1;
+    } else {
+      if (null_die) {
+        if (prev_die_had_children) {
+          // This will only happen if a DIE says is has children
+          // but all it contains is a NULL tag. Since we are removing
+          // the NULL DIEs from the list (saves up to 25% in C++ code),
+          // we need a way to let the DIE know that it actually doesn't
+          // have children.
+          if (!m_die_array.empty())
+            m_die_array.back().SetEmptyChildren(true);
         }
-        else
-        {
-            if (null_die)
-            {
-                if (prev_die_had_children)
-                {
-                    // This will only happen if a DIE says is has children
-                    // but all it contains is a NULL tag. Since we are removing
-                    // the NULL DIEs from the list (saves up to 25% in C++ code),
-                    // we need a way to let the DIE know that it actually doesn't
-                    // have children.
-                    if (!m_die_array.empty())
-                        m_die_array.back().SetEmptyChildren(true);
-                }
-            }
-            else
-            {
-                die.SetParentIndex(m_die_array.size() - die_index_stack[depth-1]);
-
-                if (die_index_stack.back())
-                    m_die_array[die_index_stack.back()].SetSiblingIndex(m_die_array.size()-die_index_stack.back());
-                
-                // Only push the DIE if it isn't a NULL DIE
-                    m_die_array.push_back(die);
-            }
-        }
-
-        if (null_die)
-        {
-            // NULL DIE.
-            if (!die_index_stack.empty())
-                die_index_stack.pop_back();
-
-            if (depth > 0)
-                --depth;
-            if (depth == 0)
-                break;  // We are done with this compile unit!
-
-            prev_die_had_children = false;
-        }
-        else
-        {
-            die_index_stack.back() = m_die_array.size() - 1;
-            // Normal DIE
-            const bool die_has_children = die.HasChildren();
-            if (die_has_children)
-            {
-                die_index_stack.push_back(0);
-                ++depth;
-            }
-            prev_die_had_children = die_has_children;
-        }
-    }
-
-    // Give a little bit of info if we encounter corrupt DWARF (our offset
-    // should always terminate at or before the start of the next compilation
-    // unit header).
-    if (offset > next_cu_offset)
-    {
-        m_dwarf2Data->GetObjectFile()->GetModule()->ReportWarning ("DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8" PRIx64 "\n",
-                                                                   GetOffset(), 
-                                                                   offset);
-    }
+      } else {
+        die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
 
-    // Since std::vector objects will double their size, we really need to
-    // make a new array with the perfect size so we don't end up wasting
-    // space. So here we copy and swap to make sure we don't have any extra
-    // memory taken up.
-    
-    if (m_die_array.size () < m_die_array.capacity())
-    {
-        DWARFDebugInfoEntry::collection exact_size_die_array (m_die_array.begin(), m_die_array.end());
-        exact_size_die_array.swap (m_die_array);
-    }
-    Log *verbose_log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO | DWARF_LOG_VERBOSE));
-    if (verbose_log)
-    {
-        StreamString strm;
-        Dump(&strm);
-        if (m_die_array.empty())
-            strm.Printf("error: no DIE for compile unit");
-        else
-            m_die_array[0].Dump(m_dwarf2Data, this, strm, UINT32_MAX);        
-        verbose_log->PutCString (strm.GetString().c_str());
-    }
-
-    if (!m_dwo_symbol_file)
-        return m_die_array.size();
+        if (die_index_stack.back())
+          m_die_array[die_index_stack.back()].SetSiblingIndex(
+              m_die_array.size() - die_index_stack.back());
+
+        // Only push the DIE if it isn't a NULL DIE
+        m_die_array.push_back(die);
+      }
+    }
+
+    if (null_die) {
+      // NULL DIE.
+      if (!die_index_stack.empty())
+        die_index_stack.pop_back();
+
+      if (depth > 0)
+        --depth;
+      if (depth == 0)
+        break; // We are done with this compile unit!
+
+      prev_die_had_children = false;
+    } else {
+      die_index_stack.back() = m_die_array.size() - 1;
+      // Normal DIE
+      const bool die_has_children = die.HasChildren();
+      if (die_has_children) {
+        die_index_stack.push_back(0);
+        ++depth;
+      }
+      prev_die_had_children = die_has_children;
+    }
+  }
+
+  // Give a little bit of info if we encounter corrupt DWARF (our offset
+  // should always terminate at or before the start of the next compilation
+  // unit header).
+  if (offset > next_cu_offset) {
+    m_dwarf2Data->GetObjectFile()->GetModule()->ReportWarning(
+        "DWARF compile unit extends beyond its bounds cu 0x%8.8x at "
+        "0x%8.8" PRIx64 "\n",
+        GetOffset(), offset);
+  }
+
+  // Since std::vector objects will double their size, we really need to
+  // make a new array with the perfect size so we don't end up wasting
+  // space. So here we copy and swap to make sure we don't have any extra
+  // memory taken up.
+
+  if (m_die_array.size() < m_die_array.capacity()) {
+    DWARFDebugInfoEntry::collection exact_size_die_array(m_die_array.begin(),
+                                                         m_die_array.end());
+    exact_size_die_array.swap(m_die_array);
+  }
+  Log *verbose_log(
+      LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO | DWARF_LOG_VERBOSE));
+  if (verbose_log) {
+    StreamString strm;
+    Dump(&strm);
+    if (m_die_array.empty())
+      strm.Printf("error: no DIE for compile unit");
+    else
+      m_die_array[0].Dump(m_dwarf2Data, this, strm, UINT32_MAX);
+    verbose_log->PutCString(strm.GetString().c_str());
+  }
+
+  if (!m_dwo_symbol_file)
+    return m_die_array.size();
+
+  DWARFCompileUnit *dwo_cu = m_dwo_symbol_file->GetCompileUnit();
+  size_t dwo_die_count = dwo_cu->ExtractDIEsIfNeeded(cu_die_only);
+  return m_die_array.size() + dwo_die_count -
+         1; // We have 2 CU die, but we want to count it only as one
+}
+
+void DWARFCompileUnit::AddCompileUnitDIE(DWARFDebugInfoEntry &die) {
+  assert(m_die_array.empty() && "Compile unit DIE already added");
+  AddDIE(die);
+
+  const DWARFDebugInfoEntry &cu_die = m_die_array.front();
+  std::unique_ptr<SymbolFileDWARFDwo> dwo_symbol_file =
+      m_dwarf2Data->GetDwoSymbolFileForCompileUnit(*this, cu_die);
+  if (!dwo_symbol_file)
+    return;
+
+  DWARFCompileUnit *dwo_cu = dwo_symbol_file->GetCompileUnit();
+  if (!dwo_cu)
+    return; // Can't fetch the compile unit from the dwo file.
+
+  DWARFDIE dwo_cu_die = dwo_cu->GetCompileUnitDIEOnly();
+  if (!dwo_cu_die.IsValid())
+    return; // Can't fetch the compile unit DIE from the dwo file.
+
+  uint64_t main_dwo_id = cu_die.GetAttributeValueAsUnsigned(
+      m_dwarf2Data, this, DW_AT_GNU_dwo_id, 0);
+  uint64_t sub_dwo_id =
+      dwo_cu_die.GetAttributeValueAsUnsigned(DW_AT_GNU_dwo_id, 0);
+  if (main_dwo_id != sub_dwo_id)
+    return; // The 2 dwo ID isn't match. Don't use the dwo file as it belongs to
+            // a differectn compilation.
+
+  m_dwo_symbol_file = std::move(dwo_symbol_file);
+
+  dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(
+      m_dwarf2Data, this, DW_AT_GNU_addr_base, 0);
+  dwo_cu->SetAddrBase(addr_base, m_offset);
+}
+
+dw_offset_t DWARFCompileUnit::GetAbbrevOffset() const {
+  return m_abbrevs ? m_abbrevs->GetOffset() : DW_INVALID_OFFSET;
+}
+
+bool DWARFCompileUnit::Verify(Stream *s) const {
+  const DWARFDataExtractor &debug_info = m_dwarf2Data->get_debug_info_data();
+  bool valid_offset = debug_info.ValidOffset(m_offset);
+  bool length_OK = debug_info.ValidOffset(GetNextCompileUnitOffset() - 1);
+  bool version_OK = SymbolFileDWARF::SupportedVersion(m_version);
+  bool abbr_offset_OK =
+      m_dwarf2Data->get_debug_abbrev_data().ValidOffset(GetAbbrevOffset());
+  bool addr_size_OK = ((m_addr_size == 4) || (m_addr_size == 8));
+  bool verbose = s->GetVerbose();
+  if (valid_offset && length_OK && version_OK && addr_size_OK &&
+      abbr_offset_OK) {
+    if (verbose)
+      s->Printf("    0x%8.8x: OK\n", m_offset);
+    return true;
+  } else {
+    s->Printf("    0x%8.8x: ", m_offset);
 
-    DWARFCompileUnit* dwo_cu = m_dwo_symbol_file->GetCompileUnit();
-    size_t dwo_die_count = dwo_cu->ExtractDIEsIfNeeded(cu_die_only);
-    return m_die_array.size() + dwo_die_count - 1; // We have 2 CU die, but we want to count it only as one
-}
-
-void
-DWARFCompileUnit::AddCompileUnitDIE(DWARFDebugInfoEntry& die)
-{
-    assert (m_die_array.empty() && "Compile unit DIE already added");
-    AddDIE(die);
-
-    const DWARFDebugInfoEntry &cu_die = m_die_array.front();
-    std::unique_ptr<SymbolFileDWARFDwo> dwo_symbol_file = m_dwarf2Data->GetDwoSymbolFileForCompileUnit(*this, cu_die);
-    if (!dwo_symbol_file)
-        return;
-
-    DWARFCompileUnit* dwo_cu = dwo_symbol_file->GetCompileUnit();
-    if (!dwo_cu)
-        return; // Can't fetch the compile unit from the dwo file.
-
-    DWARFDIE dwo_cu_die = dwo_cu->GetCompileUnitDIEOnly();
-    if (!dwo_cu_die.IsValid())
-        return; // Can't fetch the compile unit DIE from the dwo file.
-
-    uint64_t main_dwo_id = cu_die.GetAttributeValueAsUnsigned(m_dwarf2Data,
-                                                              this,
-                                                              DW_AT_GNU_dwo_id,
-                                                              0);
-    uint64_t sub_dwo_id = dwo_cu_die.GetAttributeValueAsUnsigned(DW_AT_GNU_dwo_id, 0);
-    if (main_dwo_id != sub_dwo_id)
-        return; // The 2 dwo ID isn't match. Don't use the dwo file as it belongs to a differectn compilation.
-
-    m_dwo_symbol_file = std::move(dwo_symbol_file);
-    
-    dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf2Data,
-                                                             this,
-                                                             DW_AT_GNU_addr_base,
-                                                             0);
-    dwo_cu->SetAddrBase(addr_base, m_offset);
-}
-
-dw_offset_t
-DWARFCompileUnit::GetAbbrevOffset() const
-{
-    return m_abbrevs ? m_abbrevs->GetOffset() : DW_INVALID_OFFSET;
+    m_dwarf2Data->get_debug_info_data().Dump(s, m_offset, lldb::eFormatHex, 1,
+                                             Size(), 32, LLDB_INVALID_ADDRESS,
+                                             0, 0);
+    s->EOL();
+    if (valid_offset) {
+      if (!length_OK)
+        s->Printf("        The length (0x%8.8x) for this compile unit is too "
+                  "large for the .debug_info provided.\n",
+                  m_length);
+      if (!version_OK)
+        s->Printf("        The 16 bit compile unit header version is not "
+                  "supported.\n");
+      if (!abbr_offset_OK)
+        s->Printf("        The offset into the .debug_abbrev section (0x%8.8x) "
+                  "is not valid.\n",
+                  GetAbbrevOffset());
+      if (!addr_size_OK)
+        s->Printf("        The address size is unsupported: 0x%2.2x\n",
+                  m_addr_size);
+    } else
+      s->Printf("        The start offset of the compile unit header in the "
+                ".debug_info is invalid.\n");
+  }
+  return false;
+}
+
+void DWARFCompileUnit::Dump(Stream *s) const {
+  s->Printf("0x%8.8x: Compile Unit: length = 0x%8.8x, version = 0x%4.4x, "
+            "abbr_offset = 0x%8.8x, addr_size = 0x%2.2x (next CU at "
+            "{0x%8.8x})\n",
+            m_offset, m_length, m_version, GetAbbrevOffset(), m_addr_size,
+            GetNextCompileUnitOffset());
 }
 
+static uint8_t g_default_addr_size = 4;
 
-
-bool
-DWARFCompileUnit::Verify(Stream *s) const
-{
-    const DWARFDataExtractor& debug_info = m_dwarf2Data->get_debug_info_data();
-    bool valid_offset = debug_info.ValidOffset(m_offset);
-    bool length_OK = debug_info.ValidOffset(GetNextCompileUnitOffset()-1);
-    bool version_OK = SymbolFileDWARF::SupportedVersion(m_version);
-    bool abbr_offset_OK = m_dwarf2Data->get_debug_abbrev_data().ValidOffset(GetAbbrevOffset());
-    bool addr_size_OK = ((m_addr_size == 4) || (m_addr_size == 8));
-    bool verbose = s->GetVerbose();
-    if (valid_offset && length_OK && version_OK && addr_size_OK && abbr_offset_OK)
-    {
-        if (verbose)
-            s->Printf("    0x%8.8x: OK\n", m_offset);
-        return true;
+uint8_t DWARFCompileUnit::GetAddressByteSize(const DWARFCompileUnit *cu) {
+  if (cu)
+    return cu->GetAddressByteSize();
+  return DWARFCompileUnit::GetDefaultAddressSize();
+}
+
+bool DWARFCompileUnit::IsDWARF64(const DWARFCompileUnit *cu) {
+  if (cu)
+    return cu->IsDWARF64();
+  return false;
+}
+
+uint8_t DWARFCompileUnit::GetDefaultAddressSize() {
+  return g_default_addr_size;
+}
+
+void DWARFCompileUnit::SetDefaultAddressSize(uint8_t addr_size) {
+  g_default_addr_size = addr_size;
+}
+
+lldb::user_id_t DWARFCompileUnit::GetID() const {
+  dw_offset_t local_id =
+      m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset;
+  if (m_dwarf2Data)
+    return DIERef(local_id, local_id).GetUID(m_dwarf2Data);
+  else
+    return local_id;
+}
+
+void DWARFCompileUnit::BuildAddressRangeTable(
+    SymbolFileDWARF *dwarf2Data, DWARFDebugAranges *debug_aranges) {
+  // This function is usually called if there in no .debug_aranges section
+  // in order to produce a compile unit level set of address ranges that
+  // is accurate.
+
+  size_t num_debug_aranges = debug_aranges->GetNumRanges();
+
+  // First get the compile unit DIE only and check if it has a DW_AT_ranges
+  const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
+
+  const dw_offset_t cu_offset = GetOffset();
+  if (die) {
+    DWARFRangeList ranges;
+    const size_t num_ranges =
+        die->GetAttributeAddressRanges(dwarf2Data, this, ranges, false);
+    if (num_ranges > 0) {
+      // This compile unit has DW_AT_ranges, assume this is correct if it
+      // is present since clang no longer makes .debug_aranges by default
+      // and it emits DW_AT_ranges for DW_TAG_compile_units. GCC also does
+      // this with recent GCC builds.
+      for (size_t i = 0; i < num_ranges; ++i) {
+        const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
+        debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
+                                   range.GetRangeEnd());
+      }
+
+      return; // We got all of our ranges from the DW_AT_ranges attribute
+    }
+  }
+  // We don't have a DW_AT_ranges attribute, so we need to parse the DWARF
+
+  // If the DIEs weren't parsed, then we don't want all dies for all compile
+  // units
+  // to stay loaded when they weren't needed. So we can end up parsing the DWARF
+  // and then throwing them all away to keep memory usage down.
+  const bool clear_dies = ExtractDIEsIfNeeded(false) > 1;
+
+  die = DIEPtr();
+  if (die)
+    die->BuildAddressRangeTable(dwarf2Data, this, debug_aranges);
+
+  if (debug_aranges->GetNumRanges() == num_debug_aranges) {
+    // We got nothing from the functions, maybe we have a line tables only
+    // situation. Check the line tables and build the arange table from this.
+    SymbolContext sc;
+    sc.comp_unit = dwarf2Data->GetCompUnitForDWARFCompUnit(this);
+    if (sc.comp_unit) {
+      SymbolFileDWARFDebugMap *debug_map_sym_file =
+          m_dwarf2Data->GetDebugMapSymfile();
+      if (debug_map_sym_file == NULL) {
+        LineTable *line_table = sc.comp_unit->GetLineTable();
+
+        if (line_table) {
+          LineTable::FileAddressRanges file_ranges;
+          const bool append = true;
+          const size_t num_ranges =
+              line_table->GetContiguousFileAddressRanges(file_ranges, append);
+          for (uint32_t idx = 0; idx < num_ranges; ++idx) {
+            const LineTable::FileAddressRanges::Entry &range =
+                file_ranges.GetEntryRef(idx);
+            debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
+                                       range.GetRangeEnd());
+          }
+        }
+      } else
+        debug_map_sym_file->AddOSOARanges(dwarf2Data, debug_aranges);
     }
-    else
-    {
-        s->Printf("    0x%8.8x: ", m_offset);
+  }
 
-        m_dwarf2Data->get_debug_info_data().Dump (s, m_offset, lldb::eFormatHex, 1, Size(), 32, LLDB_INVALID_ADDRESS, 0, 0);
-        s->EOL();
-        if (valid_offset)
-        {
-            if (!length_OK)
-                s->Printf("        The length (0x%8.8x) for this compile unit is too large for the .debug_info provided.\n", m_length);
-            if (!version_OK)
-                s->Printf("        The 16 bit compile unit header version is not supported.\n");
-            if (!abbr_offset_OK)
-                s->Printf("        The offset into the .debug_abbrev section (0x%8.8x) is not valid.\n", GetAbbrevOffset());
-            if (!addr_size_OK)
-                s->Printf("        The address size is unsupported: 0x%2.2x\n", m_addr_size);
+  if (debug_aranges->GetNumRanges() == num_debug_aranges) {
+    // We got nothing from the functions, maybe we have a line tables only
+    // situation. Check the line tables and build the arange table from this.
+    SymbolContext sc;
+    sc.comp_unit = dwarf2Data->GetCompUnitForDWARFCompUnit(this);
+    if (sc.comp_unit) {
+      LineTable *line_table = sc.comp_unit->GetLineTable();
+
+      if (line_table) {
+        LineTable::FileAddressRanges file_ranges;
+        const bool append = true;
+        const size_t num_ranges =
+            line_table->GetContiguousFileAddressRanges(file_ranges, append);
+        for (uint32_t idx = 0; idx < num_ranges; ++idx) {
+          const LineTable::FileAddressRanges::Entry &range =
+              file_ranges.GetEntryRef(idx);
+          debug_aranges->AppendRange(GetOffset(), range.GetRangeBase(),
+                                     range.GetRangeEnd());
         }
-        else
-            s->Printf("        The start offset of the compile unit header in the .debug_info is invalid.\n");
+      }
     }
-    return false;
-}
-
+  }
 
-void
-DWARFCompileUnit::Dump(Stream *s) const
-{
-    s->Printf("0x%8.8x: Compile Unit: length = 0x%8.8x, version = 0x%4.4x, abbr_offset = 0x%8.8x, addr_size = 0x%2.2x (next CU at {0x%8.8x})\n",
-                m_offset, m_length, m_version, GetAbbrevOffset(), m_addr_size, GetNextCompileUnitOffset());
+  // Keep memory down by clearing DIEs if this generate function
+  // caused them to be parsed
+  if (clear_dies)
+    ClearDIEs(true);
 }
 
+const DWARFDebugAranges &DWARFCompileUnit::GetFunctionAranges() {
+  if (m_func_aranges_ap.get() == NULL) {
+    m_func_aranges_ap.reset(new DWARFDebugAranges());
+    Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
 
-static uint8_t g_default_addr_size = 4;
-
-uint8_t
-DWARFCompileUnit::GetAddressByteSize(const DWARFCompileUnit* cu)
-{
-    if (cu)
-        return cu->GetAddressByteSize();
-    return DWARFCompileUnit::GetDefaultAddressSize();
-}
-
-bool
-DWARFCompileUnit::IsDWARF64(const DWARFCompileUnit* cu)
-{
-    if (cu)
-        return cu->IsDWARF64();
-    return false;
-}
-
-uint8_t
-DWARFCompileUnit::GetDefaultAddressSize()
-{
-    return g_default_addr_size;
-}
-
-void
-DWARFCompileUnit::SetDefaultAddressSize(uint8_t addr_size)
-{
-    g_default_addr_size = addr_size;
-}
-
-lldb::user_id_t
-DWARFCompileUnit::GetID () const
-{
-    dw_offset_t local_id = m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset;
-    if (m_dwarf2Data)
-        return DIERef(local_id, local_id).GetUID(m_dwarf2Data);
-    else
-        return local_id;
-}
-
-void
-DWARFCompileUnit::BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
-                                          DWARFDebugAranges* debug_aranges)
-{
-    // This function is usually called if there in no .debug_aranges section
-    // in order to produce a compile unit level set of address ranges that
-    // is accurate.
-    
-    size_t num_debug_aranges = debug_aranges->GetNumRanges();
-    
-    // First get the compile unit DIE only and check if it has a DW_AT_ranges
-    const DWARFDebugInfoEntry* die = GetCompileUnitDIEPtrOnly();
-    
-    const dw_offset_t cu_offset = GetOffset();
-    if (die)
-    {
-        DWARFRangeList ranges;
-        const size_t num_ranges = die->GetAttributeAddressRanges(dwarf2Data, this, ranges, false);
-        if (num_ranges > 0)
-        {
-            // This compile unit has DW_AT_ranges, assume this is correct if it
-            // is present since clang no longer makes .debug_aranges by default
-            // and it emits DW_AT_ranges for DW_TAG_compile_units. GCC also does
-            // this with recent GCC builds.
-            for (size_t i=0; i<num_ranges; ++i)
-            {
-                const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
-                debug_aranges->AppendRange(cu_offset, range.GetRangeBase(), range.GetRangeEnd());
-            }
-            
-            return; // We got all of our ranges from the DW_AT_ranges attribute
-        }
+    if (log) {
+      m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage(
+          log, "DWARFCompileUnit::GetFunctionAranges() for compile unit at "
+               ".debug_info[0x%8.8x]",
+          GetOffset());
     }
-    // We don't have a DW_AT_ranges attribute, so we need to parse the DWARF
-    
-    // If the DIEs weren't parsed, then we don't want all dies for all compile units
-    // to stay loaded when they weren't needed. So we can end up parsing the DWARF
-    // and then throwing them all away to keep memory usage down.
-    const bool clear_dies = ExtractDIEsIfNeeded (false) > 1;
-    
-    die = DIEPtr();
+    const DWARFDebugInfoEntry *die = DIEPtr();
     if (die)
-        die->BuildAddressRangeTable(dwarf2Data, this, debug_aranges);
-    
-    if (debug_aranges->GetNumRanges() == num_debug_aranges)
-    {
-        // We got nothing from the functions, maybe we have a line tables only
-        // situation. Check the line tables and build the arange table from this.
-        SymbolContext sc;
-        sc.comp_unit = dwarf2Data->GetCompUnitForDWARFCompUnit(this);
-        if (sc.comp_unit)
-        {
-            SymbolFileDWARFDebugMap *debug_map_sym_file = m_dwarf2Data->GetDebugMapSymfile();
-            if (debug_map_sym_file == NULL)
-            {
-                LineTable *line_table = sc.comp_unit->GetLineTable();
-
-                if (line_table)
-                {
-                    LineTable::FileAddressRanges file_ranges;
-                    const bool append = true;
-                    const size_t num_ranges = line_table->GetContiguousFileAddressRanges (file_ranges, append);
-                    for (uint32_t idx=0; idx<num_ranges; ++idx)
-                    {
-                        const LineTable::FileAddressRanges::Entry &range = file_ranges.GetEntryRef(idx);
-                        debug_aranges->AppendRange(cu_offset, range.GetRangeBase(), range.GetRangeEnd());
-                    }
-                }
-            }
-            else
-                debug_map_sym_file->AddOSOARanges(dwarf2Data,debug_aranges);
-        }
-    }
-    
-    if (debug_aranges->GetNumRanges() == num_debug_aranges)
-    {
-        // We got nothing from the functions, maybe we have a line tables only
-        // situation. Check the line tables and build the arange table from this.
-        SymbolContext sc;
-        sc.comp_unit = dwarf2Data->GetCompUnitForDWARFCompUnit(this);
-        if (sc.comp_unit)
-        {
-            LineTable *line_table = sc.comp_unit->GetLineTable();
-
-            if (line_table)
-            {
-                LineTable::FileAddressRanges file_ranges;
-                const bool append = true;
-                const size_t num_ranges = line_table->GetContiguousFileAddressRanges (file_ranges, append);
-                for (uint32_t idx=0; idx<num_ranges; ++idx)
-                {
-                    const LineTable::FileAddressRanges::Entry &range = file_ranges.GetEntryRef(idx);
-                    debug_aranges->AppendRange(GetOffset(), range.GetRangeBase(), range.GetRangeEnd());
-                }
-            }
-        }
-    }
-    
-    // Keep memory down by clearing DIEs if this generate function
-    // caused them to be parsed
-    if (clear_dies)
-        ClearDIEs (true);
-
-}
+      die->BuildFunctionAddressRangeTable(m_dwarf2Data, this,
+                                          m_func_aranges_ap.get());
 
-
-const DWARFDebugAranges &
-DWARFCompileUnit::GetFunctionAranges ()
-{
-    if (m_func_aranges_ap.get() == NULL)
-    {
-        m_func_aranges_ap.reset (new DWARFDebugAranges());
-        Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
-
-        if (log)
-        {
-            m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage (log,
-                                                                    "DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]",
-                                                                    GetOffset());
-        }
-        const DWARFDebugInfoEntry* die = DIEPtr();
-        if (die)
-            die->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get());
-
-        if (m_dwo_symbol_file)
-        {
-            DWARFCompileUnit* dwo_cu = m_dwo_symbol_file->GetCompileUnit();
-            const DWARFDebugInfoEntry* dwo_die = dwo_cu->DIEPtr();
-            if (dwo_die)
-                dwo_die->BuildFunctionAddressRangeTable (m_dwo_symbol_file.get(),
-                                                         dwo_cu,
-                                                         m_func_aranges_ap.get());
-        }
-        
-        const bool minimize = false;
-        m_func_aranges_ap->Sort(minimize);
+    if (m_dwo_symbol_file) {
+      DWARFCompileUnit *dwo_cu = m_dwo_symbol_file->GetCompileUnit();
+      const DWARFDebugInfoEntry *dwo_die = dwo_cu->DIEPtr();
+      if (dwo_die)
+        dwo_die->BuildFunctionAddressRangeTable(m_dwo_symbol_file.get(), dwo_cu,
+                                                m_func_aranges_ap.get());
     }
-    return *m_func_aranges_ap.get();
+
+    const bool minimize = false;
+    m_func_aranges_ap->Sort(minimize);
+  }
+  return *m_func_aranges_ap.get();
 }
 
 DWARFDIE
-DWARFCompileUnit::LookupAddress (const dw_addr_t address)
-{
-    if (DIE())
-    {
-        const DWARFDebugAranges &func_aranges = GetFunctionAranges ();
-
-        // Re-check the aranges auto pointer contents in case it was created above
-        if (!func_aranges.IsEmpty())
-            return GetDIE(func_aranges.FindAddress(address));
-    }
-    return DWARFDIE();
+DWARFCompileUnit::LookupAddress(const dw_addr_t address) {
+  if (DIE()) {
+    const DWARFDebugAranges &func_aranges = GetFunctionAranges();
+
+    // Re-check the aranges auto pointer contents in case it was created above
+    if (!func_aranges.IsEmpty())
+      return GetDIE(func_aranges.FindAddress(address));
+  }
+  return DWARFDIE();
 }
 
 //----------------------------------------------------------------------
 // Compare function DWARFDebugAranges::Range structures
 //----------------------------------------------------------------------
-static bool CompareDIEOffset (const DWARFDebugInfoEntry& die, const dw_offset_t die_offset)
-{
-    return die.GetOffset() < die_offset;
+static bool CompareDIEOffset(const DWARFDebugInfoEntry &die,
+                             const dw_offset_t die_offset) {
+  return die.GetOffset() < die_offset;
 }
 
 //----------------------------------------------------------------------
@@ -609,627 +554,571 @@ static bool CompareDIEOffset (const DWAR
 // from the DWARF file.
 //----------------------------------------------------------------------
 DWARFDIE
-DWARFCompileUnit::GetDIE (dw_offset_t die_offset)
-{
-    if (die_offset != DW_INVALID_OFFSET)
-    {
-        if (m_dwo_symbol_file)
-            return m_dwo_symbol_file->GetCompileUnit()->GetDIE(die_offset);
-
-        if (ContainsDIEOffset(die_offset))
-        {
-            ExtractDIEsIfNeeded (false);
-            DWARFDebugInfoEntry::iterator end = m_die_array.end();
-            DWARFDebugInfoEntry::iterator pos = lower_bound(m_die_array.begin(), end, die_offset, CompareDIEOffset);
-            if (pos != end)
-            {
-                if (die_offset == (*pos).GetOffset())
-                    return DWARFDIE(this, &(*pos));
-            }
-        }
-        else
-        {
-            // Don't specify the compile unit offset as we don't know it because the DIE belongs to
-            // a different compile unit in the same symbol file.
-            return m_dwarf2Data->DebugInfo()->GetDIEForDIEOffset(die_offset);
-        }
-    }
-    return DWARFDIE(); // Not found
-}
+DWARFCompileUnit::GetDIE(dw_offset_t die_offset) {
+  if (die_offset != DW_INVALID_OFFSET) {
+    if (m_dwo_symbol_file)
+      return m_dwo_symbol_file->GetCompileUnit()->GetDIE(die_offset);
 
-size_t
-DWARFCompileUnit::AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& dies, uint32_t depth) const
-{
-    size_t old_size = dies.Size();
-    DWARFDebugInfoEntry::const_iterator pos;
-    DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
-    for (pos = m_die_array.begin(); pos != end; ++pos)
-    {
-        if (pos->Tag() == tag)
-            dies.Append (DWARFDIE(this, &(*pos)));
-    }
+    if (ContainsDIEOffset(die_offset)) {
+      ExtractDIEsIfNeeded(false);
+      DWARFDebugInfoEntry::iterator end = m_die_array.end();
+      DWARFDebugInfoEntry::iterator pos =
+          lower_bound(m_die_array.begin(), end, die_offset, CompareDIEOffset);
+      if (pos != end) {
+        if (die_offset == (*pos).GetOffset())
+          return DWARFDIE(this, &(*pos));
+      }
+    } else {
+      // Don't specify the compile unit offset as we don't know it because the
+      // DIE belongs to
+      // a different compile unit in the same symbol file.
+      return m_dwarf2Data->DebugInfo()->GetDIEForDIEOffset(die_offset);
+    }
+  }
+  return DWARFDIE(); // Not found
+}
+
+size_t DWARFCompileUnit::AppendDIEsWithTag(const dw_tag_t tag,
+                                           DWARFDIECollection &dies,
+                                           uint32_t depth) const {
+  size_t old_size = dies.Size();
+  DWARFDebugInfoEntry::const_iterator pos;
+  DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
+  for (pos = m_die_array.begin(); pos != end; ++pos) {
+    if (pos->Tag() == tag)
+      dies.Append(DWARFDIE(this, &(*pos)));
+  }
 
-    // Return the number of DIEs added to the collection
-    return dies.Size() - old_size;
+  // Return the number of DIEs added to the collection
+  return dies.Size() - old_size;
 }
 
-//void
-//DWARFCompileUnit::AddGlobalDIEByIndex (uint32_t die_idx)
+// void
+// DWARFCompileUnit::AddGlobalDIEByIndex (uint32_t die_idx)
 //{
 //    m_global_die_indexes.push_back (die_idx);
 //}
 //
 //
-//void
-//DWARFCompileUnit::AddGlobal (const DWARFDebugInfoEntry* die)
+// void
+// DWARFCompileUnit::AddGlobal (const DWARFDebugInfoEntry* die)
 //{
 //    // Indexes to all file level global and static variables
 //    m_global_die_indexes;
-//    
+//
 //    if (m_die_array.empty())
 //        return;
-//    
+//
 //    const DWARFDebugInfoEntry* first_die = &m_die_array[0];
 //    const DWARFDebugInfoEntry* end = first_die + m_die_array.size();
 //    if (first_die <= die && die < end)
 //        m_global_die_indexes.push_back (die - first_die);
 //}
 
+void DWARFCompileUnit::Index(NameToDIE &func_basenames,
+                             NameToDIE &func_fullnames, NameToDIE &func_methods,
+                             NameToDIE &func_selectors,
+                             NameToDIE &objc_class_selectors,
+                             NameToDIE &globals, NameToDIE &types,
+                             NameToDIE &namespaces) {
+  Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
+
+  if (log) {
+    m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage(
+        log,
+        "DWARFCompileUnit::Index() for compile unit at .debug_info[0x%8.8x]",
+        GetOffset());
+  }
+
+  const LanguageType cu_language = GetLanguageType();
+  DWARFFormValue::FixedFormSizes fixed_form_sizes =
+      DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
+                                                      m_is_dwarf64);
+
+  IndexPrivate(this, cu_language, fixed_form_sizes, GetOffset(), func_basenames,
+               func_fullnames, func_methods, func_selectors,
+               objc_class_selectors, globals, types, namespaces);
+
+  SymbolFileDWARFDwo *dwo_symbol_file = GetDwoSymbolFile();
+  if (dwo_symbol_file) {
+    IndexPrivate(dwo_symbol_file->GetCompileUnit(), cu_language,
+                 fixed_form_sizes, GetOffset(), func_basenames, func_fullnames,
+                 func_methods, func_selectors, objc_class_selectors, globals,
+                 types, namespaces);
+  }
+}
+
+void DWARFCompileUnit::IndexPrivate(
+    DWARFCompileUnit *dwarf_cu, const LanguageType cu_language,
+    const DWARFFormValue::FixedFormSizes &fixed_form_sizes,
+    const dw_offset_t cu_offset, NameToDIE &func_basenames,
+    NameToDIE &func_fullnames, NameToDIE &func_methods,
+    NameToDIE &func_selectors, NameToDIE &objc_class_selectors,
+    NameToDIE &globals, NameToDIE &types, NameToDIE &namespaces) {
+  DWARFDebugInfoEntry::const_iterator pos;
+  DWARFDebugInfoEntry::const_iterator begin = dwarf_cu->m_die_array.begin();
+  DWARFDebugInfoEntry::const_iterator end = dwarf_cu->m_die_array.end();
+  for (pos = begin; pos != end; ++pos) {
+    const DWARFDebugInfoEntry &die = *pos;
+
+    const dw_tag_t tag = die.Tag();
+
+    switch (tag) {
+    case DW_TAG_array_type:
+    case DW_TAG_base_type:
+    case DW_TAG_class_type:
+    case DW_TAG_constant:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_inlined_subroutine:
+    case DW_TAG_namespace:
+    case DW_TAG_string_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_subprogram:
+    case DW_TAG_subroutine_type:
+    case DW_TAG_typedef:
+    case DW_TAG_union_type:
+    case DW_TAG_unspecified_type:
+    case DW_TAG_variable:
+      break;
 
-void
-DWARFCompileUnit::Index (NameToDIE& func_basenames,
-                         NameToDIE& func_fullnames,
-                         NameToDIE& func_methods,
-                         NameToDIE& func_selectors,
-                         NameToDIE& objc_class_selectors,
-                         NameToDIE& globals,
-                         NameToDIE& types,
-                         NameToDIE& namespaces)
-{
-    Log *log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_LOOKUPS));
-    
-    if (log)
-    {
-        m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage (log, 
-                                                                "DWARFCompileUnit::Index() for compile unit at .debug_info[0x%8.8x]",
-                                                                GetOffset());
+    default:
+      continue;
     }
 
-    const LanguageType cu_language = GetLanguageType();
-    DWARFFormValue::FixedFormSizes fixed_form_sizes =
-        DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), m_is_dwarf64);
-    
-    IndexPrivate(this,
-                 cu_language,
-                 fixed_form_sizes,
-                 GetOffset(),
-                 func_basenames,
-                 func_fullnames,
-                 func_methods,
-                 func_selectors,
-                 objc_class_selectors,
-                 globals,
-                 types,
-                 namespaces);
-
-    SymbolFileDWARFDwo* dwo_symbol_file = GetDwoSymbolFile();
-    if (dwo_symbol_file)
-    {
-        IndexPrivate(dwo_symbol_file->GetCompileUnit(),
-                     cu_language,
-                     fixed_form_sizes,
-                     GetOffset(),
-                     func_basenames,
-                     func_fullnames,
-                     func_methods,
-                     func_selectors,
-                     objc_class_selectors,
-                     globals,
-                     types,
-                     namespaces);
-    }
-}
+    DWARFAttributes attributes;
+    const char *name = NULL;
+    const char *mangled_cstr = NULL;
+    bool is_declaration = false;
+    // bool is_artificial = false;
+    bool has_address = false;
+    bool has_location_or_const_value = false;
+    bool is_global_or_static_variable = false;
+
+    DWARFFormValue specification_die_form;
+    const size_t num_attributes =
+        die.GetAttributes(dwarf_cu, fixed_form_sizes, attributes);
+    if (num_attributes > 0) {
+      for (uint32_t i = 0; i < num_attributes; ++i) {
+        dw_attr_t attr = attributes.AttributeAtIndex(i);
+        DWARFFormValue form_value;
+        switch (attr) {
+        case DW_AT_name:
+          if (attributes.ExtractFormValueAtIndex(i, form_value))
+            name = form_value.AsCString();
+          break;
+
+        case DW_AT_declaration:
+          if (attributes.ExtractFormValueAtIndex(i, form_value))
+            is_declaration = form_value.Unsigned() != 0;
+          break;
+
+        //                case DW_AT_artificial:
+        //                    if (attributes.ExtractFormValueAtIndex(i,
+        //                    form_value))
+        //                        is_artificial = form_value.Unsigned() != 0;
+        //                    break;
+
+        case DW_AT_MIPS_linkage_name:
+        case DW_AT_linkage_name:
+          if (attributes.ExtractFormValueAtIndex(i, form_value))
+            mangled_cstr = form_value.AsCString();
+          break;
+
+        case DW_AT_low_pc:
+        case DW_AT_high_pc:
+        case DW_AT_ranges:
+          has_address = true;
+          break;
+
+        case DW_AT_entry_pc:
+          has_address = true;
+          break;
+
+        case DW_AT_location:
+        case DW_AT_const_value:
+          has_location_or_const_value = true;
+          if (tag == DW_TAG_variable) {
+            const DWARFDebugInfoEntry *parent_die = die.GetParent();
+            while (parent_die != NULL) {
+              switch (parent_die->Tag()) {
+              case DW_TAG_subprogram:
+              case DW_TAG_lexical_block:
+              case DW_TAG_inlined_subroutine:
+                // Even if this is a function level static, we don't add it. We
+                // could theoretically
+                // add these if we wanted to by introspecting into the
+                // DW_AT_location and seeing
+                // if the location describes a hard coded address, but we dont
+                // want the performance
+                // penalty of that right now.
+                is_global_or_static_variable = false;
+                //                              if
+                //                              (attributes.ExtractFormValueAtIndex(dwarf2Data,
+                //                              i, form_value))
+                //                              {
+                //                                  // If we have valid block
+                //                                  data, then we have location
+                //                                  expression bytes
+                //                                  // that are fixed (not a
+                //                                  location list).
+                //                                  const uint8_t *block_data =
+                //                                  form_value.BlockData();
+                //                                  if (block_data)
+                //                                  {
+                //                                      uint32_t block_length =
+                //                                      form_value.Unsigned();
+                //                                      if (block_length == 1 +
+                //                                      attributes.CompileUnitAtIndex(i)->GetAddressByteSize())
+                //                                      {
+                //                                          if (block_data[0] ==
+                //                                          DW_OP_addr)
+                //                                              add_die = true;
+                //                                      }
+                //                                  }
+                //                              }
+                parent_die = NULL; // Terminate the while loop.
+                break;
+
+              case DW_TAG_compile_unit:
+                is_global_or_static_variable = true;
+                parent_die = NULL; // Terminate the while loop.
+                break;
+
+              default:
+                parent_die =
+                    parent_die->GetParent(); // Keep going in the while loop.
+                break;
+              }
+            }
+          }
+          break;
 
-void
-DWARFCompileUnit::IndexPrivate (DWARFCompileUnit* dwarf_cu,
-                                const LanguageType cu_language,
-                                const DWARFFormValue::FixedFormSizes& fixed_form_sizes,
-                                const dw_offset_t cu_offset,
-                                NameToDIE& func_basenames,
-                                NameToDIE& func_fullnames,
-                                NameToDIE& func_methods,
-                                NameToDIE& func_selectors,
-                                NameToDIE& objc_class_selectors,
-                                NameToDIE& globals,
-                                NameToDIE& types,
-                                NameToDIE& namespaces)
-{
-    DWARFDebugInfoEntry::const_iterator pos;
-    DWARFDebugInfoEntry::const_iterator begin = dwarf_cu->m_die_array.begin();
-    DWARFDebugInfoEntry::const_iterator end = dwarf_cu->m_die_array.end();
-    for (pos = begin; pos != end; ++pos)
-    {
-        const DWARFDebugInfoEntry &die = *pos;
-        
-        const dw_tag_t tag = die.Tag();
-    
-        switch (tag)
-        {
-        case DW_TAG_array_type:
-        case DW_TAG_base_type:
-        case DW_TAG_class_type:
-        case DW_TAG_constant:
-        case DW_TAG_enumeration_type:
-        case DW_TAG_inlined_subroutine:
-        case DW_TAG_namespace:
-        case DW_TAG_string_type:
-        case DW_TAG_structure_type:
-        case DW_TAG_subprogram:
-        case DW_TAG_subroutine_type:
-        case DW_TAG_typedef:
-        case DW_TAG_union_type:
-        case DW_TAG_unspecified_type:
-        case DW_TAG_variable:
-            break;
-            
-        default:
-            continue;
+        case DW_AT_specification:
+          if (attributes.ExtractFormValueAtIndex(i, form_value))
+            specification_die_form = form_value;
+          break;
         }
+      }
+    }
 
-        DWARFAttributes attributes;
-        const char *name = NULL;
-        const char *mangled_cstr = NULL;
-        bool is_declaration = false;
-        //bool is_artificial = false;
-        bool has_address = false;
-        bool has_location_or_const_value = false;
-        bool is_global_or_static_variable = false;
-        
-        DWARFFormValue specification_die_form;
-        const size_t num_attributes = die.GetAttributes(dwarf_cu, fixed_form_sizes, attributes);
-        if (num_attributes > 0)
-        {
-            for (uint32_t i=0; i<num_attributes; ++i)
-            {
-                dw_attr_t attr = attributes.AttributeAtIndex(i);
-                DWARFFormValue form_value;
-                switch (attr)
-                {
-                case DW_AT_name:
-                    if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        name = form_value.AsCString();
-                    break;
-
-                case DW_AT_declaration:
-                    if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        is_declaration = form_value.Unsigned() != 0;
-                    break;
-
-//                case DW_AT_artificial:
-//                    if (attributes.ExtractFormValueAtIndex(i, form_value))
-//                        is_artificial = form_value.Unsigned() != 0;
-//                    break;
-
-                case DW_AT_MIPS_linkage_name:
-                case DW_AT_linkage_name:
-                    if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        mangled_cstr = form_value.AsCString();
-                    break;
-
-                case DW_AT_low_pc:
-                case DW_AT_high_pc:
-                case DW_AT_ranges:
-                    has_address = true;
-                    break;
-
-                case DW_AT_entry_pc:
-                    has_address = true;
-                    break;
-
-                case DW_AT_location:
-                case DW_AT_const_value:
-                    has_location_or_const_value = true;
-                    if (tag == DW_TAG_variable)
-                    {
-                        const DWARFDebugInfoEntry* parent_die = die.GetParent();
-                        while ( parent_die != NULL )
-                        {
-                            switch (parent_die->Tag())
-                            {
-                            case DW_TAG_subprogram:
-                            case DW_TAG_lexical_block:
-                            case DW_TAG_inlined_subroutine:
-                                // Even if this is a function level static, we don't add it. We could theoretically
-                                // add these if we wanted to by introspecting into the DW_AT_location and seeing
-                                // if the location describes a hard coded address, but we dont want the performance
-                                // penalty of that right now.
-                                is_global_or_static_variable = false;
-//                              if (attributes.ExtractFormValueAtIndex(dwarf2Data, i, form_value))
-//                              {
-//                                  // If we have valid block data, then we have location expression bytes
-//                                  // that are fixed (not a location list).
-//                                  const uint8_t *block_data = form_value.BlockData();
-//                                  if (block_data)
-//                                  {
-//                                      uint32_t block_length = form_value.Unsigned();
-//                                      if (block_length == 1 + attributes.CompileUnitAtIndex(i)->GetAddressByteSize())
-//                                      {
-//                                          if (block_data[0] == DW_OP_addr)
-//                                              add_die = true;
-//                                      }
-//                                  }
-//                              }
-                                parent_die = NULL;  // Terminate the while loop.
-                                break;
-
-                            case DW_TAG_compile_unit:
-                                is_global_or_static_variable = true;
-                                parent_die = NULL;  // Terminate the while loop.
-                                break;
-
-                            default:
-                                parent_die = parent_die->GetParent();   // Keep going in the while loop.
-                                break;
-                            }
-                        }
-                    }
-                    break;
-                    
-                case DW_AT_specification:
-                    if (attributes.ExtractFormValueAtIndex(i, form_value))
-                        specification_die_form = form_value;
-                    break;
-                }
+    switch (tag) {
+    case DW_TAG_subprogram:
+      if (has_address) {
+        if (name) {
+          ObjCLanguage::MethodName objc_method(name, true);
+          if (objc_method.IsValid(true)) {
+            ConstString objc_class_name_with_category(
+                objc_method.GetClassNameWithCategory());
+            ConstString objc_selector_name(objc_method.GetSelector());
+            ConstString objc_fullname_no_category_name(
+                objc_method.GetFullNameWithoutCategory(true));
+            ConstString objc_class_name_no_category(objc_method.GetClassName());
+            func_fullnames.Insert(ConstString(name),
+                                  DIERef(cu_offset, die.GetOffset()));
+            if (objc_class_name_with_category)
+              objc_class_selectors.Insert(objc_class_name_with_category,
+                                          DIERef(cu_offset, die.GetOffset()));
+            if (objc_class_name_no_category &&
+                objc_class_name_no_category != objc_class_name_with_category)
+              objc_class_selectors.Insert(objc_class_name_no_category,
+                                          DIERef(cu_offset, die.GetOffset()));
+            if (objc_selector_name)
+              func_selectors.Insert(objc_selector_name,
+                                    DIERef(cu_offset, die.GetOffset()));
+            if (objc_fullname_no_category_name)
+              func_fullnames.Insert(objc_fullname_no_category_name,
+                                    DIERef(cu_offset, die.GetOffset()));
+          }
+          // If we have a mangled name, then the DW_AT_name attribute
+          // is usually the method name without the class or any parameters
+          const DWARFDebugInfoEntry *parent = die.GetParent();
+          bool is_method = false;
+          if (parent) {
+            dw_tag_t parent_tag = parent->Tag();
+            if (parent_tag == DW_TAG_class_type ||
+                parent_tag == DW_TAG_structure_type) {
+              is_method = true;
+            } else {
+              if (specification_die_form.IsValid()) {
+                DWARFDIE specification_die =
+                    dwarf_cu->GetSymbolFileDWARF()->DebugInfo()->GetDIE(
+                        DIERef(specification_die_form));
+                if (specification_die.GetParent().IsStructOrClass())
+                  is_method = true;
+              }
             }
-        }
+          }
 
-        switch (tag)
-        {
-        case DW_TAG_subprogram:
-            if (has_address)
-            {
-                if (name)
-                {
-                    ObjCLanguage::MethodName objc_method(name, true);
-                    if (objc_method.IsValid(true))
-                    {
-                        ConstString objc_class_name_with_category (objc_method.GetClassNameWithCategory());
-                        ConstString objc_selector_name (objc_method.GetSelector());
-                        ConstString objc_fullname_no_category_name (objc_method.GetFullNameWithoutCategory(true));
-                        ConstString objc_class_name_no_category (objc_method.GetClassName());
-                        func_fullnames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
-                        if (objc_class_name_with_category)
-                            objc_class_selectors.Insert(objc_class_name_with_category, DIERef(cu_offset, die.GetOffset()));
-                        if (objc_class_name_no_category && objc_class_name_no_category != objc_class_name_with_category)
-                            objc_class_selectors.Insert(objc_class_name_no_category, DIERef(cu_offset, die.GetOffset()));
-                        if (objc_selector_name)
-                            func_selectors.Insert (objc_selector_name, DIERef(cu_offset, die.GetOffset()));
-                        if (objc_fullname_no_category_name)
-                            func_fullnames.Insert (objc_fullname_no_category_name, DIERef(cu_offset, die.GetOffset()));
-                    }
-                    // If we have a mangled name, then the DW_AT_name attribute
-                    // is usually the method name without the class or any parameters
-                    const DWARFDebugInfoEntry *parent = die.GetParent();
-                    bool is_method = false;
-                    if (parent)
-                    {
-                        dw_tag_t parent_tag = parent->Tag();
-                        if (parent_tag == DW_TAG_class_type || parent_tag == DW_TAG_structure_type)
-                        {
-                            is_method = true;
-                        }
-                        else
-                        {
-                            if (specification_die_form.IsValid())
-                            {
-                                DWARFDIE specification_die = dwarf_cu->GetSymbolFileDWARF()->DebugInfo()->GetDIE (DIERef(specification_die_form));
-                                if (specification_die.GetParent().IsStructOrClass())
-                                    is_method = true;
-                            }
-                        }
-                    }
-
-
-                    if (is_method)
-                        func_methods.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
-                    else
-                        func_basenames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
-
-                    if (!is_method && !mangled_cstr && !objc_method.IsValid(true))
-                        func_fullnames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
-                }
-                if (mangled_cstr)
-                {
-                    // Make sure our mangled name isn't the same string table entry
-                    // as our name. If it starts with '_', then it is ok, else compare
-                    // the string to make sure it isn't the same and we don't end up
-                    // with duplicate entries
-                    if (name && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
-                    {
-                        Mangled mangled (ConstString(mangled_cstr), true);
-                        func_fullnames.Insert (mangled.GetMangledName(), DIERef(cu_offset, die.GetOffset()));
-                        ConstString demangled = mangled.GetDemangledName(cu_language);
-                        if (demangled)
-                            func_fullnames.Insert (demangled, DIERef(cu_offset, die.GetOffset()));
-                    }
-                }
-            }
-            break;
+          if (is_method)
+            func_methods.Insert(ConstString(name),
+                                DIERef(cu_offset, die.GetOffset()));
+          else
+            func_basenames.Insert(ConstString(name),
+                                  DIERef(cu_offset, die.GetOffset()));
+
+          if (!is_method && !mangled_cstr && !objc_method.IsValid(true))
+            func_fullnames.Insert(ConstString(name),
+                                  DIERef(cu_offset, die.GetOffset()));
+        }
+        if (mangled_cstr) {
+          // Make sure our mangled name isn't the same string table entry
+          // as our name. If it starts with '_', then it is ok, else compare
+          // the string to make sure it isn't the same and we don't end up
+          // with duplicate entries
+          if (name && name != mangled_cstr &&
+              ((mangled_cstr[0] == '_') ||
+               (::strcmp(name, mangled_cstr) != 0))) {
+            Mangled mangled(ConstString(mangled_cstr), true);
+            func_fullnames.Insert(mangled.GetMangledName(),
+                                  DIERef(cu_offset, die.GetOffset()));
+            ConstString demangled = mangled.GetDemangledName(cu_language);
+            if (demangled)
+              func_fullnames.Insert(demangled,
+                                    DIERef(cu_offset, die.GetOffset()));
+          }
+        }
+      }
+      break;
 
-        case DW_TAG_inlined_subroutine:
-            if (has_address)
-            {
-                if (name)
-                    func_basenames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
-                if (mangled_cstr)
-                {
-                    // Make sure our mangled name isn't the same string table entry
-                    // as our name. If it starts with '_', then it is ok, else compare
-                    // the string to make sure it isn't the same and we don't end up
-                    // with duplicate entries
-                    if (name && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
-                    {
-                        Mangled mangled (ConstString(mangled_cstr), true);
-                        func_fullnames.Insert (mangled.GetMangledName(), DIERef(cu_offset, die.GetOffset()));
-                        ConstString demangled = mangled.GetDemangledName(cu_language);
-                        if (demangled)
-                            func_fullnames.Insert (demangled, DIERef(cu_offset, die.GetOffset()));
-                    }
-                }
-                else
-                    func_fullnames.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
-            }
-            break;
-        
-        case DW_TAG_array_type:
-        case DW_TAG_base_type:
-        case DW_TAG_class_type:
-        case DW_TAG_constant:
-        case DW_TAG_enumeration_type:
-        case DW_TAG_string_type:
-        case DW_TAG_structure_type:
-        case DW_TAG_subroutine_type:
-        case DW_TAG_typedef:
-        case DW_TAG_union_type:
-        case DW_TAG_unspecified_type:
-            if (name && !is_declaration)
-                types.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
-            if (mangled_cstr && !is_declaration)
-                types.Insert (ConstString(mangled_cstr), DIERef(cu_offset, die.GetOffset()));
-            break;
-
-        case DW_TAG_namespace:
-            if (name)
-                namespaces.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
-            break;
-
-        case DW_TAG_variable:
-            if (name && has_location_or_const_value && is_global_or_static_variable)
-            {
-                globals.Insert (ConstString(name), DIERef(cu_offset, die.GetOffset()));
-                // Be sure to include variables by their mangled and demangled
-                // names if they have any since a variable can have a basename
-                // "i", a mangled named "_ZN12_GLOBAL__N_11iE" and a demangled 
-                // mangled name "(anonymous namespace)::i"...
-                
-                // Make sure our mangled name isn't the same string table entry
-                // as our name. If it starts with '_', then it is ok, else compare
-                // the string to make sure it isn't the same and we don't end up
-                // with duplicate entries
-                if (mangled_cstr && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0)))
-                {
-                    Mangled mangled (ConstString(mangled_cstr), true);
-                    globals.Insert (mangled.GetMangledName(), DIERef(cu_offset, die.GetOffset()));
-                    ConstString demangled = mangled.GetDemangledName(cu_language);
-                    if (demangled)
-                        globals.Insert (demangled, DIERef(cu_offset, die.GetOffset()));
-                }
-            }
-            break;
-            
-        default:
-            continue;
+    case DW_TAG_inlined_subroutine:
+      if (has_address) {
+        if (name)
+          func_basenames.Insert(ConstString(name),
+                                DIERef(cu_offset, die.GetOffset()));
+        if (mangled_cstr) {
+          // Make sure our mangled name isn't the same string table entry
+          // as our name. If it starts with '_', then it is ok, else compare
+          // the string to make sure it isn't the same and we don't end up
+          // with duplicate entries
+          if (name && name != mangled_cstr &&
+              ((mangled_cstr[0] == '_') ||
+               (::strcmp(name, mangled_cstr) != 0))) {
+            Mangled mangled(ConstString(mangled_cstr), true);
+            func_fullnames.Insert(mangled.GetMangledName(),
+                                  DIERef(cu_offset, die.GetOffset()));
+            ConstString demangled = mangled.GetDemangledName(cu_language);
+            if (demangled)
+              func_fullnames.Insert(demangled,
+                                    DIERef(cu_offset, die.GetOffset()));
+          }
+        } else
+          func_fullnames.Insert(ConstString(name),
+                                DIERef(cu_offset, die.GetOffset()));
+      }
+      break;
+
+    case DW_TAG_array_type:
+    case DW_TAG_base_type:
+    case DW_TAG_class_type:
+    case DW_TAG_constant:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_string_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_subroutine_type:
+    case DW_TAG_typedef:
+    case DW_TAG_union_type:
+    case DW_TAG_unspecified_type:
+      if (name && !is_declaration)
+        types.Insert(ConstString(name), DIERef(cu_offset, die.GetOffset()));
+      if (mangled_cstr && !is_declaration)
+        types.Insert(ConstString(mangled_cstr),
+                     DIERef(cu_offset, die.GetOffset()));
+      break;
+
+    case DW_TAG_namespace:
+      if (name)
+        namespaces.Insert(ConstString(name),
+                          DIERef(cu_offset, die.GetOffset()));
+      break;
+
+    case DW_TAG_variable:
+      if (name && has_location_or_const_value && is_global_or_static_variable) {
+        globals.Insert(ConstString(name), DIERef(cu_offset, die.GetOffset()));
+        // Be sure to include variables by their mangled and demangled
+        // names if they have any since a variable can have a basename
+        // "i", a mangled named "_ZN12_GLOBAL__N_11iE" and a demangled
+        // mangled name "(anonymous namespace)::i"...
+
+        // Make sure our mangled name isn't the same string table entry
+        // as our name. If it starts with '_', then it is ok, else compare
+        // the string to make sure it isn't the same and we don't end up
+        // with duplicate entries
+        if (mangled_cstr && name != mangled_cstr &&
+            ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0))) {
+          Mangled mangled(ConstString(mangled_cstr), true);
+          globals.Insert(mangled.GetMangledName(),
+                         DIERef(cu_offset, die.GetOffset()));
+          ConstString demangled = mangled.GetDemangledName(cu_language);
+          if (demangled)
+            globals.Insert(demangled, DIERef(cu_offset, die.GetOffset()));
         }
-    }
-}
+      }
+      break;
 
-bool
-DWARFCompileUnit::Supports_unnamed_objc_bitfields ()
-{
-    if (GetProducer() == eProducerClang)
-    {
-        const uint32_t major_version = GetProducerVersionMajor();
-        if (major_version > 425 || (major_version == 425 && GetProducerVersionUpdate() >= 13))
-            return true;
-        else
-            return false;
+    default:
+      continue;
     }
-    return true; // Assume all other compilers didn't have incorrect ObjC bitfield info
+  }
 }
 
-bool
-DWARFCompileUnit::Supports_DW_AT_APPLE_objc_complete_type ()
-{
-    if (GetProducer() == eProducerLLVMGCC)
-        return false;
-    return true;
+bool DWARFCompileUnit::Supports_unnamed_objc_bitfields() {
+  if (GetProducer() == eProducerClang) {
+    const uint32_t major_version = GetProducerVersionMajor();
+    if (major_version > 425 ||
+        (major_version == 425 && GetProducerVersionUpdate() >= 13))
+      return true;
+    else
+      return false;
+  }
+  return true; // Assume all other compilers didn't have incorrect ObjC bitfield
+               // info
 }
 
-bool
-DWARFCompileUnit::DW_AT_decl_file_attributes_are_invalid()
-{
-    // llvm-gcc makes completely invalid decl file attributes and won't ever
-    // be fixed, so we need to know to ignore these.
-    return GetProducer() == eProducerLLVMGCC;
+bool DWARFCompileUnit::Supports_DW_AT_APPLE_objc_complete_type() {
+  if (GetProducer() == eProducerLLVMGCC)
+    return false;
+  return true;
 }
 
-void
-DWARFCompileUnit::ParseProducerInfo ()
-{
-    m_producer_version_major = UINT32_MAX;
-    m_producer_version_minor = UINT32_MAX;
-    m_producer_version_update = UINT32_MAX;
-
-    const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
-    if (die)
-    {
-
-        const char *producer_cstr = die->GetAttributeValueAsString(m_dwarf2Data, this, DW_AT_producer, NULL);
-        if (producer_cstr)
-        {
-            RegularExpression llvm_gcc_regex("^4\\.[012]\\.[01] \\(Based on Apple Inc\\. build [0-9]+\\) \\(LLVM build [\\.0-9]+\\)$");
-            if (llvm_gcc_regex.Execute (producer_cstr))
-            {
-                m_producer = eProducerLLVMGCC;
-            }
-            else if (strstr(producer_cstr, "clang"))
-            {
-                static RegularExpression g_clang_version_regex("clang-([0-9]+)\\.([0-9]+)\\.([0-9]+)");
-                RegularExpression::Match regex_match(3);
-                if (g_clang_version_regex.Execute (producer_cstr, &regex_match))
-                {
-                    std::string str;
-                    if (regex_match.GetMatchAtIndex (producer_cstr, 1, str))
-                        m_producer_version_major = StringConvert::ToUInt32(str.c_str(), UINT32_MAX, 10);
-                    if (regex_match.GetMatchAtIndex (producer_cstr, 2, str))
-                        m_producer_version_minor = StringConvert::ToUInt32(str.c_str(), UINT32_MAX, 10);
-                    if (regex_match.GetMatchAtIndex (producer_cstr, 3, str))
-                        m_producer_version_update = StringConvert::ToUInt32(str.c_str(), UINT32_MAX, 10);
-                }
-                m_producer = eProducerClang;
-            }
-            else if (strstr(producer_cstr, "GNU"))
-                m_producer = eProducerGCC;
+bool DWARFCompileUnit::DW_AT_decl_file_attributes_are_invalid() {
+  // llvm-gcc makes completely invalid decl file attributes and won't ever
+  // be fixed, so we need to know to ignore these.
+  return GetProducer() == eProducerLLVMGCC;
+}
+
+void DWARFCompileUnit::ParseProducerInfo() {
+  m_producer_version_major = UINT32_MAX;
+  m_producer_version_minor = UINT32_MAX;
+  m_producer_version_update = UINT32_MAX;
+
+  const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
+  if (die) {
+
+    const char *producer_cstr = die->GetAttributeValueAsString(
+        m_dwarf2Data, this, DW_AT_producer, NULL);
+    if (producer_cstr) {
+      RegularExpression llvm_gcc_regex("^4\\.[012]\\.[01] \\(Based on Apple "
+                                       "Inc\\. build [0-9]+\\) \\(LLVM build "
+                                       "[\\.0-9]+\\)$");
+      if (llvm_gcc_regex.Execute(producer_cstr)) {
+        m_producer = eProducerLLVMGCC;
+      } else if (strstr(producer_cstr, "clang")) {
+        static RegularExpression g_clang_version_regex(
+            "clang-([0-9]+)\\.([0-9]+)\\.([0-9]+)");
+        RegularExpression::Match regex_match(3);
+        if (g_clang_version_regex.Execute(producer_cstr, &regex_match)) {
+          std::string str;
+          if (regex_match.GetMatchAtIndex(producer_cstr, 1, str))
+            m_producer_version_major =
+                StringConvert::ToUInt32(str.c_str(), UINT32_MAX, 10);
+          if (regex_match.GetMatchAtIndex(producer_cstr, 2, str))
+            m_producer_version_minor =
+                StringConvert::ToUInt32(str.c_str(), UINT32_MAX, 10);
+          if (regex_match.GetMatchAtIndex(producer_cstr, 3, str))
+            m_producer_version_update =
+                StringConvert::ToUInt32(str.c_str(), UINT32_MAX, 10);
         }
+        m_producer = eProducerClang;
+      } else if (strstr(producer_cstr, "GNU"))
+        m_producer = eProducerGCC;
     }
-    if (m_producer == eProducerInvalid)
-        m_producer = eProcucerOther;
+  }
+  if (m_producer == eProducerInvalid)
+    m_producer = eProcucerOther;
 }
 
-DWARFCompileUnit::Producer
-DWARFCompileUnit::GetProducer ()
-{
-    if (m_producer == eProducerInvalid)
-        ParseProducerInfo ();
-    return m_producer;
+DWARFCompileUnit::Producer DWARFCompileUnit::GetProducer() {
+  if (m_producer == eProducerInvalid)
+    ParseProducerInfo();
+  return m_producer;
 }
 
+uint32_t DWARFCompileUnit::GetProducerVersionMajor() {
+  if (m_producer_version_major == 0)
+    ParseProducerInfo();
+  return m_producer_version_major;
+}
 
-uint32_t
-DWARFCompileUnit::GetProducerVersionMajor()
-{
-    if (m_producer_version_major == 0)
-        ParseProducerInfo ();
-    return m_producer_version_major;
-}
-
-uint32_t
-DWARFCompileUnit::GetProducerVersionMinor()
-{
-    if (m_producer_version_minor == 0)
-        ParseProducerInfo ();
-    return m_producer_version_minor;
-}
-
-uint32_t
-DWARFCompileUnit::GetProducerVersionUpdate()
-{
-    if (m_producer_version_update == 0)
-        ParseProducerInfo ();
-    return m_producer_version_update;
-}
-
-LanguageType
-DWARFCompileUnit::LanguageTypeFromDWARF(uint64_t val) 
-{
-    // Note: user languages between lo_user and hi_user
-    // must be handled explicitly here.
-    switch (val)
-    {
-    case DW_LANG_Mips_Assembler:
-        return eLanguageTypeMipsAssembler;
-    case DW_LANG_GOOGLE_RenderScript:
-        return eLanguageTypeExtRenderScript;
-    default:
-        return static_cast<LanguageType>(val);
-    }
+uint32_t DWARFCompileUnit::GetProducerVersionMinor() {
+  if (m_producer_version_minor == 0)
+    ParseProducerInfo();
+  return m_producer_version_minor;
 }
 
-LanguageType
-DWARFCompileUnit::GetLanguageType()
-{
-    if (m_language_type != eLanguageTypeUnknown)
-        return m_language_type;
+uint32_t DWARFCompileUnit::GetProducerVersionUpdate() {
+  if (m_producer_version_update == 0)
+    ParseProducerInfo();
+  return m_producer_version_update;
+}
 
-    const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
-    if (die)
-        m_language_type = LanguageTypeFromDWARF(die->GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_language, 0));
+LanguageType DWARFCompileUnit::LanguageTypeFromDWARF(uint64_t val) {
+  // Note: user languages between lo_user and hi_user
+  // must be handled explicitly here.
+  switch (val) {
+  case DW_LANG_Mips_Assembler:
+    return eLanguageTypeMipsAssembler;
+  case DW_LANG_GOOGLE_RenderScript:
+    return eLanguageTypeExtRenderScript;
+  default:
+    return static_cast<LanguageType>(val);
+  }
+}
+
+LanguageType DWARFCompileUnit::GetLanguageType() {
+  if (m_language_type != eLanguageTypeUnknown)
     return m_language_type;
+
+  const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
+  if (die)
+    m_language_type = LanguageTypeFromDWARF(die->GetAttributeValueAsUnsigned(
+        m_dwarf2Data, this, DW_AT_language, 0));
+  return m_language_type;
 }
 
-bool
-DWARFCompileUnit::IsDWARF64() const
-{
-    return m_is_dwarf64;
-}
-
-bool
-DWARFCompileUnit::GetIsOptimized ()
-{
-    if (m_is_optimized == eLazyBoolCalculate)
-    {
-        const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
-        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;
+bool DWARFCompileUnit::IsDWARF64() const { return m_is_dwarf64; }
+
+bool DWARFCompileUnit::GetIsOptimized() {
+  if (m_is_optimized == eLazyBoolCalculate) {
+    const DWARFDebugInfoEntry *die = GetCompileUnitDIEPtrOnly();
+    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;
+  }
 }
 
-DWARFFormValue::FixedFormSizes
-DWARFCompileUnit::GetFixedFormSizes ()
-{
-    return DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), IsDWARF64());
+DWARFFormValue::FixedFormSizes DWARFCompileUnit::GetFixedFormSizes() {
+  return DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
+                                                         IsDWARF64());
 }
 
-TypeSystem *
-DWARFCompileUnit::GetTypeSystem ()
-{
-    if (m_dwarf2Data)
-        return m_dwarf2Data->GetTypeSystemForLanguage(GetLanguageType());
-    else
-        return nullptr;
+TypeSystem *DWARFCompileUnit::GetTypeSystem() {
+  if (m_dwarf2Data)
+    return m_dwarf2Data->GetTypeSystemForLanguage(GetLanguageType());
+  else
+    return nullptr;
 }
 
-void
-DWARFCompileUnit::SetUserData(void *d)
-{
-    m_user_data = d;
-    if (m_dwo_symbol_file)
-        m_dwo_symbol_file->GetCompileUnit()->SetUserData(d);
+void DWARFCompileUnit::SetUserData(void *d) {
+  m_user_data = d;
+  if (m_dwo_symbol_file)
+    m_dwo_symbol_file->GetCompileUnit()->SetUserData(d);
 }
 
-void
-DWARFCompileUnit::SetAddrBase(dw_addr_t addr_base, dw_offset_t base_obj_offset)
-{
-    m_addr_base = addr_base;
-    m_base_obj_offset = base_obj_offset;
+void DWARFCompileUnit::SetAddrBase(dw_addr_t addr_base,
+                                   dw_offset_t base_obj_offset) {
+  m_addr_base = addr_base;
+  m_base_obj_offset = base_obj_offset;
 }
 
-lldb::ByteOrder
-DWARFCompileUnit::GetByteOrder() const
-{
-    return m_dwarf2Data->GetObjectFile()->GetByteOrder();
+lldb::ByteOrder DWARFCompileUnit::GetByteOrder() const {
+  return m_dwarf2Data->GetObjectFile()->GetByteOrder();
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Tue Sep  6 15:57:50 2016
@@ -10,258 +10,212 @@
 #ifndef SymbolFileDWARF_DWARFCompileUnit_h_
 #define SymbolFileDWARF_DWARFCompileUnit_h_
 
-#include "lldb/lldb-enumerations.h"
-#include "DWARFDebugInfoEntry.h"
 #include "DWARFDIE.h"
+#include "DWARFDebugInfoEntry.h"
+#include "lldb/lldb-enumerations.h"
 
 class NameToDIE;
 class SymbolFileDWARF;
 class SymbolFileDWARFDwo;
 
-class DWARFCompileUnit
-{
+class DWARFCompileUnit {
 public:
-    enum Producer 
-    {
-        eProducerInvalid = 0,
-        eProducerClang,
-        eProducerGCC,
-        eProducerLLVMGCC,
-        eProcucerOther
-    };
-
-    DWARFCompileUnit(SymbolFileDWARF* dwarf2Data);
-    ~DWARFCompileUnit();
-
-    bool        Extract(const lldb_private::DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr);
-    size_t      ExtractDIEsIfNeeded (bool cu_die_only);
-    DWARFDIE    LookupAddress(const dw_addr_t address);
-    size_t      AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& matching_dies, uint32_t depth = UINT32_MAX) const;
-    void        Clear();
-    bool        Verify(lldb_private::Stream *s) const;
-    void        Dump(lldb_private::Stream *s) const;
-    dw_offset_t GetOffset() const { return m_offset; }
-    lldb::user_id_t GetID () const;
-    uint32_t    Size() const { return m_is_dwarf64 ? 23 : 11; /* Size in bytes of the compile unit header */ }
-    bool        ContainsDIEOffset(dw_offset_t die_offset) const { return die_offset >= GetFirstDIEOffset() && die_offset < GetNextCompileUnitOffset(); }
-    dw_offset_t GetFirstDIEOffset() const { return m_offset + Size(); }
-    dw_offset_t GetNextCompileUnitOffset() const { return m_offset + m_length + (m_is_dwarf64 ? 12 : 4); }
-    size_t      GetDebugInfoSize() const { return m_length + (m_is_dwarf64 ? 12 : 4) - Size(); /* Size in bytes of the .debug_info data associated with this compile unit. */ }
-    uint32_t    GetLength() const { return m_length; }
-    uint16_t    GetVersion() const { return m_version; }
-    const DWARFAbbreviationDeclarationSet*  GetAbbreviations() const { return m_abbrevs; }
-    dw_offset_t GetAbbrevOffset() const;
-    uint8_t     GetAddressByteSize() const { return m_addr_size; }
-    dw_addr_t   GetBaseAddress() const { return m_base_addr; }
-    dw_addr_t   GetAddrBase() const { return m_addr_base; }
-    void        SetAddrBase(dw_addr_t addr_base, dw_offset_t base_obj_offset);
-    void        ClearDIEs(bool keep_compile_unit_die);
-    void        BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
-                                        DWARFDebugAranges* debug_aranges);
-
-    lldb::ByteOrder
-    GetByteOrder() const;
-
-    lldb_private::TypeSystem *
-                GetTypeSystem();
-
-    DWARFFormValue::FixedFormSizes
-                GetFixedFormSizes ();
-
-    void
-    SetBaseAddress(dw_addr_t base_addr)
-    {
-        m_base_addr = base_addr;
-    }
-
-    DWARFDIE
-    GetCompileUnitDIEOnly()
-    {
-        return DWARFDIE(this, GetCompileUnitDIEPtrOnly());
-    }
-
-    DWARFDIE
-    DIE ()
-    {
-        return DWARFDIE(this, DIEPtr());
-    }
-
-    void
-    AddDIE (DWARFDebugInfoEntry& die)
-    {
-        // The average bytes per DIE entry has been seen to be
-        // around 14-20 so lets pre-reserve half of that since
-        // we are now stripping the NULL tags. 
-
-        // Only reserve the memory if we are adding children of
-        // the main compile unit DIE. The compile unit DIE is always
-        // the first entry, so if our size is 1, then we are adding
-        // the first compile unit child DIE and should reserve
-        // the memory.
-        if (m_die_array.empty())
-            m_die_array.reserve(GetDebugInfoSize() / 24);
-        m_die_array.push_back(die);
-    }
-    
-    void
-    AddCompileUnitDIE (DWARFDebugInfoEntry& die);
-
-    bool
-    HasDIEsParsed () const
-    {
-        return m_die_array.size() > 1;
-    }
-
-    DWARFDIE
-    GetDIE (dw_offset_t die_offset);
-
-    static uint8_t
-    GetAddressByteSize(const DWARFCompileUnit* cu);
-
-    static bool
-    IsDWARF64(const DWARFCompileUnit* cu);
-
-    static uint8_t
-    GetDefaultAddressSize();
-
-    static void
-    SetDefaultAddressSize(uint8_t addr_size);
-
-    void *
-    GetUserData() const
-    {
-        return m_user_data;
-    }
-
-    void
-    SetUserData(void *d);
-
-    bool
-    Supports_DW_AT_APPLE_objc_complete_type ();
-
-    bool
-    DW_AT_decl_file_attributes_are_invalid();
-
-    bool
-    Supports_unnamed_objc_bitfields ();
-
-    void
-    Index (NameToDIE& func_basenames,
-           NameToDIE& func_fullnames,
-           NameToDIE& func_methods,
-           NameToDIE& func_selectors,
-           NameToDIE& objc_class_selectors,
-           NameToDIE& globals,
-           NameToDIE& types,
-           NameToDIE& namespaces);
-
-    const DWARFDebugAranges &
-    GetFunctionAranges ();
-
-    SymbolFileDWARF*
-    GetSymbolFileDWARF () const
-    {
-        return m_dwarf2Data;
-    }
-    
-    Producer
-    GetProducer ();
-    
-    uint32_t
-    GetProducerVersionMajor();
-
-    uint32_t
-    GetProducerVersionMinor();
-    
-    uint32_t
-    GetProducerVersionUpdate();
-
-    static lldb::LanguageType
-    LanguageTypeFromDWARF(uint64_t val);
-
-    lldb::LanguageType
-    GetLanguageType();
-
-    bool
-    IsDWARF64() const;
-
-    bool
-    GetIsOptimized ();
-
-    SymbolFileDWARFDwo*
-    GetDwoSymbolFile() const
-    {
-        return m_dwo_symbol_file.get();
-    }
-
-    dw_offset_t
-    GetBaseObjOffset() const
-    {
-        return m_base_obj_offset;
-    }
+  enum Producer {
+    eProducerInvalid = 0,
+    eProducerClang,
+    eProducerGCC,
+    eProducerLLVMGCC,
+    eProcucerOther
+  };
 
-protected:
-    SymbolFileDWARF*    m_dwarf2Data;
-    std::unique_ptr<SymbolFileDWARFDwo> m_dwo_symbol_file;
-    const DWARFAbbreviationDeclarationSet *m_abbrevs;
-    void *              m_user_data;
-    DWARFDebugInfoEntry::collection m_die_array;    // The compile unit debug information entry item
-    std::unique_ptr<DWARFDebugAranges> m_func_aranges_ap;   // A table similar to the .debug_aranges table, but this one points to the exact DW_TAG_subprogram DIEs
-    dw_addr_t           m_base_addr;
-    dw_offset_t         m_offset;
-    dw_offset_t         m_length;
-    uint16_t            m_version;
-    uint8_t             m_addr_size;
-    Producer            m_producer;
-    uint32_t            m_producer_version_major;
-    uint32_t            m_producer_version_minor;
-    uint32_t            m_producer_version_update;
-    lldb::LanguageType  m_language_type;
-    bool                m_is_dwarf64;
-    lldb_private::LazyBool m_is_optimized;
-    dw_addr_t           m_addr_base;       // Value of DW_AT_addr_base
-    dw_offset_t         m_base_obj_offset; // If this is a dwo compile unit this is the offset of
-                                           // the base compile unit in the main object file
-
-    void
-    ParseProducerInfo ();
-
-    static void
-    IndexPrivate (DWARFCompileUnit* dwarf_cu,
-                  const lldb::LanguageType cu_language,
-                  const DWARFFormValue::FixedFormSizes& fixed_form_sizes,
-                  const dw_offset_t cu_offset,
-                  NameToDIE& func_basenames,
-                  NameToDIE& func_fullnames,
-                  NameToDIE& func_methods,
-                  NameToDIE& func_selectors,
-                  NameToDIE& objc_class_selectors,
-                  NameToDIE& globals,
-                  NameToDIE& types,
-                  NameToDIE& namespaces);
+  DWARFCompileUnit(SymbolFileDWARF *dwarf2Data);
+  ~DWARFCompileUnit();
 
-private:
+  bool Extract(const lldb_private::DWARFDataExtractor &debug_info,
+               lldb::offset_t *offset_ptr);
+  size_t ExtractDIEsIfNeeded(bool cu_die_only);
+  DWARFDIE LookupAddress(const dw_addr_t address);
+  size_t AppendDIEsWithTag(const dw_tag_t tag,
+                           DWARFDIECollection &matching_dies,
+                           uint32_t depth = UINT32_MAX) const;
+  void Clear();
+  bool Verify(lldb_private::Stream *s) const;
+  void Dump(lldb_private::Stream *s) const;
+  dw_offset_t GetOffset() const { return m_offset; }
+  lldb::user_id_t GetID() const;
+  uint32_t Size() const {
+    return m_is_dwarf64 ? 23
+                        : 11; /* Size in bytes of the compile unit header */
+  }
+  bool ContainsDIEOffset(dw_offset_t die_offset) const {
+    return die_offset >= GetFirstDIEOffset() &&
+           die_offset < GetNextCompileUnitOffset();
+  }
+  dw_offset_t GetFirstDIEOffset() const { return m_offset + Size(); }
+  dw_offset_t GetNextCompileUnitOffset() const {
+    return m_offset + m_length + (m_is_dwarf64 ? 12 : 4);
+  }
+  size_t GetDebugInfoSize() const {
+    return m_length + (m_is_dwarf64 ? 12 : 4) - Size(); /* Size in bytes of the
+                                                           .debug_info data
+                                                           associated with this
+                                                           compile unit. */
+  }
+  uint32_t GetLength() const { return m_length; }
+  uint16_t GetVersion() const { return m_version; }
+  const DWARFAbbreviationDeclarationSet *GetAbbreviations() const {
+    return m_abbrevs;
+  }
+  dw_offset_t GetAbbrevOffset() const;
+  uint8_t GetAddressByteSize() const { return m_addr_size; }
+  dw_addr_t GetBaseAddress() const { return m_base_addr; }
+  dw_addr_t GetAddrBase() const { return m_addr_base; }
+  void SetAddrBase(dw_addr_t addr_base, dw_offset_t base_obj_offset);
+  void ClearDIEs(bool keep_compile_unit_die);
+  void BuildAddressRangeTable(SymbolFileDWARF *dwarf2Data,
+                              DWARFDebugAranges *debug_aranges);
+
+  lldb::ByteOrder GetByteOrder() const;
+
+  lldb_private::TypeSystem *GetTypeSystem();
+
+  DWARFFormValue::FixedFormSizes GetFixedFormSizes();
+
+  void SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
+
+  DWARFDIE
+  GetCompileUnitDIEOnly() { return DWARFDIE(this, GetCompileUnitDIEPtrOnly()); }
+
+  DWARFDIE
+  DIE() { return DWARFDIE(this, DIEPtr()); }
+
+  void AddDIE(DWARFDebugInfoEntry &die) {
+    // The average bytes per DIE entry has been seen to be
+    // around 14-20 so lets pre-reserve half of that since
+    // we are now stripping the NULL tags.
+
+    // Only reserve the memory if we are adding children of
+    // the main compile unit DIE. The compile unit DIE is always
+    // the first entry, so if our size is 1, then we are adding
+    // the first compile unit child DIE and should reserve
+    // the memory.
+    if (m_die_array.empty())
+      m_die_array.reserve(GetDebugInfoSize() / 24);
+    m_die_array.push_back(die);
+  }
+
+  void AddCompileUnitDIE(DWARFDebugInfoEntry &die);
+
+  bool HasDIEsParsed() const { return m_die_array.size() > 1; }
+
+  DWARFDIE
+  GetDIE(dw_offset_t die_offset);
+
+  static uint8_t GetAddressByteSize(const DWARFCompileUnit *cu);
+
+  static bool IsDWARF64(const DWARFCompileUnit *cu);
+
+  static uint8_t GetDefaultAddressSize();
+
+  static void SetDefaultAddressSize(uint8_t addr_size);
 
-    const DWARFDebugInfoEntry*
-    GetCompileUnitDIEPtrOnly()
-    {
-        ExtractDIEsIfNeeded (true);
-        if (m_die_array.empty())
-            return NULL;
-        return &m_die_array[0];
-    }
-
-    const DWARFDebugInfoEntry*
-    DIEPtr()
-    {
-        ExtractDIEsIfNeeded (false);
-        if (m_die_array.empty())
-            return NULL;
-        return &m_die_array[0];
-    }
+  void *GetUserData() const { return m_user_data; }
 
+  void SetUserData(void *d);
+
+  bool Supports_DW_AT_APPLE_objc_complete_type();
+
+  bool DW_AT_decl_file_attributes_are_invalid();
+
+  bool Supports_unnamed_objc_bitfields();
+
+  void Index(NameToDIE &func_basenames, NameToDIE &func_fullnames,
+             NameToDIE &func_methods, NameToDIE &func_selectors,
+             NameToDIE &objc_class_selectors, NameToDIE &globals,
+             NameToDIE &types, NameToDIE &namespaces);
+
+  const DWARFDebugAranges &GetFunctionAranges();
+
+  SymbolFileDWARF *GetSymbolFileDWARF() const { return m_dwarf2Data; }
+
+  Producer GetProducer();
+
+  uint32_t GetProducerVersionMajor();
+
+  uint32_t GetProducerVersionMinor();
+
+  uint32_t GetProducerVersionUpdate();
+
+  static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
+
+  lldb::LanguageType GetLanguageType();
+
+  bool IsDWARF64() const;
+
+  bool GetIsOptimized();
+
+  SymbolFileDWARFDwo *GetDwoSymbolFile() const {
+    return m_dwo_symbol_file.get();
+  }
+
+  dw_offset_t GetBaseObjOffset() const { return m_base_obj_offset; }
+
+protected:
+  SymbolFileDWARF *m_dwarf2Data;
+  std::unique_ptr<SymbolFileDWARFDwo> m_dwo_symbol_file;
+  const DWARFAbbreviationDeclarationSet *m_abbrevs;
+  void *m_user_data;
+  DWARFDebugInfoEntry::collection
+      m_die_array; // The compile unit debug information entry item
+  std::unique_ptr<DWARFDebugAranges> m_func_aranges_ap; // A table similar to
+                                                        // the .debug_aranges
+                                                        // table, but this one
+                                                        // points to the exact
+                                                        // DW_TAG_subprogram
+                                                        // DIEs
+  dw_addr_t m_base_addr;
+  dw_offset_t m_offset;
+  dw_offset_t m_length;
+  uint16_t m_version;
+  uint8_t m_addr_size;
+  Producer m_producer;
+  uint32_t m_producer_version_major;
+  uint32_t m_producer_version_minor;
+  uint32_t m_producer_version_update;
+  lldb::LanguageType m_language_type;
+  bool m_is_dwarf64;
+  lldb_private::LazyBool m_is_optimized;
+  dw_addr_t m_addr_base; // Value of DW_AT_addr_base
+  dw_offset_t
+      m_base_obj_offset; // If this is a dwo compile unit this is the offset of
+                         // the base compile unit in the main object file
+
+  void ParseProducerInfo();
+
+  static void
+  IndexPrivate(DWARFCompileUnit *dwarf_cu, const lldb::LanguageType cu_language,
+               const DWARFFormValue::FixedFormSizes &fixed_form_sizes,
+               const dw_offset_t cu_offset, NameToDIE &func_basenames,
+               NameToDIE &func_fullnames, NameToDIE &func_methods,
+               NameToDIE &func_selectors, NameToDIE &objc_class_selectors,
+               NameToDIE &globals, NameToDIE &types, NameToDIE &namespaces);
+
+private:
+  const DWARFDebugInfoEntry *GetCompileUnitDIEPtrOnly() {
+    ExtractDIEsIfNeeded(true);
+    if (m_die_array.empty())
+      return NULL;
+    return &m_die_array[0];
+  }
+
+  const DWARFDebugInfoEntry *DIEPtr() {
+    ExtractDIEsIfNeeded(false);
+    if (m_die_array.empty())
+      return NULL;
+    return &m_die_array[0];
+  }
 
-    DISALLOW_COPY_AND_ASSIGN (DWARFCompileUnit);
+  DISALLOW_COPY_AND_ASSIGN(DWARFCompileUnit);
 };
 
-#endif  // SymbolFileDWARF_DWARFCompileUnit_h_
+#endif // SymbolFileDWARF_DWARFCompileUnit_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp Tue Sep  6 15:57:50 2016
@@ -11,13 +11,13 @@
 
 #include "DWARFASTParser.h"
 #include "DWARFCompileUnit.h"
+#include "DWARFDIECollection.h"
 #include "DWARFDebugAbbrev.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDebugInfoEntry.h"
 #include "DWARFDebugRanges.h"
 #include "DWARFDeclContext.h"
-#include "DWARFDIECollection.h"
 #include "DWARFFormValue.h"
 #include "SymbolFileDWARF.h"
 
@@ -28,543 +28,441 @@
 
 using namespace lldb_private;
 
-DIERef
-DWARFDIE::GetDIERef() const
-{
-    if (!IsValid())
-        return DIERef();
-
-    dw_offset_t cu_offset = m_cu->GetOffset();
-    if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
-        cu_offset = m_cu->GetBaseObjOffset();
-    return DIERef(cu_offset, m_die->GetOffset());
-}
-
-dw_tag_t
-DWARFDIE::Tag() const
-{
-    if (m_die)
-        return m_die->Tag();
-    else
-        return 0;
-}
-
-const char *
-DWARFDIE::GetTagAsCString () const
-{
-    return lldb_private::DW_TAG_value_to_name (Tag());
+DIERef DWARFDIE::GetDIERef() const {
+  if (!IsValid())
+    return DIERef();
+
+  dw_offset_t cu_offset = m_cu->GetOffset();
+  if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
+    cu_offset = m_cu->GetBaseObjOffset();
+  return DIERef(cu_offset, m_die->GetOffset());
 }
 
-DWARFDIE
-DWARFDIE::GetParent () const
-{
-    if (IsValid())
-        return DWARFDIE(m_cu, m_die->GetParent());
-    else
-        return DWARFDIE();
+dw_tag_t DWARFDIE::Tag() const {
+  if (m_die)
+    return m_die->Tag();
+  else
+    return 0;
+}
+
+const char *DWARFDIE::GetTagAsCString() const {
+  return lldb_private::DW_TAG_value_to_name(Tag());
 }
 
 DWARFDIE
-DWARFDIE::GetFirstChild () const
-{
-    if (IsValid())
-        return DWARFDIE(m_cu, m_die->GetFirstChild());
-    else
-        return DWARFDIE();
+DWARFDIE::GetParent() const {
+  if (IsValid())
+    return DWARFDIE(m_cu, m_die->GetParent());
+  else
+    return DWARFDIE();
 }
 
 DWARFDIE
-DWARFDIE::GetSibling () const
-{
-    if (IsValid())
-        return DWARFDIE(m_cu, m_die->GetSibling());
-    else
-        return DWARFDIE();
+DWARFDIE::GetFirstChild() const {
+  if (IsValid())
+    return DWARFDIE(m_cu, m_die->GetFirstChild());
+  else
+    return DWARFDIE();
 }
 
 DWARFDIE
-DWARFDIE::GetReferencedDIE (const dw_attr_t attr) const
-{
-    const dw_offset_t die_offset = GetAttributeValueAsReference (attr, DW_INVALID_OFFSET);
-    if (die_offset != DW_INVALID_OFFSET)
-        return GetDIE(die_offset);
-    else
-        return DWARFDIE();
+DWARFDIE::GetSibling() const {
+  if (IsValid())
+    return DWARFDIE(m_cu, m_die->GetSibling());
+  else
+    return DWARFDIE();
 }
 
 DWARFDIE
-DWARFDIE::GetDIE (dw_offset_t die_offset) const
-{
-    if (IsValid())
-        return m_cu->GetDIE(die_offset);
-    else
-        return DWARFDIE();
-}
-
-const char *
-DWARFDIE::GetAttributeValueAsString (const dw_attr_t attr, const char *fail_value) const
-{
-    if (IsValid())
-        return m_die->GetAttributeValueAsString(GetDWARF(), GetCU(), attr, fail_value);
-    else
-        return fail_value;
-}
-
-uint64_t
-DWARFDIE::GetAttributeValueAsUnsigned (const dw_attr_t attr, uint64_t fail_value) const
-{
-    if (IsValid())
-        return m_die->GetAttributeValueAsUnsigned(GetDWARF(), GetCU(), attr, fail_value);
-    else
-        return fail_value;
-}
-
-int64_t
-DWARFDIE::GetAttributeValueAsSigned (const dw_attr_t attr, int64_t fail_value) const
-{
-    if (IsValid())
-        return m_die->GetAttributeValueAsSigned(GetDWARF(), GetCU(), attr, fail_value);
-    else
-        return fail_value;
+DWARFDIE::GetReferencedDIE(const dw_attr_t attr) const {
+  const dw_offset_t die_offset =
+      GetAttributeValueAsReference(attr, DW_INVALID_OFFSET);
+  if (die_offset != DW_INVALID_OFFSET)
+    return GetDIE(die_offset);
+  else
+    return DWARFDIE();
 }
 
 DWARFDIE
-DWARFDIE::GetAttributeValueAsReferenceDIE (const dw_attr_t attr) const
-{
-    if (IsValid())
-    {
-        DWARFCompileUnit *cu = GetCU();
-        SymbolFileDWARF *dwarf = cu->GetSymbolFileDWARF();
-        const bool check_specification_or_abstract_origin = true;
-        DWARFFormValue form_value;
-        if (m_die->GetAttributeValue(dwarf, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
-            return dwarf->GetDIE(DIERef(form_value));
-    }
+DWARFDIE::GetDIE(dw_offset_t die_offset) const {
+  if (IsValid())
+    return m_cu->GetDIE(die_offset);
+  else
     return DWARFDIE();
 }
 
-uint64_t
-DWARFDIE::GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const
-{
-    if (IsValid())
-        return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr, fail_value);
-    else
-        return fail_value;
-}
-
-uint64_t
-DWARFDIE::GetAttributeValueAsAddress (const dw_attr_t attr, uint64_t fail_value) const
-{
-    if (IsValid())
-        return m_die->GetAttributeValueAsAddress(GetDWARF(), GetCU(), attr, fail_value);
-    else
-        return fail_value;
+const char *DWARFDIE::GetAttributeValueAsString(const dw_attr_t attr,
+                                                const char *fail_value) const {
+  if (IsValid())
+    return m_die->GetAttributeValueAsString(GetDWARF(), GetCU(), attr,
+                                            fail_value);
+  else
+    return fail_value;
+}
+
+uint64_t DWARFDIE::GetAttributeValueAsUnsigned(const dw_attr_t attr,
+                                               uint64_t fail_value) const {
+  if (IsValid())
+    return m_die->GetAttributeValueAsUnsigned(GetDWARF(), GetCU(), attr,
+                                              fail_value);
+  else
+    return fail_value;
+}
+
+int64_t DWARFDIE::GetAttributeValueAsSigned(const dw_attr_t attr,
+                                            int64_t fail_value) const {
+  if (IsValid())
+    return m_die->GetAttributeValueAsSigned(GetDWARF(), GetCU(), attr,
+                                            fail_value);
+  else
+    return fail_value;
 }
 
+DWARFDIE
+DWARFDIE::GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const {
+  if (IsValid()) {
+    DWARFCompileUnit *cu = GetCU();
+    SymbolFileDWARF *dwarf = cu->GetSymbolFileDWARF();
+    const bool check_specification_or_abstract_origin = true;
+    DWARFFormValue form_value;
+    if (m_die->GetAttributeValue(dwarf, cu, attr, form_value, nullptr,
+                                 check_specification_or_abstract_origin))
+      return dwarf->GetDIE(DIERef(form_value));
+  }
+  return DWARFDIE();
+}
+
+uint64_t DWARFDIE::GetAttributeValueAsReference(const dw_attr_t attr,
+                                                uint64_t fail_value) const {
+  if (IsValid())
+    return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr,
+                                               fail_value);
+  else
+    return fail_value;
+}
+
+uint64_t DWARFDIE::GetAttributeValueAsAddress(const dw_attr_t attr,
+                                              uint64_t fail_value) const {
+  if (IsValid())
+    return m_die->GetAttributeValueAsAddress(GetDWARF(), GetCU(), attr,
+                                             fail_value);
+  else
+    return fail_value;
+}
 
 DWARFDIE
-DWARFDIE::LookupDeepestBlock (lldb::addr_t file_addr) const
-{
-    if (IsValid())
-    {
-        SymbolFileDWARF *dwarf= GetDWARF();
-        DWARFCompileUnit *cu = GetCU();
-        DWARFDebugInfoEntry* function_die = nullptr;
-        DWARFDebugInfoEntry* block_die = nullptr;
-        if (m_die->LookupAddress (file_addr,
-                                  dwarf,
-                                  cu,
-                                  &function_die,
-                                  &block_die))
-        {
-            if (block_die && block_die != function_die)
-            {
-                if (cu->ContainsDIEOffset(block_die->GetOffset()))
-                    return DWARFDIE(cu, block_die);
-                else
-                    return DWARFDIE(dwarf->DebugInfo()->GetCompileUnit(DIERef(cu->GetOffset(), block_die->GetOffset())), block_die);
-            }
-        }
+DWARFDIE::LookupDeepestBlock(lldb::addr_t file_addr) const {
+  if (IsValid()) {
+    SymbolFileDWARF *dwarf = GetDWARF();
+    DWARFCompileUnit *cu = GetCU();
+    DWARFDebugInfoEntry *function_die = nullptr;
+    DWARFDebugInfoEntry *block_die = nullptr;
+    if (m_die->LookupAddress(file_addr, dwarf, cu, &function_die, &block_die)) {
+      if (block_die && block_die != function_die) {
+        if (cu->ContainsDIEOffset(block_die->GetOffset()))
+          return DWARFDIE(cu, block_die);
+        else
+          return DWARFDIE(dwarf->DebugInfo()->GetCompileUnit(
+                              DIERef(cu->GetOffset(), block_die->GetOffset())),
+                          block_die);
+      }
     }
-    return DWARFDIE();
+  }
+  return DWARFDIE();
 }
 
-lldb::user_id_t
-DWARFDIE::GetID () const
-{
-    return GetDIERef().GetUID(GetDWARF());
-}
-
-const char *
-DWARFDIE::GetName () const
-{
-    if (IsValid())
-        return m_die->GetName (GetDWARF(), m_cu);
-    else
-        return nullptr;
-}
-
-const char *
-DWARFDIE::GetMangledName () const
-{
-    if (IsValid())
-        return m_die->GetMangledName (GetDWARF(), m_cu);
-    else
-        return nullptr;
-}
-
-const char *
-DWARFDIE::GetPubname () const
-{
-    if (IsValid())
-        return m_die->GetPubname (GetDWARF(), m_cu);
-    else
-        return nullptr;
-}
-
-const char *
-DWARFDIE::GetQualifiedName (std::string &storage) const
-{
-    if (IsValid())
-        return m_die->GetQualifiedName (GetDWARF(), m_cu, storage);
-    else
-        return nullptr;
-}
-
-lldb::LanguageType
-DWARFDIE::GetLanguage () const
-{
-    if (IsValid())
-        return m_cu->GetLanguageType();
-    else
-        return lldb::eLanguageTypeUnknown;
+lldb::user_id_t DWARFDIE::GetID() const {
+  return GetDIERef().GetUID(GetDWARF());
 }
 
+const char *DWARFDIE::GetName() const {
+  if (IsValid())
+    return m_die->GetName(GetDWARF(), m_cu);
+  else
+    return nullptr;
+}
 
-lldb::ModuleSP
-DWARFDIE::GetModule () const
-{
-    SymbolFileDWARF *dwarf = GetDWARF();
-    if (dwarf)
-        return dwarf->GetObjectFile()->GetModule();
-    else
-        return lldb::ModuleSP();
-}
-
-lldb_private::CompileUnit *
-DWARFDIE::GetLLDBCompileUnit () const
-{
-    if (IsValid())
-        return GetDWARF()->GetCompUnitForDWARFCompUnit(GetCU());
-    else
-        return nullptr;
-}
-
-lldb_private::Type *
-DWARFDIE::ResolveType () const
-{
-    if (IsValid())
-        return GetDWARF()->ResolveType(*this, true);
-    else
-        return nullptr;
-}
-
-lldb_private::Type *
-DWARFDIE::ResolveTypeUID (const DIERef &die_ref) const
-{
-    SymbolFileDWARF *dwarf = GetDWARF();
-    if (dwarf)
-        return dwarf->ResolveTypeUID(dwarf->GetDIE(die_ref), true);
-    else
-        return nullptr;
-}
-
-void
-DWARFDIE::GetDeclContextDIEs (DWARFDIECollection &decl_context_dies) const
-{
-    if (IsValid())
-    {
-        DWARFDIE parent_decl_ctx_die = m_die->GetParentDeclContextDIE (GetDWARF(), GetCU());
-        if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != GetDIE())
-        {
-            decl_context_dies.Append(parent_decl_ctx_die);
-            parent_decl_ctx_die.GetDeclContextDIEs (decl_context_dies);
-        }
-    }
+const char *DWARFDIE::GetMangledName() const {
+  if (IsValid())
+    return m_die->GetMangledName(GetDWARF(), m_cu);
+  else
+    return nullptr;
 }
 
-void
-DWARFDIE::GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const
-{
-    if (IsValid())
-    {
-        dwarf_decl_ctx.SetLanguage(GetLanguage());
-        m_die->GetDWARFDeclContext (GetDWARF(), GetCU(), dwarf_decl_ctx);
-    }
-    else
-    {
-        dwarf_decl_ctx.Clear();
-    }
+const char *DWARFDIE::GetPubname() const {
+  if (IsValid())
+    return m_die->GetPubname(GetDWARF(), m_cu);
+  else
+    return nullptr;
 }
 
-void
-DWARFDIE::GetDWOContext (std::vector<CompilerContext> &context) const
-{
-    const dw_tag_t tag = Tag();
-    if (tag == DW_TAG_compile_unit)
-        return;
-    DWARFDIE parent = GetParent();
-    if (parent)
-        parent.GetDWOContext(context);
-    switch (tag)
-    {
-        case DW_TAG_module:
-            context.push_back(CompilerContext(CompilerContextKind::Module, ConstString(GetName())));
-            break;
-        case DW_TAG_namespace:
-            context.push_back(CompilerContext(CompilerContextKind::Namespace, ConstString(GetName())));
-            break;
-        case DW_TAG_structure_type:
-            context.push_back(CompilerContext(CompilerContextKind::Structure, ConstString(GetName())));
-            break;
-        case DW_TAG_union_type:
-            context.push_back(CompilerContext(CompilerContextKind::Union, ConstString(GetName())));
-            break;
-        case DW_TAG_class_type:
-            context.push_back(CompilerContext(CompilerContextKind::Class, ConstString(GetName())));
-            break;
-        case DW_TAG_enumeration_type:
-            context.push_back(CompilerContext(CompilerContextKind::Enumeration, ConstString(GetName())));
-            break;
-        case DW_TAG_subprogram:
-            context.push_back(CompilerContext(CompilerContextKind::Function, ConstString(GetPubname())));
-            break;
-        case DW_TAG_variable:
-            context.push_back(CompilerContext(CompilerContextKind::Variable, ConstString(GetPubname())));
-            break;
-        case DW_TAG_typedef:
-            context.push_back(CompilerContext(CompilerContextKind::Typedef, ConstString(GetName())));
-            break;
-        default:
-            break;
-    }
+const char *DWARFDIE::GetQualifiedName(std::string &storage) const {
+  if (IsValid())
+    return m_die->GetQualifiedName(GetDWARF(), m_cu, storage);
+  else
+    return nullptr;
+}
+
+lldb::LanguageType DWARFDIE::GetLanguage() const {
+  if (IsValid())
+    return m_cu->GetLanguageType();
+  else
+    return lldb::eLanguageTypeUnknown;
 }
 
+lldb::ModuleSP DWARFDIE::GetModule() const {
+  SymbolFileDWARF *dwarf = GetDWARF();
+  if (dwarf)
+    return dwarf->GetObjectFile()->GetModule();
+  else
+    return lldb::ModuleSP();
+}
+
+lldb_private::CompileUnit *DWARFDIE::GetLLDBCompileUnit() const {
+  if (IsValid())
+    return GetDWARF()->GetCompUnitForDWARFCompUnit(GetCU());
+  else
+    return nullptr;
+}
+
+lldb_private::Type *DWARFDIE::ResolveType() const {
+  if (IsValid())
+    return GetDWARF()->ResolveType(*this, true);
+  else
+    return nullptr;
+}
+
+lldb_private::Type *DWARFDIE::ResolveTypeUID(const DIERef &die_ref) const {
+  SymbolFileDWARF *dwarf = GetDWARF();
+  if (dwarf)
+    return dwarf->ResolveTypeUID(dwarf->GetDIE(die_ref), true);
+  else
+    return nullptr;
+}
+
+void DWARFDIE::GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const {
+  if (IsValid()) {
+    DWARFDIE parent_decl_ctx_die =
+        m_die->GetParentDeclContextDIE(GetDWARF(), GetCU());
+    if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != GetDIE()) {
+      decl_context_dies.Append(parent_decl_ctx_die);
+      parent_decl_ctx_die.GetDeclContextDIEs(decl_context_dies);
+    }
+  }
+}
 
+void DWARFDIE::GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const {
+  if (IsValid()) {
+    dwarf_decl_ctx.SetLanguage(GetLanguage());
+    m_die->GetDWARFDeclContext(GetDWARF(), GetCU(), dwarf_decl_ctx);
+  } else {
+    dwarf_decl_ctx.Clear();
+  }
+}
+
+void DWARFDIE::GetDWOContext(std::vector<CompilerContext> &context) const {
+  const dw_tag_t tag = Tag();
+  if (tag == DW_TAG_compile_unit)
+    return;
+  DWARFDIE parent = GetParent();
+  if (parent)
+    parent.GetDWOContext(context);
+  switch (tag) {
+  case DW_TAG_module:
+    context.push_back(
+        CompilerContext(CompilerContextKind::Module, ConstString(GetName())));
+    break;
+  case DW_TAG_namespace:
+    context.push_back(CompilerContext(CompilerContextKind::Namespace,
+                                      ConstString(GetName())));
+    break;
+  case DW_TAG_structure_type:
+    context.push_back(CompilerContext(CompilerContextKind::Structure,
+                                      ConstString(GetName())));
+    break;
+  case DW_TAG_union_type:
+    context.push_back(
+        CompilerContext(CompilerContextKind::Union, ConstString(GetName())));
+    break;
+  case DW_TAG_class_type:
+    context.push_back(
+        CompilerContext(CompilerContextKind::Class, ConstString(GetName())));
+    break;
+  case DW_TAG_enumeration_type:
+    context.push_back(CompilerContext(CompilerContextKind::Enumeration,
+                                      ConstString(GetName())));
+    break;
+  case DW_TAG_subprogram:
+    context.push_back(CompilerContext(CompilerContextKind::Function,
+                                      ConstString(GetPubname())));
+    break;
+  case DW_TAG_variable:
+    context.push_back(CompilerContext(CompilerContextKind::Variable,
+                                      ConstString(GetPubname())));
+    break;
+  case DW_TAG_typedef:
+    context.push_back(
+        CompilerContext(CompilerContextKind::Typedef, ConstString(GetName())));
+    break;
+  default:
+    break;
+  }
+}
 
 DWARFDIE
-DWARFDIE::GetParentDeclContextDIE () const
-{
-    if (IsValid())
-        return m_die->GetParentDeclContextDIE(GetDWARF(), m_cu);
-    else
-        return DWARFDIE();
+DWARFDIE::GetParentDeclContextDIE() const {
+  if (IsValid())
+    return m_die->GetParentDeclContextDIE(GetDWARF(), m_cu);
+  else
+    return DWARFDIE();
 }
 
+dw_offset_t DWARFDIE::GetOffset() const {
+  if (IsValid())
+    return m_die->GetOffset();
+  else
+    return DW_INVALID_OFFSET;
+}
 
-dw_offset_t
-DWARFDIE::GetOffset () const
-{
-    if (IsValid())
-        return m_die->GetOffset();
-    else
-        return DW_INVALID_OFFSET;
-}
-
-dw_offset_t
-DWARFDIE::GetCompileUnitRelativeOffset () const
-{
-    if (IsValid())
-        return m_die->GetOffset() - m_cu->GetOffset();
-    else
-        return DW_INVALID_OFFSET;
-}
-
-SymbolFileDWARF *
-DWARFDIE::GetDWARF () const
-{
-    if (m_cu)
-        return m_cu->GetSymbolFileDWARF();
-    else
-        return nullptr;
-}
-
-lldb_private::TypeSystem *
-DWARFDIE::GetTypeSystem () const
-{
-    if (m_cu)
-        return m_cu->GetTypeSystem();
-    else
-        return nullptr;
-}
-
-DWARFASTParser *
-DWARFDIE::GetDWARFParser () const
-{
-    lldb_private::TypeSystem *type_system = GetTypeSystem ();
-    if (type_system)
-        return type_system->GetDWARFParser();
-    else
-        return nullptr;
-}
-
-bool
-DWARFDIE::IsStructOrClass () const
-{
-    const dw_tag_t tag = Tag();
-    return tag == DW_TAG_class_type || tag == DW_TAG_structure_type;
+dw_offset_t DWARFDIE::GetCompileUnitRelativeOffset() const {
+  if (IsValid())
+    return m_die->GetOffset() - m_cu->GetOffset();
+  else
+    return DW_INVALID_OFFSET;
 }
 
+SymbolFileDWARF *DWARFDIE::GetDWARF() const {
+  if (m_cu)
+    return m_cu->GetSymbolFileDWARF();
+  else
+    return nullptr;
+}
 
-DWARFDIE
-DWARFDIE::GetContainingDWOModuleDIE () const
-{
-    if (IsValid())
-    {
-        DWARFDIE top_module_die;
-        // Now make sure this DIE is scoped in a DW_TAG_module tag and return true if so
-        for (DWARFDIE parent = GetParent(); parent.IsValid(); parent = parent.GetParent())
-        {
-            const dw_tag_t tag = parent.Tag();
-            if (tag == DW_TAG_module)
-                top_module_die = parent;
-            else if (tag == DW_TAG_compile_unit)
-                break;
-        }
+lldb_private::TypeSystem *DWARFDIE::GetTypeSystem() const {
+  if (m_cu)
+    return m_cu->GetTypeSystem();
+  else
+    return nullptr;
+}
 
-        return top_module_die;
-    }
-    return DWARFDIE();
+DWARFASTParser *DWARFDIE::GetDWARFParser() const {
+  lldb_private::TypeSystem *type_system = GetTypeSystem();
+  if (type_system)
+    return type_system->GetDWARFParser();
+  else
+    return nullptr;
 }
 
-lldb::ModuleSP
-DWARFDIE::GetContainingDWOModule () const
-{
-    if (IsValid())
-    {
-        DWARFDIE dwo_module_die = GetContainingDWOModuleDIE();
-
-        if (dwo_module_die)
-        {
-            const char *module_name = dwo_module_die.GetName();
-            if (module_name)
-                return GetDWARF()->GetDWOModule (lldb_private::ConstString(module_name));
-        }
-    }
-    return lldb::ModuleSP();
+bool DWARFDIE::IsStructOrClass() const {
+  const dw_tag_t tag = Tag();
+  return tag == DW_TAG_class_type || tag == DW_TAG_structure_type;
 }
 
-bool
-DWARFDIE::HasChildren () const
-{
-    if (m_die)
-        return m_die->HasChildren();
-    else
-        return false;
-}
-
-bool
-DWARFDIE::Supports_DW_AT_APPLE_objc_complete_type () const
-{
-    if (IsValid())
-        return GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
-    else
-        return false;
-}
-
-size_t
-DWARFDIE::GetAttributes (DWARFAttributes &attributes, uint32_t depth) const
-{
-    if (IsValid())
-    {
-        return m_die->GetAttributes (m_cu,
-                                     m_cu->GetFixedFormSizes(),
-                                     attributes,
-                                     depth);
+DWARFDIE
+DWARFDIE::GetContainingDWOModuleDIE() const {
+  if (IsValid()) {
+    DWARFDIE top_module_die;
+    // Now make sure this DIE is scoped in a DW_TAG_module tag and return true
+    // if so
+    for (DWARFDIE parent = GetParent(); parent.IsValid();
+         parent = parent.GetParent()) {
+      const dw_tag_t tag = parent.Tag();
+      if (tag == DW_TAG_module)
+        top_module_die = parent;
+      else if (tag == DW_TAG_compile_unit)
+        break;
     }
-    if (depth == 0)
-        attributes.Clear();
-    return 0;
-}
 
+    return top_module_die;
+  }
+  return DWARFDIE();
+}
 
-bool
-DWARFDIE::GetDIENamesAndRanges (const char * &name,
-                                const char * &mangled,
-                                DWARFRangeList& ranges,
-                                int& decl_file,
-                                int& decl_line,
-                                int& decl_column,
-                                int& call_file,
-                                int& call_line,
-                                int& call_column,
-                                lldb_private::DWARFExpression *frame_base) const
-{
-    if (IsValid())
-    {
-        return m_die->GetDIENamesAndRanges (GetDWARF(),
-                                            GetCU(),
-                                            name,
-                                            mangled,
-                                            ranges,
-                                            decl_file,
-                                            decl_line,
-                                            decl_column,
-                                            call_file,
-                                            call_line,
-                                            call_column,
-                                            frame_base);
+lldb::ModuleSP DWARFDIE::GetContainingDWOModule() const {
+  if (IsValid()) {
+    DWARFDIE dwo_module_die = GetContainingDWOModuleDIE();
+
+    if (dwo_module_die) {
+      const char *module_name = dwo_module_die.GetName();
+      if (module_name)
+        return GetDWARF()->GetDWOModule(lldb_private::ConstString(module_name));
     }
-    else
-        return false;
+  }
+  return lldb::ModuleSP();
+}
+
+bool DWARFDIE::HasChildren() const {
+  if (m_die)
+    return m_die->HasChildren();
+  else
+    return false;
 }
 
-void
-DWARFDIE::Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const
-{
-    if (s && IsValid())
-        m_die->Dump (GetDWARF(), GetCU(), *s, recurse_depth);
+bool DWARFDIE::Supports_DW_AT_APPLE_objc_complete_type() const {
+  if (IsValid())
+    return GetDWARF()->Supports_DW_AT_APPLE_objc_complete_type(m_cu);
+  else
+    return false;
 }
 
+size_t DWARFDIE::GetAttributes(DWARFAttributes &attributes,
+                               uint32_t depth) const {
+  if (IsValid()) {
+    return m_die->GetAttributes(m_cu, m_cu->GetFixedFormSizes(), attributes,
+                                depth);
+  }
+  if (depth == 0)
+    attributes.Clear();
+  return 0;
+}
 
-CompilerDecl
-DWARFDIE::GetDecl () const
-{
-    DWARFASTParser *dwarf_ast = GetDWARFParser();
-    if (dwarf_ast)
-        return dwarf_ast->GetDeclForUIDFromDWARF(*this);
-    else
-        return CompilerDecl();
+bool DWARFDIE::GetDIENamesAndRanges(
+    const char *&name, const char *&mangled, DWARFRangeList &ranges,
+    int &decl_file, int &decl_line, int &decl_column, int &call_file,
+    int &call_line, int &call_column,
+    lldb_private::DWARFExpression *frame_base) const {
+  if (IsValid()) {
+    return m_die->GetDIENamesAndRanges(
+        GetDWARF(), GetCU(), name, mangled, ranges, decl_file, decl_line,
+        decl_column, call_file, call_line, call_column, frame_base);
+  } else
+    return false;
 }
 
-CompilerDeclContext
-DWARFDIE::GetDeclContext () const
-{
-    DWARFASTParser *dwarf_ast = GetDWARFParser();
-    if (dwarf_ast)
-        return dwarf_ast->GetDeclContextForUIDFromDWARF(*this);
-    else
-        return CompilerDeclContext();
+void DWARFDIE::Dump(lldb_private::Stream *s,
+                    const uint32_t recurse_depth) const {
+  if (s && IsValid())
+    m_die->Dump(GetDWARF(), GetCU(), *s, recurse_depth);
 }
 
-CompilerDeclContext
-DWARFDIE::GetContainingDeclContext () const
-{
-    DWARFASTParser *dwarf_ast = GetDWARFParser();
-    if (dwarf_ast)
-        return dwarf_ast->GetDeclContextContainingUIDFromDWARF(*this);
-    else
-        return CompilerDeclContext();
+CompilerDecl DWARFDIE::GetDecl() const {
+  DWARFASTParser *dwarf_ast = GetDWARFParser();
+  if (dwarf_ast)
+    return dwarf_ast->GetDeclForUIDFromDWARF(*this);
+  else
+    return CompilerDecl();
 }
 
-bool operator == (const DWARFDIE &lhs, const DWARFDIE &rhs)
-{
-    return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
+CompilerDeclContext DWARFDIE::GetDeclContext() const {
+  DWARFASTParser *dwarf_ast = GetDWARFParser();
+  if (dwarf_ast)
+    return dwarf_ast->GetDeclContextForUIDFromDWARF(*this);
+  else
+    return CompilerDeclContext();
 }
 
-bool operator != (const DWARFDIE &lhs, const DWARFDIE &rhs)
-{
-    return lhs.GetDIE() != rhs.GetDIE() || lhs.GetCU() != rhs.GetCU();
+CompilerDeclContext DWARFDIE::GetContainingDeclContext() const {
+  DWARFASTParser *dwarf_ast = GetDWARFParser();
+  if (dwarf_ast)
+    return dwarf_ast->GetDeclContextContainingUIDFromDWARF(*this);
+  else
+    return CompilerDeclContext();
 }
 
+bool operator==(const DWARFDIE &lhs, const DWARFDIE &rhs) {
+  return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
+}
 
+bool operator!=(const DWARFDIE &lhs, const DWARFDIE &rhs) {
+  return lhs.GetDIE() != rhs.GetDIE() || lhs.GetCU() != rhs.GetCU();
+}

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.h Tue Sep  6 15:57:50 2016
@@ -10,8 +10,8 @@
 #ifndef SymbolFileDWARF_DWARFDIE_h_
 #define SymbolFileDWARF_DWARFDIE_h_
 
-#include "lldb/lldb-types.h"
 #include "lldb/Core/dwarf.h"
+#include "lldb/lldb-types.h"
 
 struct DIERef;
 class DWARFASTParser;
@@ -22,274 +22,200 @@ class DWARFDeclContext;
 class DWARFDIECollection;
 class SymbolFileDWARF;
 
-class DWARFDIE
-{
+class DWARFDIE {
 public:
-    DWARFDIE () :
-        m_cu (nullptr),
-        m_die (nullptr)
-    {
-    }
+  DWARFDIE() : m_cu(nullptr), m_die(nullptr) {}
 
-    DWARFDIE (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) :
-        m_cu (cu),
-        m_die (die)
-    {
-    }
+  DWARFDIE(DWARFCompileUnit *cu, DWARFDebugInfoEntry *die)
+      : m_cu(cu), m_die(die) {}
 
-    DWARFDIE (const DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) :
-        m_cu (const_cast<DWARFCompileUnit *>(cu)),
-        m_die (die)
-    {
-    }
+  DWARFDIE(const DWARFCompileUnit *cu, DWARFDebugInfoEntry *die)
+      : m_cu(const_cast<DWARFCompileUnit *>(cu)), m_die(die) {}
 
-    DWARFDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) :
-        m_cu (cu),
-        m_die (const_cast<DWARFDebugInfoEntry *>(die))
-    {
-    }
+  DWARFDIE(DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die)
+      : m_cu(cu), m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
 
-    DWARFDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) :
-        m_cu (const_cast<DWARFCompileUnit *>(cu)),
-        m_die (const_cast<DWARFDebugInfoEntry *>(die))
-    {
-    }
+  DWARFDIE(const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die)
+      : m_cu(const_cast<DWARFCompileUnit *>(cu)),
+        m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
 
-    //----------------------------------------------------------------------
-    // Tests
-    //----------------------------------------------------------------------
-    explicit operator bool () const
-    {
-        return IsValid();
-    }
+  //----------------------------------------------------------------------
+  // Tests
+  //----------------------------------------------------------------------
+  explicit operator bool() const { return IsValid(); }
 
-    bool
-    IsValid() const
-    {
-        return m_cu && m_die;
-    }
+  bool IsValid() const { return m_cu && m_die; }
 
-    bool
-    IsStructOrClass () const;
+  bool IsStructOrClass() const;
 
-    bool
-    HasChildren () const;
+  bool HasChildren() const;
 
-    bool
-    Supports_DW_AT_APPLE_objc_complete_type () const;
+  bool Supports_DW_AT_APPLE_objc_complete_type() const;
 
-    //----------------------------------------------------------------------
-    // Accessors
-    //----------------------------------------------------------------------
-    SymbolFileDWARF *
-    GetDWARF () const;
-
-    DWARFCompileUnit *
-    GetCU() const
-    {
-        return m_cu;
-    }
+  //----------------------------------------------------------------------
+  // Accessors
+  //----------------------------------------------------------------------
+  SymbolFileDWARF *GetDWARF() const;
 
-    DWARFDebugInfoEntry *
-    GetDIE() const
-    {
-        return m_die;
-    }
+  DWARFCompileUnit *GetCU() const { return m_cu; }
 
-    DIERef
-    GetDIERef() const;
+  DWARFDebugInfoEntry *GetDIE() const { return m_die; }
 
-    lldb_private::TypeSystem *
-    GetTypeSystem () const;
+  DIERef GetDIERef() const;
 
-    DWARFASTParser *
-    GetDWARFParser () const;
+  lldb_private::TypeSystem *GetTypeSystem() const;
 
-    void
-    Set (DWARFCompileUnit *cu, DWARFDebugInfoEntry *die)
-    {
-        if (cu && die)
-        {
-            m_cu = cu;
-            m_die = die;
-        }
-        else
-        {
-            Clear();
-        }
-    }
+  DWARFASTParser *GetDWARFParser() const;
 
-    void
-    Clear ()
-    {
-        m_cu = nullptr;
-        m_die = nullptr;
+  void Set(DWARFCompileUnit *cu, DWARFDebugInfoEntry *die) {
+    if (cu && die) {
+      m_cu = cu;
+      m_die = die;
+    } else {
+      Clear();
     }
+  }
+
+  void Clear() {
+    m_cu = nullptr;
+    m_die = nullptr;
+  }
+
+  lldb::ModuleSP GetContainingDWOModule() const;
+
+  DWARFDIE
+  GetContainingDWOModuleDIE() const;
+
+  //----------------------------------------------------------------------
+  // Accessing information about a DIE
+  //----------------------------------------------------------------------
+  dw_tag_t Tag() const;
+
+  const char *GetTagAsCString() const;
+
+  dw_offset_t GetOffset() const;
+
+  dw_offset_t GetCompileUnitRelativeOffset() const;
+
+  //----------------------------------------------------------------------
+  // Get the LLDB user ID for this DIE. This is often just the DIE offset,
+  // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
+  // we are doing Darwin DWARF in .o file, or DWARF stand alone debug
+  // info.
+  //----------------------------------------------------------------------
+  lldb::user_id_t GetID() const;
+
+  const char *GetName() const;
+
+  const char *GetMangledName() const;
+
+  const char *GetPubname() const;
+
+  const char *GetQualifiedName(std::string &storage) const;
+
+  lldb::LanguageType GetLanguage() const;
+
+  lldb::ModuleSP GetModule() const;
+
+  lldb_private::CompileUnit *GetLLDBCompileUnit() const;
+
+  lldb_private::Type *ResolveType() const;
+
+  //----------------------------------------------------------------------
+  // Resolve a type by UID using this DIE's DWARF file
+  //----------------------------------------------------------------------
+  lldb_private::Type *ResolveTypeUID(const DIERef &die_ref) const;
+
+  //----------------------------------------------------------------------
+  // Functions for obtaining DIE relations and references
+  //----------------------------------------------------------------------
+
+  DWARFDIE
+  GetParent() const;
+
+  DWARFDIE
+  GetFirstChild() const;
+
+  DWARFDIE
+  GetSibling() const;
+
+  DWARFDIE
+  GetReferencedDIE(const dw_attr_t attr) const;
+
+  //----------------------------------------------------------------------
+  // Get a another DIE from the same DWARF file as this DIE. This will
+  // check the current DIE's compile unit first to see if "die_offset" is
+  // in the same compile unit, and fall back to checking the DWARF file.
+  //----------------------------------------------------------------------
+  DWARFDIE
+  GetDIE(dw_offset_t die_offset) const;
+
+  DWARFDIE
+  LookupDeepestBlock(lldb::addr_t file_addr) const;
+
+  DWARFDIE
+  GetParentDeclContextDIE() const;
+
+  //----------------------------------------------------------------------
+  // DeclContext related functions
+  //----------------------------------------------------------------------
+  void GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const;
+
+  void GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const;
+
+  void GetDWOContext(std::vector<lldb_private::CompilerContext> &context) const;
+
+  //----------------------------------------------------------------------
+  // Getting attribute values from the DIE.
+  //
+  // GetAttributeValueAsXXX() functions should only be used if you are
+  // looking for one or two attributes on a DIE. If you are trying to
+  // parse all attributes, use GetAttributes (...) instead
+  //----------------------------------------------------------------------
+  const char *GetAttributeValueAsString(const dw_attr_t attr,
+                                        const char *fail_value) const;
+
+  uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr,
+                                       uint64_t fail_value) const;
+
+  int64_t GetAttributeValueAsSigned(const dw_attr_t attr,
+                                    int64_t fail_value) const;
+
+  uint64_t GetAttributeValueAsReference(const dw_attr_t attr,
+                                        uint64_t fail_value) const;
+
+  DWARFDIE
+  GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const;
+
+  uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,
+                                      uint64_t fail_value) const;
+
+  size_t GetAttributes(DWARFAttributes &attributes, uint32_t depth = 0) const;
 
-    lldb::ModuleSP
-    GetContainingDWOModule () const;
+  bool GetDIENamesAndRanges(const char *&name, const char *&mangled,
+                            DWARFRangeList &ranges, int &decl_file,
+                            int &decl_line, int &decl_column, int &call_file,
+                            int &call_line, int &call_column,
+                            lldb_private::DWARFExpression *frame_base) const;
 
-    DWARFDIE
-    GetContainingDWOModuleDIE () const;
+  //----------------------------------------------------------------------
+  // Pretty printing
+  //----------------------------------------------------------------------
 
-    //----------------------------------------------------------------------
-    // Accessing information about a DIE
-    //----------------------------------------------------------------------
-    dw_tag_t
-    Tag() const;
-
-    const char *
-    GetTagAsCString () const;
-
-    dw_offset_t
-    GetOffset () const;
-
-    dw_offset_t
-    GetCompileUnitRelativeOffset () const;
-
-    //----------------------------------------------------------------------
-    // Get the LLDB user ID for this DIE. This is often just the DIE offset,
-    // but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
-    // we are doing Darwin DWARF in .o file, or DWARF stand alone debug
-    // info.
-    //----------------------------------------------------------------------
-    lldb::user_id_t
-    GetID() const;
-
-    const char *
-    GetName () const;
-
-    const char *
-    GetMangledName () const;
-
-    const char *
-    GetPubname () const;
-
-    const char *
-    GetQualifiedName (std::string &storage) const;
-
-    lldb::LanguageType
-    GetLanguage () const;
-
-    lldb::ModuleSP
-    GetModule () const;
-
-    lldb_private::CompileUnit *
-    GetLLDBCompileUnit () const;
-
-    lldb_private::Type *
-    ResolveType () const;
-
-    //----------------------------------------------------------------------
-    // Resolve a type by UID using this DIE's DWARF file
-    //----------------------------------------------------------------------
-    lldb_private::Type *
-    ResolveTypeUID (const DIERef &die_ref) const;
-
-    //----------------------------------------------------------------------
-    // Functions for obtaining DIE relations and references
-    //----------------------------------------------------------------------
-
-    DWARFDIE
-    GetParent () const;
-
-    DWARFDIE
-    GetFirstChild () const;
-
-    DWARFDIE
-    GetSibling () const;
-
-    DWARFDIE
-    GetReferencedDIE (const dw_attr_t attr) const;
-
-    //----------------------------------------------------------------------
-    // Get a another DIE from the same DWARF file as this DIE. This will
-    // check the current DIE's compile unit first to see if "die_offset" is
-    // in the same compile unit, and fall back to checking the DWARF file.
-    //----------------------------------------------------------------------
-    DWARFDIE
-    GetDIE (dw_offset_t die_offset) const;
-
-    DWARFDIE
-    LookupDeepestBlock (lldb::addr_t file_addr) const;
-
-    DWARFDIE
-    GetParentDeclContextDIE () const;
-
-    //----------------------------------------------------------------------
-    // DeclContext related functions
-    //----------------------------------------------------------------------
-    void
-    GetDeclContextDIEs (DWARFDIECollection &decl_context_dies) const;
-
-    void
-    GetDWARFDeclContext (DWARFDeclContext &dwarf_decl_ctx) const;
-
-    void
-    GetDWOContext (std::vector<lldb_private::CompilerContext> &context) const;
-
-    //----------------------------------------------------------------------
-    // Getting attribute values from the DIE.
-    //
-    // GetAttributeValueAsXXX() functions should only be used if you are
-    // looking for one or two attributes on a DIE. If you are trying to
-    // parse all attributes, use GetAttributes (...) instead
-    //----------------------------------------------------------------------
-    const char *
-    GetAttributeValueAsString (const dw_attr_t attr, const char *fail_value) const;
-
-    uint64_t
-    GetAttributeValueAsUnsigned (const dw_attr_t attr, uint64_t fail_value) const;
-
-    int64_t
-    GetAttributeValueAsSigned (const dw_attr_t attr, int64_t fail_value) const;
-
-    uint64_t
-    GetAttributeValueAsReference (const dw_attr_t attr, uint64_t fail_value) const;
-
-    DWARFDIE
-    GetAttributeValueAsReferenceDIE (const dw_attr_t attr) const;
-
-    uint64_t
-    GetAttributeValueAsAddress (const dw_attr_t attr, uint64_t fail_value) const;
-
-    size_t
-    GetAttributes (DWARFAttributes &attributes, uint32_t depth = 0) const;
-
-    bool
-    GetDIENamesAndRanges (const char * &name,
-                          const char * &mangled,
-                          DWARFRangeList& ranges,
-                          int& decl_file,
-                          int& decl_line,
-                          int& decl_column,
-                          int& call_file,
-                          int& call_line,
-                          int& call_column,
-                          lldb_private::DWARFExpression *frame_base) const;
-
-    //----------------------------------------------------------------------
-    // Pretty printing
-    //----------------------------------------------------------------------
-
-    void
-    Dump (lldb_private::Stream *s, const uint32_t recurse_depth) const;
+  void Dump(lldb_private::Stream *s, const uint32_t recurse_depth) const;
 
-    lldb_private::CompilerDecl
-    GetDecl () const;
+  lldb_private::CompilerDecl GetDecl() const;
 
-    lldb_private::CompilerDeclContext
-    GetDeclContext() const;
+  lldb_private::CompilerDeclContext GetDeclContext() const;
 
-    lldb_private::CompilerDeclContext
-    GetContainingDeclContext() const;
+  lldb_private::CompilerDeclContext GetContainingDeclContext() const;
 
 protected:
-    DWARFCompileUnit *m_cu;
-    DWARFDebugInfoEntry *m_die;
+  DWARFCompileUnit *m_cu;
+  DWARFDebugInfoEntry *m_die;
 };
 
-bool operator == (const DWARFDIE &lhs, const DWARFDIE &rhs);
-bool operator != (const DWARFDIE &lhs, const DWARFDIE &rhs);
+bool operator==(const DWARFDIE &lhs, const DWARFDIE &rhs);
+bool operator!=(const DWARFDIE &lhs, const DWARFDIE &rhs);
 
-#endif  // SymbolFileDWARF_DWARFDIE_h_
+#endif // SymbolFileDWARF_DWARFDIE_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp Tue Sep  6 15:57:50 2016
@@ -16,32 +16,20 @@
 using namespace lldb_private;
 using namespace std;
 
-void
-DWARFDIECollection::Append (const DWARFDIE &die)
-{
-    m_dies.push_back (die);
-}
+void DWARFDIECollection::Append(const DWARFDIE &die) { m_dies.push_back(die); }
 
 DWARFDIE
-DWARFDIECollection::GetDIEAtIndex(uint32_t idx) const
-{
-    if (idx < m_dies.size())
-        return m_dies[idx];
-    return DWARFDIE();
+DWARFDIECollection::GetDIEAtIndex(uint32_t idx) const {
+  if (idx < m_dies.size())
+    return m_dies[idx];
+  return DWARFDIE();
 }
 
+size_t DWARFDIECollection::Size() const { return m_dies.size(); }
 
-size_t
-DWARFDIECollection::Size() const
-{
-    return m_dies.size();
-}
-
-void
-DWARFDIECollection::Dump(Stream *s, const char* title) const
-{
-    if (title && title[0] != '\0')
-        s->Printf( "%s\n", title);
-    for (const auto &die : m_dies)
-        s->Printf( "0x%8.8x\n", die.GetOffset());
+void DWARFDIECollection::Dump(Stream *s, const char *title) const {
+  if (title && title[0] != '\0')
+    s->Printf("%s\n", title);
+  for (const auto &die : m_dies)
+    s->Printf("0x%8.8x\n", die.GetOffset());
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h Tue Sep  6 15:57:50 2016
@@ -13,36 +13,26 @@
 #include "DWARFDIE.h"
 #include <vector>
 
-class DWARFDIECollection
-{
+class DWARFDIECollection {
 public:
-    DWARFDIECollection() :
-        m_dies()
-    {
-    }
-    ~DWARFDIECollection()
-    {
-    }
-
-    void
-    Append (const DWARFDIE &die);
+  DWARFDIECollection() : m_dies() {}
+  ~DWARFDIECollection() {}
 
-    void
-    Dump(lldb_private::Stream *s, const char* title) const;
+  void Append(const DWARFDIE &die);
 
-    DWARFDIE
-    GetDIEAtIndex (uint32_t idx) const;
+  void Dump(lldb_private::Stream *s, const char *title) const;
 
-    size_t
-    Size() const;
+  DWARFDIE
+  GetDIEAtIndex(uint32_t idx) const;
+
+  size_t Size() const;
 
 protected:
-    typedef std::vector<DWARFDIE>               collection;
-    typedef collection::iterator                iterator;
-    typedef collection::const_iterator          const_iterator;
+  typedef std::vector<DWARFDIE> collection;
+  typedef collection::iterator iterator;
+  typedef collection::const_iterator const_iterator;
 
-    collection m_dies;  // Ordered list of die offsets
+  collection m_dies; // Ordered list of die offsets
 };
 
-
-#endif  // SymbolFileDWARF_DWARFDIECollection_h_
+#endif // SymbolFileDWARF_DWARFDIECollection_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp Tue Sep  6 15:57:50 2016
@@ -12,19 +12,16 @@
 namespace lldb_private {
 
 uint64_t
-DWARFDataExtractor::GetDWARFInitialLength(lldb::offset_t *offset_ptr) const
-{
-    uint64_t length = GetU32(offset_ptr);
-    m_is_dwarf64 = (length == UINT32_MAX);
-    if (m_is_dwarf64)
-        length = GetU64(offset_ptr);
-    return length;
+DWARFDataExtractor::GetDWARFInitialLength(lldb::offset_t *offset_ptr) const {
+  uint64_t length = GetU32(offset_ptr);
+  m_is_dwarf64 = (length == UINT32_MAX);
+  if (m_is_dwarf64)
+    length = GetU64(offset_ptr);
+  return length;
 }
 
 dw_offset_t
-DWARFDataExtractor::GetDWARFOffset(lldb::offset_t *offset_ptr) const
-{
-    return GetMaxU64(offset_ptr, m_is_dwarf64 ? 8 : 4);
+DWARFDataExtractor::GetDWARFOffset(lldb::offset_t *offset_ptr) const {
+  return GetMaxU64(offset_ptr, m_is_dwarf64 ? 8 : 4);
 }
-
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h Tue Sep  6 15:57:50 2016
@@ -7,8 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef liblldb_DWARFDataExtractor_h_                                 
-#define liblldb_DWARFDataExtractor_h_                                 
+#ifndef liblldb_DWARFDataExtractor_h_
+#define liblldb_DWARFDataExtractor_h_
 
 // Other libraries and framework includes.
 #include "lldb/Core/DataExtractor.h"
@@ -16,30 +16,25 @@
 
 namespace lldb_private {
 
-class DWARFDataExtractor : public lldb_private::DataExtractor
-{
+class DWARFDataExtractor : public lldb_private::DataExtractor {
 public:
-    DWARFDataExtractor() : DataExtractor(), m_is_dwarf64(false) { }
+  DWARFDataExtractor() : DataExtractor(), m_is_dwarf64(false) {}
 
-    DWARFDataExtractor (const DWARFDataExtractor& data, lldb::offset_t offset, lldb::offset_t length) :
-      DataExtractor(data, offset, length), m_is_dwarf64(false) { }
+  DWARFDataExtractor(const DWARFDataExtractor &data, lldb::offset_t offset,
+                     lldb::offset_t length)
+      : DataExtractor(data, offset, length), m_is_dwarf64(false) {}
 
-    uint64_t
-    GetDWARFInitialLength(lldb::offset_t *offset_ptr) const;
+  uint64_t GetDWARFInitialLength(lldb::offset_t *offset_ptr) const;
 
-    dw_offset_t
-    GetDWARFOffset(lldb::offset_t *offset_ptr) const;
+  dw_offset_t GetDWARFOffset(lldb::offset_t *offset_ptr) const;
 
-    size_t
-    GetDWARFSizeofInitialLength() const { return m_is_dwarf64 ? 12 : 4; }
+  size_t GetDWARFSizeofInitialLength() const { return m_is_dwarf64 ? 12 : 4; }
 
-    bool
-    IsDWARF64() const { return m_is_dwarf64; }
+  bool IsDWARF64() const { return m_is_dwarf64; }
 
 protected:
-    mutable bool m_is_dwarf64;
+  mutable bool m_is_dwarf64;
 };
-
 }
 
-#endif  // liblldb_DWARFDataExtractor_h_                                 
+#endif // liblldb_DWARFDataExtractor_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp Tue Sep  6 15:57:50 2016
@@ -18,74 +18,63 @@ using namespace std;
 //----------------------------------------------------------------------
 // DWARFAbbreviationDeclarationSet::Clear()
 //----------------------------------------------------------------------
-void
-DWARFAbbreviationDeclarationSet::Clear()
-{
-    m_idx_offset = 0;
-    m_decls.clear();
+void DWARFAbbreviationDeclarationSet::Clear() {
+  m_idx_offset = 0;
+  m_decls.clear();
 }
 
-
 //----------------------------------------------------------------------
 // DWARFAbbreviationDeclarationSet::Extract()
 //----------------------------------------------------------------------
-bool
-DWARFAbbreviationDeclarationSet::Extract(const DWARFDataExtractor& data, lldb::offset_t *offset_ptr)
-{
-    const lldb::offset_t begin_offset = *offset_ptr;
-    m_offset = begin_offset;
-    Clear();
-    DWARFAbbreviationDeclaration abbrevDeclaration;
-    dw_uleb128_t prev_abbr_code = 0;
-    while (abbrevDeclaration.Extract(data, offset_ptr))
-    {
-        m_decls.push_back(abbrevDeclaration);
-        if (m_idx_offset == 0)
-            m_idx_offset = abbrevDeclaration.Code();
-        else
-        {
-            if (prev_abbr_code + 1 != abbrevDeclaration.Code())
-                m_idx_offset = UINT32_MAX;    // Out of order indexes, we can't do O(1) lookups...
-        }
-        prev_abbr_code = abbrevDeclaration.Code();
-    }
-    return begin_offset != *offset_ptr;
+bool DWARFAbbreviationDeclarationSet::Extract(const DWARFDataExtractor &data,
+                                              lldb::offset_t *offset_ptr) {
+  const lldb::offset_t begin_offset = *offset_ptr;
+  m_offset = begin_offset;
+  Clear();
+  DWARFAbbreviationDeclaration abbrevDeclaration;
+  dw_uleb128_t prev_abbr_code = 0;
+  while (abbrevDeclaration.Extract(data, offset_ptr)) {
+    m_decls.push_back(abbrevDeclaration);
+    if (m_idx_offset == 0)
+      m_idx_offset = abbrevDeclaration.Code();
+    else {
+      if (prev_abbr_code + 1 != abbrevDeclaration.Code())
+        m_idx_offset =
+            UINT32_MAX; // Out of order indexes, we can't do O(1) lookups...
+    }
+    prev_abbr_code = abbrevDeclaration.Code();
+  }
+  return begin_offset != *offset_ptr;
 }
 
-
 //----------------------------------------------------------------------
 // DWARFAbbreviationDeclarationSet::Dump()
 //----------------------------------------------------------------------
-void
-DWARFAbbreviationDeclarationSet::Dump(Stream *s) const
-{
-    std::for_each (m_decls.begin(), m_decls.end(), bind2nd(std::mem_fun_ref(&DWARFAbbreviationDeclaration::Dump),s));
+void DWARFAbbreviationDeclarationSet::Dump(Stream *s) const {
+  std::for_each(
+      m_decls.begin(), m_decls.end(),
+      bind2nd(std::mem_fun_ref(&DWARFAbbreviationDeclaration::Dump), s));
 }
 
-
 //----------------------------------------------------------------------
 // DWARFAbbreviationDeclarationSet::GetAbbreviationDeclaration()
 //----------------------------------------------------------------------
-const DWARFAbbreviationDeclaration*
-DWARFAbbreviationDeclarationSet::GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const
-{
-    if (m_idx_offset == UINT32_MAX)
-    {
-        DWARFAbbreviationDeclarationCollConstIter pos;
-        DWARFAbbreviationDeclarationCollConstIter end = m_decls.end();
-        for (pos = m_decls.begin(); pos != end; ++pos)
-        {
-            if (pos->Code() == abbrCode)
-                return &(*pos);
-        }
-    }
-    else
-    {
-        uint32_t idx = abbrCode - m_idx_offset;
-        if (idx < m_decls.size())
-            return &m_decls[idx];
-    }
-    return NULL;
+const DWARFAbbreviationDeclaration *
+DWARFAbbreviationDeclarationSet::GetAbbreviationDeclaration(
+    dw_uleb128_t abbrCode) const {
+  if (m_idx_offset == UINT32_MAX) {
+    DWARFAbbreviationDeclarationCollConstIter pos;
+    DWARFAbbreviationDeclarationCollConstIter end = m_decls.end();
+    for (pos = m_decls.begin(); pos != end; ++pos) {
+      if (pos->Code() == abbrCode)
+        return &(*pos);
+    }
+  } else {
+    uint32_t idx = abbrCode - m_idx_offset;
+    if (idx < m_decls.size())
+      return &m_decls[idx];
+  }
+  return NULL;
 }
 
 //----------------------------------------------------------------------
@@ -94,22 +83,20 @@ DWARFAbbreviationDeclarationSet::GetAbbr
 // Append an abbreviation declaration with a sequential code for O(n)
 // lookups. Handy when creating an DWARFAbbreviationDeclarationSet.
 //----------------------------------------------------------------------
-dw_uleb128_t
-DWARFAbbreviationDeclarationSet::AppendAbbrevDeclSequential(const DWARFAbbreviationDeclaration& abbrevDecl)
-{
-    // Get the next abbreviation code based on our current array size
-    dw_uleb128_t code = m_decls.size()+1;
+dw_uleb128_t DWARFAbbreviationDeclarationSet::AppendAbbrevDeclSequential(
+    const DWARFAbbreviationDeclaration &abbrevDecl) {
+  // Get the next abbreviation code based on our current array size
+  dw_uleb128_t code = m_decls.size() + 1;
 
-    // Push the new declaration on the back
-    m_decls.push_back(abbrevDecl);
+  // Push the new declaration on the back
+  m_decls.push_back(abbrevDecl);
 
-    // Update the code for this new declaration
-    m_decls.back().SetCode(code);
+  // Update the code for this new declaration
+  m_decls.back().SetCode(code);
 
-    return code;    // return the new abbreviation code!
+  return code; // return the new abbreviation code!
 }
 
-
 //----------------------------------------------------------------------
 // Encode
 //
@@ -117,8 +104,9 @@ DWARFAbbreviationDeclarationSet::AppendA
 // into a byte representation as would be found in a ".debug_abbrev"
 // debug information section.
 //----------------------------------------------------------------------
-//void
-//DWARFAbbreviationDeclarationSet::Encode(BinaryStreamBuf& debug_abbrev_buf) const
+// void
+// DWARFAbbreviationDeclarationSet::Encode(BinaryStreamBuf& debug_abbrev_buf)
+// const
 //{
 //  DWARFAbbreviationDeclarationCollConstIter pos;
 //  DWARFAbbreviationDeclarationCollConstIter end = m_decls.end();
@@ -127,76 +115,63 @@ DWARFAbbreviationDeclarationSet::AppendA
 //  debug_abbrev_buf.Append8(0);
 //}
 
-
 //----------------------------------------------------------------------
 // DWARFDebugAbbrev constructor
 //----------------------------------------------------------------------
-DWARFDebugAbbrev::DWARFDebugAbbrev() :
-    m_abbrevCollMap(),
-    m_prev_abbr_offset_pos(m_abbrevCollMap.end())
-{
-}
-
+DWARFDebugAbbrev::DWARFDebugAbbrev()
+    : m_abbrevCollMap(), m_prev_abbr_offset_pos(m_abbrevCollMap.end()) {}
 
 //----------------------------------------------------------------------
 // DWARFDebugAbbrev::Parse()
 //----------------------------------------------------------------------
-void
-DWARFDebugAbbrev::Parse(const DWARFDataExtractor& data)
-{
-    lldb::offset_t offset = 0;
-
-    while (data.ValidOffset(offset))
-    {
-        uint32_t initial_cu_offset = offset;
-        DWARFAbbreviationDeclarationSet abbrevDeclSet;
-
-        if (abbrevDeclSet.Extract(data, &offset))
-            m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet;
-        else
-            break;
-    }
-    m_prev_abbr_offset_pos = m_abbrevCollMap.end();
+void DWARFDebugAbbrev::Parse(const DWARFDataExtractor &data) {
+  lldb::offset_t offset = 0;
+
+  while (data.ValidOffset(offset)) {
+    uint32_t initial_cu_offset = offset;
+    DWARFAbbreviationDeclarationSet abbrevDeclSet;
+
+    if (abbrevDeclSet.Extract(data, &offset))
+      m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet;
+    else
+      break;
+  }
+  m_prev_abbr_offset_pos = m_abbrevCollMap.end();
 }
 
 //----------------------------------------------------------------------
 // DWARFDebugAbbrev::Dump()
 //----------------------------------------------------------------------
-void
-DWARFDebugAbbrev::Dump(Stream *s) const
-{
-    if (m_abbrevCollMap.empty())
-    {
-        s->PutCString("< EMPTY >\n");
-        return;
-    }
-
-    DWARFAbbreviationDeclarationCollMapConstIter pos;
-    for (pos = m_abbrevCollMap.begin(); pos != m_abbrevCollMap.end(); ++pos)
-    {
-        s->Printf("Abbrev table for offset: 0x%8.8x\n", pos->first);
-        pos->second.Dump(s);
-    }
+void DWARFDebugAbbrev::Dump(Stream *s) const {
+  if (m_abbrevCollMap.empty()) {
+    s->PutCString("< EMPTY >\n");
+    return;
+  }
+
+  DWARFAbbreviationDeclarationCollMapConstIter pos;
+  for (pos = m_abbrevCollMap.begin(); pos != m_abbrevCollMap.end(); ++pos) {
+    s->Printf("Abbrev table for offset: 0x%8.8x\n", pos->first);
+    pos->second.Dump(s);
+  }
 }
 
-
 //----------------------------------------------------------------------
 // DWARFDebugAbbrev::GetAbbreviationDeclarationSet()
 //----------------------------------------------------------------------
-const DWARFAbbreviationDeclarationSet*
-DWARFDebugAbbrev::GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const
-{
-    DWARFAbbreviationDeclarationCollMapConstIter end = m_abbrevCollMap.end();
-    DWARFAbbreviationDeclarationCollMapConstIter pos;
-    if (m_prev_abbr_offset_pos != end && m_prev_abbr_offset_pos->first == cu_abbr_offset)
-        return &(m_prev_abbr_offset_pos->second);
-    else
-    {
-        pos = m_abbrevCollMap.find(cu_abbr_offset);
-        m_prev_abbr_offset_pos = pos;
-    }
-
-    if (pos != m_abbrevCollMap.end())
-        return &(pos->second);
-    return NULL;
+const DWARFAbbreviationDeclarationSet *
+DWARFDebugAbbrev::GetAbbreviationDeclarationSet(
+    dw_offset_t cu_abbr_offset) const {
+  DWARFAbbreviationDeclarationCollMapConstIter end = m_abbrevCollMap.end();
+  DWARFAbbreviationDeclarationCollMapConstIter pos;
+  if (m_prev_abbr_offset_pos != end &&
+      m_prev_abbr_offset_pos->first == cu_abbr_offset)
+    return &(m_prev_abbr_offset_pos->second);
+  else {
+    pos = m_abbrevCollMap.find(cu_abbr_offset);
+    m_prev_abbr_offset_pos = pos;
+  }
+
+  if (pos != m_abbrevCollMap.end())
+    return &(pos->second);
+  return NULL;
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h Tue Sep  6 15:57:50 2016
@@ -15,60 +15,60 @@
 
 #include "lldb/lldb-private.h"
 
-#include "DWARFDefines.h"
 #include "DWARFAbbreviationDeclaration.h"
+#include "DWARFDefines.h"
 
-typedef std::vector<DWARFAbbreviationDeclaration>               DWARFAbbreviationDeclarationColl;
-typedef DWARFAbbreviationDeclarationColl::iterator              DWARFAbbreviationDeclarationCollIter;
-typedef DWARFAbbreviationDeclarationColl::const_iterator        DWARFAbbreviationDeclarationCollConstIter;
-
+typedef std::vector<DWARFAbbreviationDeclaration>
+    DWARFAbbreviationDeclarationColl;
+typedef DWARFAbbreviationDeclarationColl::iterator
+    DWARFAbbreviationDeclarationCollIter;
+typedef DWARFAbbreviationDeclarationColl::const_iterator
+    DWARFAbbreviationDeclarationCollConstIter;
 
-class DWARFAbbreviationDeclarationSet
-{
+class DWARFAbbreviationDeclarationSet {
 public:
-    DWARFAbbreviationDeclarationSet() :
-        m_offset(DW_INVALID_OFFSET),
-        m_idx_offset(0),
-        m_decls()
-        {
-        }
-
-    DWARFAbbreviationDeclarationSet(dw_offset_t offset, uint32_t idx_offset) :
-        m_offset(offset),
-        m_idx_offset(idx_offset),
-        m_decls()
-        {
-        }
-
-    void Clear();
-    dw_offset_t GetOffset() const { return m_offset; }
-    void Dump(lldb_private::Stream *s) const;
-    bool Extract(const lldb_private::DWARFDataExtractor& data, lldb::offset_t *offset_ptr);
-    //void Encode(BinaryStreamBuf& debug_abbrev_buf) const;
-    dw_uleb128_t AppendAbbrevDeclSequential(const DWARFAbbreviationDeclaration& abbrevDecl);
+  DWARFAbbreviationDeclarationSet()
+      : m_offset(DW_INVALID_OFFSET), m_idx_offset(0), m_decls() {}
+
+  DWARFAbbreviationDeclarationSet(dw_offset_t offset, uint32_t idx_offset)
+      : m_offset(offset), m_idx_offset(idx_offset), m_decls() {}
+
+  void Clear();
+  dw_offset_t GetOffset() const { return m_offset; }
+  void Dump(lldb_private::Stream *s) const;
+  bool Extract(const lldb_private::DWARFDataExtractor &data,
+               lldb::offset_t *offset_ptr);
+  // void Encode(BinaryStreamBuf& debug_abbrev_buf) const;
+  dw_uleb128_t
+  AppendAbbrevDeclSequential(const DWARFAbbreviationDeclaration &abbrevDecl);
+
+  const DWARFAbbreviationDeclaration *
+  GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const;
 
-    const DWARFAbbreviationDeclaration* GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const;
 private:
-    dw_offset_t m_offset;
-    uint32_t m_idx_offset;
-    std::vector<DWARFAbbreviationDeclaration> m_decls;
+  dw_offset_t m_offset;
+  uint32_t m_idx_offset;
+  std::vector<DWARFAbbreviationDeclaration> m_decls;
 };
 
-typedef std::map<dw_offset_t, DWARFAbbreviationDeclarationSet> DWARFAbbreviationDeclarationCollMap;
-typedef DWARFAbbreviationDeclarationCollMap::iterator DWARFAbbreviationDeclarationCollMapIter;
-typedef DWARFAbbreviationDeclarationCollMap::const_iterator DWARFAbbreviationDeclarationCollMapConstIter;
+typedef std::map<dw_offset_t, DWARFAbbreviationDeclarationSet>
+    DWARFAbbreviationDeclarationCollMap;
+typedef DWARFAbbreviationDeclarationCollMap::iterator
+    DWARFAbbreviationDeclarationCollMapIter;
+typedef DWARFAbbreviationDeclarationCollMap::const_iterator
+    DWARFAbbreviationDeclarationCollMapConstIter;
 
-
-class DWARFDebugAbbrev
-{
+class DWARFDebugAbbrev {
 public:
-    DWARFDebugAbbrev();
-    const DWARFAbbreviationDeclarationSet*  GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const;
-    void Dump(lldb_private::Stream *s) const;
-    void Parse(const lldb_private::DWARFDataExtractor& data);
+  DWARFDebugAbbrev();
+  const DWARFAbbreviationDeclarationSet *
+  GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const;
+  void Dump(lldb_private::Stream *s) const;
+  void Parse(const lldb_private::DWARFDataExtractor &data);
+
 protected:
-    DWARFAbbreviationDeclarationCollMap m_abbrevCollMap;
-    mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos;
+  DWARFAbbreviationDeclarationCollMap m_abbrevCollMap;
+  mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos;
 };
 
-#endif  // SymbolFileDWARF_DWARFDebugAbbrev_h_
+#endif // SymbolFileDWARF_DWARFDebugAbbrev_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp Tue Sep  6 15:57:50 2016
@@ -9,302 +9,262 @@
 
 #include "DWARFDebugArangeSet.h"
 
-#include <assert.h>
-#include "lldb/Core/Stream.h"
 #include "SymbolFileDWARF.h"
+#include "lldb/Core/Stream.h"
+#include <assert.h>
 
 using namespace lldb_private;
 
-DWARFDebugArangeSet::DWARFDebugArangeSet() :
-    m_offset(DW_INVALID_OFFSET),
-    m_header(),
-    m_arange_descriptors()
-{
-    m_header.length     = 0;
-    m_header.version    = 0;
-    m_header.cu_offset  = 0;
-    m_header.addr_size  = 0;
-    m_header.seg_size   = 0;
+DWARFDebugArangeSet::DWARFDebugArangeSet()
+    : m_offset(DW_INVALID_OFFSET), m_header(), m_arange_descriptors() {
+  m_header.length = 0;
+  m_header.version = 0;
+  m_header.cu_offset = 0;
+  m_header.addr_size = 0;
+  m_header.seg_size = 0;
 }
 
-void
-DWARFDebugArangeSet::Clear()
-{
-    m_offset = DW_INVALID_OFFSET;
-    m_header.length     = 0;
-    m_header.version    = 0;
-    m_header.cu_offset  = 0;
-    m_header.addr_size  = 0;
-    m_header.seg_size   = 0;
-    m_arange_descriptors.clear();
+void DWARFDebugArangeSet::Clear() {
+  m_offset = DW_INVALID_OFFSET;
+  m_header.length = 0;
+  m_header.version = 0;
+  m_header.cu_offset = 0;
+  m_header.addr_size = 0;
+  m_header.seg_size = 0;
+  m_arange_descriptors.clear();
 }
 
-void
-DWARFDebugArangeSet::SetHeader
-(
-    uint16_t version,
-    uint32_t cu_offset,
-    uint8_t addr_size,
-    uint8_t seg_size
-)
-{
-    m_header.version    = version;
-    m_header.cu_offset  = cu_offset;
-    m_header.addr_size  = addr_size;
-    m_header.seg_size   = seg_size;
+void DWARFDebugArangeSet::SetHeader(uint16_t version, uint32_t cu_offset,
+                                    uint8_t addr_size, uint8_t seg_size) {
+  m_header.version = version;
+  m_header.cu_offset = cu_offset;
+  m_header.addr_size = addr_size;
+  m_header.seg_size = seg_size;
 }
 
-void
-DWARFDebugArangeSet::Compact()
-{
-    if (m_arange_descriptors.empty())
-        return;
-
-    // Iterate through all arange descriptors and combine any ranges that
-    // overlap or have matching boundaries. The m_arange_descriptors are assumed
-    // to be in ascending order after being built by adding descriptors
-    // using the AddDescriptor method.
-    uint32_t i = 0;
-    while (i + 1 < m_arange_descriptors.size())
-    {
-        if (m_arange_descriptors[i].end_address() >= m_arange_descriptors[i+1].address)
-        {
-            // The current range ends at or exceeds the start of the next address range.
-            // Compute the max end address between the two and use that to make the new
-            // length.
-            const dw_addr_t max_end_addr = std::max(m_arange_descriptors[i].end_address(), m_arange_descriptors[i+1].end_address());
-            m_arange_descriptors[i].length = max_end_addr - m_arange_descriptors[i].address;
-            // Now remove the next entry as it was just combined with the previous one.
-            m_arange_descriptors.erase(m_arange_descriptors.begin()+i+1);
-        }
-        else
-        {
-            // Discontiguous address range, just proceed to the next one.
-            ++i;
-        }
+void DWARFDebugArangeSet::Compact() {
+  if (m_arange_descriptors.empty())
+    return;
+
+  // Iterate through all arange descriptors and combine any ranges that
+  // overlap or have matching boundaries. The m_arange_descriptors are assumed
+  // to be in ascending order after being built by adding descriptors
+  // using the AddDescriptor method.
+  uint32_t i = 0;
+  while (i + 1 < m_arange_descriptors.size()) {
+    if (m_arange_descriptors[i].end_address() >=
+        m_arange_descriptors[i + 1].address) {
+      // The current range ends at or exceeds the start of the next address
+      // range.
+      // Compute the max end address between the two and use that to make the
+      // new
+      // length.
+      const dw_addr_t max_end_addr =
+          std::max(m_arange_descriptors[i].end_address(),
+                   m_arange_descriptors[i + 1].end_address());
+      m_arange_descriptors[i].length =
+          max_end_addr - m_arange_descriptors[i].address;
+      // Now remove the next entry as it was just combined with the previous
+      // one.
+      m_arange_descriptors.erase(m_arange_descriptors.begin() + i + 1);
+    } else {
+      // Discontiguous address range, just proceed to the next one.
+      ++i;
     }
+  }
 }
 //----------------------------------------------------------------------
 // Compare function DWARFDebugArangeSet::Descriptor structures
 //----------------------------------------------------------------------
-static bool DescriptorLessThan (const DWARFDebugArangeSet::Descriptor& range1, const DWARFDebugArangeSet::Descriptor& range2)
-{
-    return range1.address < range2.address;
+static bool DescriptorLessThan(const DWARFDebugArangeSet::Descriptor &range1,
+                               const DWARFDebugArangeSet::Descriptor &range2) {
+  return range1.address < range2.address;
 }
 
 //----------------------------------------------------------------------
 // Add a range descriptor and keep things sorted so we can easily
 // compact the ranges before being saved or used.
 //----------------------------------------------------------------------
-void
-DWARFDebugArangeSet::AddDescriptor(const DWARFDebugArangeSet::Descriptor& range)
-{
-    if (m_arange_descriptors.empty())
-    {
-        m_arange_descriptors.push_back(range);
-        return;
+void DWARFDebugArangeSet::AddDescriptor(
+    const DWARFDebugArangeSet::Descriptor &range) {
+  if (m_arange_descriptors.empty()) {
+    m_arange_descriptors.push_back(range);
+    return;
+  }
+
+  DescriptorIter end = m_arange_descriptors.end();
+  DescriptorIter pos =
+      lower_bound(m_arange_descriptors.begin(), end, range, DescriptorLessThan);
+  const dw_addr_t range_end_addr = range.end_address();
+  if (pos != end) {
+    const dw_addr_t found_end_addr = pos->end_address();
+    if (range.address < pos->address) {
+      if (range_end_addr < pos->address) {
+        // Non-contiguous entries, add this one before the found entry
+        m_arange_descriptors.insert(pos, range);
+      } else if (range_end_addr == pos->address) {
+        // The top end of 'range' is the lower end of the entry
+        // pointed to by 'pos'. We can combine range with the
+        // entry we found by setting the starting address and
+        // increasing the length since they don't overlap.
+        pos->address = range.address;
+        pos->length += range.length;
+      } else {
+        // We can combine these two and make sure the largest end
+        // address is used to make end address.
+        pos->address = range.address;
+        pos->length = std::max(found_end_addr, range_end_addr) - pos->address;
+      }
+    } else if (range.address == pos->address) {
+      pos->length = std::max(pos->length, range.length);
     }
-
-    DescriptorIter end = m_arange_descriptors.end();
-    DescriptorIter pos = lower_bound(m_arange_descriptors.begin(), end, range, DescriptorLessThan);
-    const dw_addr_t range_end_addr = range.end_address();
-    if (pos != end)
-    {
-        const dw_addr_t found_end_addr = pos->end_address();
-        if (range.address < pos->address)
-        {
-            if (range_end_addr < pos->address)
-            {
-                // Non-contiguous entries, add this one before the found entry
-                m_arange_descriptors.insert(pos, range);
-            }
-            else if (range_end_addr == pos->address)
-            {
-                // The top end of 'range' is the lower end of the entry
-                // pointed to by 'pos'. We can combine range with the
-                // entry we found by setting the starting address and
-                // increasing the length since they don't overlap.
-                pos->address = range.address;
-                pos->length += range.length;
-            }
-            else
-            {
-                // We can combine these two and make sure the largest end
-                // address is used to make end address.
-                pos->address = range.address;
-                pos->length = std::max(found_end_addr, range_end_addr) - pos->address;
-            }
-        }
-        else if (range.address == pos->address)
-        {
-            pos->length = std::max(pos->length, range.length);
-        }
-    }
-    else
-    {
-        // NOTE: 'pos' points to entry past the end which is ok for insert,
-        // don't use otherwise!!!
-        const dw_addr_t max_addr = m_arange_descriptors.back().end_address();
-        if (max_addr < range.address)
-        {
-            // Non-contiguous entries, add this one before the found entry
-            m_arange_descriptors.insert(pos, range);
-        }
-        else if (max_addr == range.address)
-        {
-            m_arange_descriptors.back().length += range.length;
-        }
-        else
-        {
-            m_arange_descriptors.back().length = std::max(max_addr, range_end_addr) - m_arange_descriptors.back().address;
-        }
+  } else {
+    // NOTE: 'pos' points to entry past the end which is ok for insert,
+    // don't use otherwise!!!
+    const dw_addr_t max_addr = m_arange_descriptors.back().end_address();
+    if (max_addr < range.address) {
+      // Non-contiguous entries, add this one before the found entry
+      m_arange_descriptors.insert(pos, range);
+    } else if (max_addr == range.address) {
+      m_arange_descriptors.back().length += range.length;
+    } else {
+      m_arange_descriptors.back().length = std::max(max_addr, range_end_addr) -
+                                           m_arange_descriptors.back().address;
     }
+  }
 }
 
-bool
-DWARFDebugArangeSet::Extract(const DWARFDataExtractor &data, lldb::offset_t *offset_ptr)
-{
-    if (data.ValidOffset(*offset_ptr))
-    {
-        m_arange_descriptors.clear();
-        m_offset = *offset_ptr;
-
-        // 7.20 Address Range Table
-        //
-        // Each set of entries in the table of address ranges contained in
-        // the .debug_aranges section begins with a header consisting of: a
-        // 4-byte length containing the length of the set of entries for this
-        // compilation unit, not including the length field itself; a 2-byte
-        // version identifier containing the value 2 for DWARF Version 2; a
-        // 4-byte offset into the.debug_infosection; a 1-byte unsigned integer
-        // containing the size in bytes of an address (or the offset portion of
-        // an address for segmented addressing) on the target system; and a
-        // 1-byte unsigned integer containing the size in bytes of a segment
-        // descriptor on the target system. This header is followed by a series
-        // of tuples. Each tuple consists of an address and a length, each in
-        // the size appropriate for an address on the target architecture.
-        m_header.length     = data.GetDWARFInitialLength(offset_ptr);
-        m_header.version    = data.GetU16(offset_ptr);
-        m_header.cu_offset  = data.GetDWARFOffset(offset_ptr);
-        m_header.addr_size  = data.GetU8(offset_ptr);
-        m_header.seg_size   = data.GetU8(offset_ptr);
-        
-        // Try to avoid reading invalid arange sets by making sure:
-        // 1 - the version looks good
-        // 2 - the address byte size looks plausible
-        // 3 - the length seems to make sense
-        // size looks plausible
-        if ((m_header.version >= 2 && m_header.version <= 5) &&
-            (m_header.addr_size == 4 || m_header.addr_size == 8) &&
-            (m_header.length > 0))
-        {
-            if (data.ValidOffset(m_offset + sizeof(m_header.length) + m_header.length - 1))
-            {
-                // The first tuple following the header in each set begins at an offset
-                // that is a multiple of the size of a single tuple (that is, twice the
-                // size of an address). The header is padded, if necessary, to the
-                // appropriate boundary.
-                const uint32_t header_size = *offset_ptr - m_offset;
-                const uint32_t tuple_size = m_header.addr_size << 1;
-                uint32_t first_tuple_offset = 0;
-                while (first_tuple_offset < header_size)
-                    first_tuple_offset += tuple_size;
-                
-                *offset_ptr = m_offset + first_tuple_offset;
-                
-                Descriptor arangeDescriptor;
-                
-                static_assert(sizeof(arangeDescriptor.address) == sizeof(arangeDescriptor.length),
-                              "DWARFDebugArangeSet::Descriptor.address and DWARFDebugArangeSet::Descriptor.length must have same size");
-                
-                while (data.ValidOffset(*offset_ptr))
-                {
-                    arangeDescriptor.address    = data.GetMaxU64(offset_ptr, m_header.addr_size);
-                    arangeDescriptor.length     = data.GetMaxU64(offset_ptr, m_header.addr_size);
-                    
-                    // Each set of tuples is terminated by a 0 for the address and 0
-                    // for the length.
-                    if (arangeDescriptor.address || arangeDescriptor.length)
-                        m_arange_descriptors.push_back(arangeDescriptor);
-                    else
-                        break;  // We are done if we get a zero address and length
-                }
-            }
-#if defined (LLDB_CONFIGURATION_DEBUG)
-            else
-            {
-                printf ("warning: .debug_arange set length is too large arange data at 0x%8.8x: length=0x%8.8x, version=0x%4.4x, cu_offset=0x%8.8x, addr_size=%u, seg_size=%u\n",
-                        m_offset,
-                        m_header.length,
-                        m_header.version,
-                        m_header.cu_offset,
-                        m_header.addr_size,
-                        m_header.seg_size);
-            }
-#endif
-        }
-#if defined (LLDB_CONFIGURATION_DEBUG)
-        else
-        {
-            printf ("warning: .debug_arange set has bad header at 0x%8.8x: length=0x%8.8x, version=0x%4.4x, cu_offset=0x%8.8x, addr_size=%u, seg_size=%u\n",
-                    m_offset,
-                    m_header.length,
-                    m_header.version,
-                    m_header.cu_offset,
-                    m_header.addr_size,
-                    m_header.seg_size);
+bool DWARFDebugArangeSet::Extract(const DWARFDataExtractor &data,
+                                  lldb::offset_t *offset_ptr) {
+  if (data.ValidOffset(*offset_ptr)) {
+    m_arange_descriptors.clear();
+    m_offset = *offset_ptr;
+
+    // 7.20 Address Range Table
+    //
+    // Each set of entries in the table of address ranges contained in
+    // the .debug_aranges section begins with a header consisting of: a
+    // 4-byte length containing the length of the set of entries for this
+    // compilation unit, not including the length field itself; a 2-byte
+    // version identifier containing the value 2 for DWARF Version 2; a
+    // 4-byte offset into the.debug_infosection; a 1-byte unsigned integer
+    // containing the size in bytes of an address (or the offset portion of
+    // an address for segmented addressing) on the target system; and a
+    // 1-byte unsigned integer containing the size in bytes of a segment
+    // descriptor on the target system. This header is followed by a series
+    // of tuples. Each tuple consists of an address and a length, each in
+    // the size appropriate for an address on the target architecture.
+    m_header.length = data.GetDWARFInitialLength(offset_ptr);
+    m_header.version = data.GetU16(offset_ptr);
+    m_header.cu_offset = data.GetDWARFOffset(offset_ptr);
+    m_header.addr_size = data.GetU8(offset_ptr);
+    m_header.seg_size = data.GetU8(offset_ptr);
+
+    // Try to avoid reading invalid arange sets by making sure:
+    // 1 - the version looks good
+    // 2 - the address byte size looks plausible
+    // 3 - the length seems to make sense
+    // size looks plausible
+    if ((m_header.version >= 2 && m_header.version <= 5) &&
+        (m_header.addr_size == 4 || m_header.addr_size == 8) &&
+        (m_header.length > 0)) {
+      if (data.ValidOffset(m_offset + sizeof(m_header.length) +
+                           m_header.length - 1)) {
+        // The first tuple following the header in each set begins at an offset
+        // that is a multiple of the size of a single tuple (that is, twice the
+        // size of an address). The header is padded, if necessary, to the
+        // appropriate boundary.
+        const uint32_t header_size = *offset_ptr - m_offset;
+        const uint32_t tuple_size = m_header.addr_size << 1;
+        uint32_t first_tuple_offset = 0;
+        while (first_tuple_offset < header_size)
+          first_tuple_offset += tuple_size;
+
+        *offset_ptr = m_offset + first_tuple_offset;
+
+        Descriptor arangeDescriptor;
+
+        static_assert(
+            sizeof(arangeDescriptor.address) == sizeof(arangeDescriptor.length),
+            "DWARFDebugArangeSet::Descriptor.address and "
+            "DWARFDebugArangeSet::Descriptor.length must have same size");
+
+        while (data.ValidOffset(*offset_ptr)) {
+          arangeDescriptor.address =
+              data.GetMaxU64(offset_ptr, m_header.addr_size);
+          arangeDescriptor.length =
+              data.GetMaxU64(offset_ptr, m_header.addr_size);
+
+          // Each set of tuples is terminated by a 0 for the address and 0
+          // for the length.
+          if (arangeDescriptor.address || arangeDescriptor.length)
+            m_arange_descriptors.push_back(arangeDescriptor);
+          else
+            break; // We are done if we get a zero address and length
         }
+      }
+#if defined(LLDB_CONFIGURATION_DEBUG)
+      else {
+        printf("warning: .debug_arange set length is too large arange data at "
+               "0x%8.8x: length=0x%8.8x, version=0x%4.4x, cu_offset=0x%8.8x, "
+               "addr_size=%u, seg_size=%u\n",
+               m_offset, m_header.length, m_header.version, m_header.cu_offset,
+               m_header.addr_size, m_header.seg_size);
+      }
 #endif
-        
-        return !m_arange_descriptors.empty();
     }
-    return false;
-}
-
+#if defined(LLDB_CONFIGURATION_DEBUG)
+    else {
+      printf("warning: .debug_arange set has bad header at 0x%8.8x: "
+             "length=0x%8.8x, version=0x%4.4x, cu_offset=0x%8.8x, "
+             "addr_size=%u, seg_size=%u\n",
+             m_offset, m_header.length, m_header.version, m_header.cu_offset,
+             m_header.addr_size, m_header.seg_size);
+    }
+#endif
 
-dw_offset_t
-DWARFDebugArangeSet::GetOffsetOfNextEntry() const
-{
-    return m_offset + m_header.length + 4;
+    return !m_arange_descriptors.empty();
+  }
+  return false;
 }
 
-
-void
-DWARFDebugArangeSet::Dump(Stream *s) const
-{
-    s->Printf("Address Range Header: length = 0x%8.8x, version = 0x%4.4x, cu_offset = 0x%8.8x, addr_size = 0x%2.2x, seg_size = 0x%2.2x\n",
-        m_header.length ,m_header.version, m_header.cu_offset, m_header.addr_size, m_header.seg_size);
-
-    const uint32_t hex_width = m_header.addr_size * 2;
-    DescriptorConstIter pos;
-    DescriptorConstIter end = m_arange_descriptors.end();
-    for (pos = m_arange_descriptors.begin(); pos != end; ++pos)
-        s->Printf("[0x%*.*" PRIx64 " - 0x%*.*" PRIx64 ")\n",
-            hex_width, hex_width, pos->address,
-            hex_width, hex_width, pos->end_address());
+dw_offset_t DWARFDebugArangeSet::GetOffsetOfNextEntry() const {
+  return m_offset + m_header.length + 4;
 }
 
+void DWARFDebugArangeSet::Dump(Stream *s) const {
+  s->Printf("Address Range Header: length = 0x%8.8x, version = 0x%4.4x, "
+            "cu_offset = 0x%8.8x, addr_size = 0x%2.2x, seg_size = 0x%2.2x\n",
+            m_header.length, m_header.version, m_header.cu_offset,
+            m_header.addr_size, m_header.seg_size);
+
+  const uint32_t hex_width = m_header.addr_size * 2;
+  DescriptorConstIter pos;
+  DescriptorConstIter end = m_arange_descriptors.end();
+  for (pos = m_arange_descriptors.begin(); pos != end; ++pos)
+    s->Printf("[0x%*.*" PRIx64 " - 0x%*.*" PRIx64 ")\n", hex_width, hex_width,
+              pos->address, hex_width, hex_width, pos->end_address());
+}
 
-class DescriptorContainsAddress
-{
+class DescriptorContainsAddress {
 public:
-    DescriptorContainsAddress (dw_addr_t address) : m_address(address) {}
-    bool operator() (const DWARFDebugArangeSet::Descriptor& desc) const
-    {
-        return (m_address >= desc.address) && (m_address < (desc.address + desc.length));
-    }
- private:
-   const dw_addr_t m_address;
+  DescriptorContainsAddress(dw_addr_t address) : m_address(address) {}
+  bool operator()(const DWARFDebugArangeSet::Descriptor &desc) const {
+    return (m_address >= desc.address) &&
+           (m_address < (desc.address + desc.length));
+  }
+
+private:
+  const dw_addr_t m_address;
 };
 
-dw_offset_t
-DWARFDebugArangeSet::FindAddress(dw_addr_t address) const
-{
-    DescriptorConstIter end = m_arange_descriptors.end();
-    DescriptorConstIter pos = std::find_if( m_arange_descriptors.begin(), end,  // Range
-                                            DescriptorContainsAddress(address));// Predicate
-    if (pos != end)
-        return m_header.cu_offset;
+dw_offset_t DWARFDebugArangeSet::FindAddress(dw_addr_t address) const {
+  DescriptorConstIter end = m_arange_descriptors.end();
+  DescriptorConstIter pos =
+      std::find_if(m_arange_descriptors.begin(), end,   // Range
+                   DescriptorContainsAddress(address)); // Predicate
+  if (pos != end)
+    return m_header.cu_offset;
 
-    return DW_INVALID_OFFSET;
+  return DW_INVALID_OFFSET;
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h Tue Sep  6 15:57:50 2016
@@ -15,62 +15,62 @@
 
 class SymbolFileDWARF;
 
-class DWARFDebugArangeSet
-{
+class DWARFDebugArangeSet {
 public:
-    struct Header
-    {
-        uint32_t    length;     // The total length of the entries for that set, not including the length field itself.
-        uint16_t    version;    // The DWARF version number
-        uint32_t    cu_offset;  // The offset from the beginning of the .debug_info section of the compilation unit entry referenced by the table.
-        uint8_t     addr_size;  // The size in bytes of an address on the target architecture. For segmented addressing, this is the size of the offset portion of the address
-        uint8_t     seg_size;   // The size in bytes of a segment descriptor on the target architecture. If the target system uses a flat address space, this value is 0.
-    };
-
-    struct Descriptor
-    {
-        dw_addr_t   address;
-        dw_addr_t   length;
-        dw_addr_t end_address() const { return address + length; }
-    };
-
-
-                    DWARFDebugArangeSet();
-        void        Clear();
-        void        SetOffset(uint32_t offset) { m_offset = offset; }
-        void        SetHeader(uint16_t version, uint32_t cu_offset, uint8_t addr_size, uint8_t seg_size);
-        void        AddDescriptor(const DWARFDebugArangeSet::Descriptor& range);
-        void        Compact();
-        bool        Extract(const lldb_private::DWARFDataExtractor &data, lldb::offset_t *offset_ptr);
-        void        Dump(lldb_private::Stream *s) const;
-        dw_offset_t GetCompileUnitDIEOffset() const { return m_header.cu_offset; }
-        dw_offset_t GetOffsetOfNextEntry() const;
-        dw_offset_t FindAddress(dw_addr_t address) const;
-        size_t      NumDescriptors() const { return m_arange_descriptors.size(); }
-        const Header&       GetHeader() const { return m_header; }
-        const Descriptor*   GetDescriptor(uint32_t i) const
-        {
-            if (i < m_arange_descriptors.size())
-                return &m_arange_descriptors[i];
-            return NULL;
-        }
-
-        const Descriptor &  
-        GetDescriptorRef (uint32_t i) const
-        {
-            return m_arange_descriptors[i];
-        }
-
+  struct Header {
+    uint32_t length;    // The total length of the entries for that set, not
+                        // including the length field itself.
+    uint16_t version;   // The DWARF version number
+    uint32_t cu_offset; // The offset from the beginning of the .debug_info
+                        // section of the compilation unit entry referenced by
+                        // the table.
+    uint8_t addr_size;  // The size in bytes of an address on the target
+                        // architecture. For segmented addressing, this is the
+                        // size of the offset portion of the address
+    uint8_t seg_size; // The size in bytes of a segment descriptor on the target
+                      // architecture. If the target system uses a flat address
+                      // space, this value is 0.
+  };
+
+  struct Descriptor {
+    dw_addr_t address;
+    dw_addr_t length;
+    dw_addr_t end_address() const { return address + length; }
+  };
+
+  DWARFDebugArangeSet();
+  void Clear();
+  void SetOffset(uint32_t offset) { m_offset = offset; }
+  void SetHeader(uint16_t version, uint32_t cu_offset, uint8_t addr_size,
+                 uint8_t seg_size);
+  void AddDescriptor(const DWARFDebugArangeSet::Descriptor &range);
+  void Compact();
+  bool Extract(const lldb_private::DWARFDataExtractor &data,
+               lldb::offset_t *offset_ptr);
+  void Dump(lldb_private::Stream *s) const;
+  dw_offset_t GetCompileUnitDIEOffset() const { return m_header.cu_offset; }
+  dw_offset_t GetOffsetOfNextEntry() const;
+  dw_offset_t FindAddress(dw_addr_t address) const;
+  size_t NumDescriptors() const { return m_arange_descriptors.size(); }
+  const Header &GetHeader() const { return m_header; }
+  const Descriptor *GetDescriptor(uint32_t i) const {
+    if (i < m_arange_descriptors.size())
+      return &m_arange_descriptors[i];
+    return NULL;
+  }
+
+  const Descriptor &GetDescriptorRef(uint32_t i) const {
+    return m_arange_descriptors[i];
+  }
 
 protected:
-    typedef std::vector<Descriptor>         DescriptorColl;
-    typedef DescriptorColl::iterator        DescriptorIter;
-    typedef DescriptorColl::const_iterator  DescriptorConstIter;
-
-
-    uint32_t        m_offset;
-    Header          m_header;
-    DescriptorColl  m_arange_descriptors;
+  typedef std::vector<Descriptor> DescriptorColl;
+  typedef DescriptorColl::iterator DescriptorIter;
+  typedef DescriptorColl::const_iterator DescriptorConstIter;
+
+  uint32_t m_offset;
+  Header m_header;
+  DescriptorColl m_arange_descriptors;
 };
 
-#endif  // SymbolFileDWARF_DWARFDebugArangeSet_h_
+#endif // SymbolFileDWARF_DWARFDebugArangeSet_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Tue Sep  6 15:57:50 2016
@@ -18,10 +18,10 @@
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/Timer.h"
 
+#include "DWARFCompileUnit.h"
+#include "DWARFDebugInfo.h"
 #include "LogChannelDWARF.h"
 #include "SymbolFileDWARF.h"
-#include "DWARFDebugInfo.h"
-#include "DWARFCompileUnit.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -29,148 +29,122 @@ using namespace lldb_private;
 //----------------------------------------------------------------------
 // Constructor
 //----------------------------------------------------------------------
-DWARFDebugAranges::DWARFDebugAranges() :
-    m_aranges()
-{
-}
+DWARFDebugAranges::DWARFDebugAranges() : m_aranges() {}
 
 //----------------------------------------------------------------------
 // CountArangeDescriptors
 //----------------------------------------------------------------------
-class CountArangeDescriptors
-{
+class CountArangeDescriptors {
 public:
-    CountArangeDescriptors (uint32_t& count_ref) : count(count_ref)
-    {
-//      printf("constructor CountArangeDescriptors()\n");
-    }
-    void operator() (const DWARFDebugArangeSet& set)
-    {
-        count += set.NumDescriptors();
-    }
-    uint32_t& count;
+  CountArangeDescriptors(uint32_t &count_ref) : count(count_ref) {
+    //      printf("constructor CountArangeDescriptors()\n");
+  }
+  void operator()(const DWARFDebugArangeSet &set) {
+    count += set.NumDescriptors();
+  }
+  uint32_t &count;
 };
 
-
 //----------------------------------------------------------------------
 // Extract
 //----------------------------------------------------------------------
-bool
-DWARFDebugAranges::Extract(const DWARFDataExtractor &debug_aranges_data)
-{
-    if (debug_aranges_data.ValidOffset(0))
-    {
-        lldb::offset_t offset = 0;
-
-        DWARFDebugArangeSet set;
-        Range range;
-        while (set.Extract(debug_aranges_data, &offset))
-        {
-            const uint32_t num_descriptors = set.NumDescriptors();
-            if (num_descriptors > 0)
-            {
-                const dw_offset_t cu_offset = set.GetCompileUnitDIEOffset();
-                
-                for (uint32_t i=0; i<num_descriptors; ++i)
-                {
-                    const DWARFDebugArangeSet::Descriptor &descriptor = set.GetDescriptorRef(i);
-                    m_aranges.Append(RangeToDIE::Entry (descriptor.address, descriptor.length, cu_offset));
-                }
-            }
-            set.Clear();
+bool DWARFDebugAranges::Extract(const DWARFDataExtractor &debug_aranges_data) {
+  if (debug_aranges_data.ValidOffset(0)) {
+    lldb::offset_t offset = 0;
+
+    DWARFDebugArangeSet set;
+    Range range;
+    while (set.Extract(debug_aranges_data, &offset)) {
+      const uint32_t num_descriptors = set.NumDescriptors();
+      if (num_descriptors > 0) {
+        const dw_offset_t cu_offset = set.GetCompileUnitDIEOffset();
+
+        for (uint32_t i = 0; i < num_descriptors; ++i) {
+          const DWARFDebugArangeSet::Descriptor &descriptor =
+              set.GetDescriptorRef(i);
+          m_aranges.Append(RangeToDIE::Entry(descriptor.address,
+                                             descriptor.length, cu_offset));
         }
+      }
+      set.Clear();
     }
-    return false;
+  }
+  return false;
 }
 
 //----------------------------------------------------------------------
 // Generate
 //----------------------------------------------------------------------
-bool
-DWARFDebugAranges::Generate(SymbolFileDWARF* dwarf2Data)
-{
-    Clear();
-    DWARFDebugInfo* debug_info = dwarf2Data->DebugInfo();
-    if (debug_info)
-    {
-        uint32_t cu_idx = 0;
-        const uint32_t num_compile_units = dwarf2Data->GetNumCompileUnits();
-        for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx)
-        {
-            DWARFCompileUnit* cu = debug_info->GetCompileUnitAtIndex(cu_idx);
-            if (cu)
-                cu->BuildAddressRangeTable(dwarf2Data, this);
-        }
-    }
-    return !IsEmpty();
-}
-
-
-void
-DWARFDebugAranges::Dump (Log *log) const
-{
-    if (log == NULL)
-        return;
-    
-    const size_t num_entries = m_aranges.GetSize();
-    for (size_t i=0; i<num_entries; ++i)
-    {
-        const RangeToDIE::Entry *entry = m_aranges.GetEntryAtIndex(i);
-        if (entry)
-            log->Printf ("0x%8.8x: [0x%" PRIx64 " - 0x%" PRIx64 ")",
-                         entry->data,
-                         entry->GetRangeBase(),
-                         entry->GetRangeEnd());
-    }
-}
-
-void
-DWARFDebugAranges::AppendRange (dw_offset_t offset, dw_addr_t low_pc, dw_addr_t high_pc)
-{
-    if (high_pc > low_pc)
-        m_aranges.Append(RangeToDIE::Entry (low_pc, high_pc - low_pc, offset));
-}
-
-void
-DWARFDebugAranges::Sort (bool minimize)
-{    
-    Timer scoped_timer(LLVM_PRETTY_FUNCTION, "%s this = %p",
-                       LLVM_PRETTY_FUNCTION, static_cast<void*>(this));
-
-    Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
-    size_t orig_arange_size = 0;
-    if (log)
-    {
-        orig_arange_size = m_aranges.GetSize();
-        log->Printf ("DWARFDebugAranges::Sort(minimize = %u) with %" PRIu64 " entries", minimize, (uint64_t)orig_arange_size);
-    }
-
-    m_aranges.Sort();
-    m_aranges.CombineConsecutiveEntriesWithEqualData();
-
-    if (log)
-    {
-        if (minimize)
-        {
-            const size_t new_arange_size = m_aranges.GetSize();
-            const size_t delta = orig_arange_size - new_arange_size;
-            log->Printf ("DWARFDebugAranges::Sort() %" PRIu64 " entries after minimizing (%" PRIu64 " entries combined for %" PRIu64 " bytes saved)",
-                         (uint64_t)new_arange_size,
-                         (uint64_t)delta,
-                         (uint64_t)delta * sizeof(Range));
-        }
-        Dump (log);
+bool DWARFDebugAranges::Generate(SymbolFileDWARF *dwarf2Data) {
+  Clear();
+  DWARFDebugInfo *debug_info = dwarf2Data->DebugInfo();
+  if (debug_info) {
+    uint32_t cu_idx = 0;
+    const uint32_t num_compile_units = dwarf2Data->GetNumCompileUnits();
+    for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
+      DWARFCompileUnit *cu = debug_info->GetCompileUnitAtIndex(cu_idx);
+      if (cu)
+        cu->BuildAddressRangeTable(dwarf2Data, this);
+    }
+  }
+  return !IsEmpty();
+}
+
+void DWARFDebugAranges::Dump(Log *log) const {
+  if (log == NULL)
+    return;
+
+  const size_t num_entries = m_aranges.GetSize();
+  for (size_t i = 0; i < num_entries; ++i) {
+    const RangeToDIE::Entry *entry = m_aranges.GetEntryAtIndex(i);
+    if (entry)
+      log->Printf("0x%8.8x: [0x%" PRIx64 " - 0x%" PRIx64 ")", entry->data,
+                  entry->GetRangeBase(), entry->GetRangeEnd());
+  }
+}
+
+void DWARFDebugAranges::AppendRange(dw_offset_t offset, dw_addr_t low_pc,
+                                    dw_addr_t high_pc) {
+  if (high_pc > low_pc)
+    m_aranges.Append(RangeToDIE::Entry(low_pc, high_pc - low_pc, offset));
+}
+
+void DWARFDebugAranges::Sort(bool minimize) {
+  Timer scoped_timer(LLVM_PRETTY_FUNCTION, "%s this = %p", LLVM_PRETTY_FUNCTION,
+                     static_cast<void *>(this));
+
+  Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
+  size_t orig_arange_size = 0;
+  if (log) {
+    orig_arange_size = m_aranges.GetSize();
+    log->Printf("DWARFDebugAranges::Sort(minimize = %u) with %" PRIu64
+                " entries",
+                minimize, (uint64_t)orig_arange_size);
+  }
+
+  m_aranges.Sort();
+  m_aranges.CombineConsecutiveEntriesWithEqualData();
+
+  if (log) {
+    if (minimize) {
+      const size_t new_arange_size = m_aranges.GetSize();
+      const size_t delta = orig_arange_size - new_arange_size;
+      log->Printf("DWARFDebugAranges::Sort() %" PRIu64
+                  " entries after minimizing (%" PRIu64
+                  " entries combined for %" PRIu64 " bytes saved)",
+                  (uint64_t)new_arange_size, (uint64_t)delta,
+                  (uint64_t)delta * sizeof(Range));
     }
+    Dump(log);
+  }
 }
 
 //----------------------------------------------------------------------
 // FindAddress
 //----------------------------------------------------------------------
-dw_offset_t
-DWARFDebugAranges::FindAddress(dw_addr_t address) const
-{
-    const RangeToDIE::Entry *entry = m_aranges.FindEntryThatContains(address);
-    if (entry)
-        return entry->data;
-    return DW_INVALID_OFFSET;
+dw_offset_t DWARFDebugAranges::FindAddress(dw_addr_t address) const {
+  const RangeToDIE::Entry *entry = m_aranges.FindEntryThatContains(address);
+  if (entry)
+    return entry->data;
+  return DW_INVALID_OFFSET;
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Tue Sep  6 15:57:50 2016
@@ -17,78 +17,50 @@
 
 class SymbolFileDWARF;
 
-class DWARFDebugAranges
-{
+class DWARFDebugAranges {
 protected:
-    typedef lldb_private::RangeDataArray<dw_addr_t, uint32_t, dw_offset_t, 1> RangeToDIE;
+  typedef lldb_private::RangeDataArray<dw_addr_t, uint32_t, dw_offset_t, 1>
+      RangeToDIE;
 
 public:
-    typedef RangeToDIE::Entry Range;
-    typedef std::vector<RangeToDIE::Entry> RangeColl;
+  typedef RangeToDIE::Entry Range;
+  typedef std::vector<RangeToDIE::Entry> RangeColl;
 
-    DWARFDebugAranges();
+  DWARFDebugAranges();
 
-    void
-    Clear() 
-    {
-        m_aranges.Clear(); 
-    }
-
-    bool
-    Extract(const lldb_private::DWARFDataExtractor &debug_aranges_data);
-
-    bool
-    Generate(SymbolFileDWARF* dwarf2Data);
-    
-                // Use append range multiple times and then call sort
-    void
-    AppendRange (dw_offset_t cu_offset, 
-                 dw_addr_t low_pc, 
-                 dw_addr_t high_pc);
-
-    void 
-    Sort (bool minimize);
-
-    const Range* 
-    RangeAtIndex(uint32_t idx) const
-    {
-        return m_aranges.GetEntryAtIndex (idx);
-    }
-    
-    void
-    Dump (lldb_private::Log *log) const;
-    
-    dw_offset_t
-    FindAddress(dw_addr_t address) const;
-
-    bool
-    IsEmpty() const 
-    {
-        return m_aranges.IsEmpty(); 
-    }
-    size_t
-    GetNumRanges() const
-    {
-        return m_aranges.GetSize();
-    }
-
-    dw_offset_t 
-    OffsetAtIndex(uint32_t idx) const
-    {
-        const Range *range = m_aranges.GetEntryAtIndex (idx);
-        if (range)
-            return range->data;
-        return DW_INVALID_OFFSET;
-    }
-
-    static void 
-    Dump(SymbolFileDWARF* dwarf2Data, lldb_private::Stream *s);
-    
-protected:
+  void Clear() { m_aranges.Clear(); }
 
+  bool Extract(const lldb_private::DWARFDataExtractor &debug_aranges_data);
 
-    RangeToDIE m_aranges;
-};
+  bool Generate(SymbolFileDWARF *dwarf2Data);
+
+  // Use append range multiple times and then call sort
+  void AppendRange(dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc);
+
+  void Sort(bool minimize);
+
+  const Range *RangeAtIndex(uint32_t idx) const {
+    return m_aranges.GetEntryAtIndex(idx);
+  }
+
+  void Dump(lldb_private::Log *log) const;
 
+  dw_offset_t FindAddress(dw_addr_t address) const;
+
+  bool IsEmpty() const { return m_aranges.IsEmpty(); }
+  size_t GetNumRanges() const { return m_aranges.GetSize(); }
+
+  dw_offset_t OffsetAtIndex(uint32_t idx) const {
+    const Range *range = m_aranges.GetEntryAtIndex(idx);
+    if (range)
+      return range->data;
+    return DW_INVALID_OFFSET;
+  }
+
+  static void Dump(SymbolFileDWARF *dwarf2Data, lldb_private::Stream *s);
+
+protected:
+  RangeToDIE m_aranges;
+};
 
-#endif  // SymbolFileDWARF_DWARFDebugAranges_h_
+#endif // SymbolFileDWARF_DWARFDebugAranges_h_

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Tue Sep  6 15:57:50 2016
@@ -17,10 +17,10 @@
 #include "lldb/Host/PosixApi.h"
 #include "lldb/Symbol/ObjectFile.h"
 
-#include "DWARFDebugAranges.h"
-#include "DWARFDebugInfo.h"
 #include "DWARFCompileUnit.h"
 #include "DWARFDebugAranges.h"
+#include "DWARFDebugAranges.h"
+#include "DWARFDebugInfo.h"
 #include "DWARFDebugInfoEntry.h"
 #include "DWARFFormValue.h"
 #include "LogChannelDWARF.h"
@@ -32,229 +32,192 @@ using namespace std;
 //----------------------------------------------------------------------
 // Constructor
 //----------------------------------------------------------------------
-DWARFDebugInfo::DWARFDebugInfo() :
-    m_dwarf2Data(NULL),
-    m_compile_units(),
-    m_cu_aranges_ap ()
-{
-}
+DWARFDebugInfo::DWARFDebugInfo()
+    : m_dwarf2Data(NULL), m_compile_units(), m_cu_aranges_ap() {}
 
 //----------------------------------------------------------------------
 // SetDwarfData
 //----------------------------------------------------------------------
-void
-DWARFDebugInfo::SetDwarfData(SymbolFileDWARF* dwarf2Data)
-{
-    m_dwarf2Data = dwarf2Data;
-    m_compile_units.clear();
-}
-
-
-DWARFDebugAranges &
-DWARFDebugInfo::GetCompileUnitAranges ()
-{
-    if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data)
-    {
-        Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
-
-        m_cu_aranges_ap.reset (new DWARFDebugAranges());
-        const DWARFDataExtractor &debug_aranges_data = m_dwarf2Data->get_debug_aranges_data();
-        if (debug_aranges_data.GetByteSize() > 0)
-        {
-            if (log)
-                log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" from .debug_aranges",
-                             m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
-            m_cu_aranges_ap->Extract (debug_aranges_data);
-            
-        }
-
-        // Make a list of all CUs represented by the arange data in the file.
-        std::set<dw_offset_t> cus_with_data;
-        for (size_t n=0;n<m_cu_aranges_ap.get()->GetNumRanges();n++)
-        {
-            dw_offset_t offset = m_cu_aranges_ap.get()->OffsetAtIndex(n);
-            if (offset != DW_INVALID_OFFSET)
-                cus_with_data.insert (offset);
-        }
-
-        // Manually build arange data for everything that wasn't in the .debug_aranges table.
-        bool printed = false;
-        const size_t num_compile_units = GetNumCompileUnits();
-        for (size_t idx = 0; idx < num_compile_units; ++idx)
-        {
-            DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx);
-
-            dw_offset_t offset = cu->GetOffset();
-            if (cus_with_data.find(offset) == cus_with_data.end())
-            {
-                if (log)
-                {
-                    if (!printed)
-                        log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" by parsing",
-                                     m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
-                    printed = true;
-                }
-                cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get());
-            }
-        }
-
-        const bool minimize = true;
-        m_cu_aranges_ap->Sort (minimize);
-    }
-    return *m_cu_aranges_ap.get();
-}
-
-void
-DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded()
-{
-    if (m_compile_units.empty())
-    {
-        if (m_dwarf2Data != NULL)
-        {
-            lldb::offset_t offset = 0;
-            const DWARFDataExtractor &debug_info_data = m_dwarf2Data->get_debug_info_data();
-            while (debug_info_data.ValidOffset(offset))
-            {
-                DWARFCompileUnitSP cu_sp(new DWARFCompileUnit(m_dwarf2Data));
-                // Out of memory?
-                if (cu_sp.get() == NULL)
-                    break;
-
-                if (cu_sp->Extract(debug_info_data, &offset) == false)
-                    break;
-
-                m_compile_units.push_back(cu_sp);
-
-                offset = cu_sp->GetNextCompileUnitOffset();
-            }
-        }
-    }
-}
-
-size_t
-DWARFDebugInfo::GetNumCompileUnits()
-{
+void DWARFDebugInfo::SetDwarfData(SymbolFileDWARF *dwarf2Data) {
+  m_dwarf2Data = dwarf2Data;
+  m_compile_units.clear();
+}
+
+DWARFDebugAranges &DWARFDebugInfo::GetCompileUnitAranges() {
+  if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data) {
+    Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
+
+    m_cu_aranges_ap.reset(new DWARFDebugAranges());
+    const DWARFDataExtractor &debug_aranges_data =
+        m_dwarf2Data->get_debug_aranges_data();
+    if (debug_aranges_data.GetByteSize() > 0) {
+      if (log)
+        log->Printf(
+            "DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" from "
+            ".debug_aranges",
+            m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
+      m_cu_aranges_ap->Extract(debug_aranges_data);
+    }
+
+    // Make a list of all CUs represented by the arange data in the file.
+    std::set<dw_offset_t> cus_with_data;
+    for (size_t n = 0; n < m_cu_aranges_ap.get()->GetNumRanges(); n++) {
+      dw_offset_t offset = m_cu_aranges_ap.get()->OffsetAtIndex(n);
+      if (offset != DW_INVALID_OFFSET)
+        cus_with_data.insert(offset);
+    }
+
+    // Manually build arange data for everything that wasn't in the
+    // .debug_aranges table.
+    bool printed = false;
+    const size_t num_compile_units = GetNumCompileUnits();
+    for (size_t idx = 0; idx < num_compile_units; ++idx) {
+      DWARFCompileUnit *cu = GetCompileUnitAtIndex(idx);
+
+      dw_offset_t offset = cu->GetOffset();
+      if (cus_with_data.find(offset) == cus_with_data.end()) {
+        if (log) {
+          if (!printed)
+            log->Printf(
+                "DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" by parsing",
+                m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
+          printed = true;
+        }
+        cu->BuildAddressRangeTable(m_dwarf2Data, m_cu_aranges_ap.get());
+      }
+    }
+
+    const bool minimize = true;
+    m_cu_aranges_ap->Sort(minimize);
+  }
+  return *m_cu_aranges_ap.get();
+}
+
+void DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded() {
+  if (m_compile_units.empty()) {
+    if (m_dwarf2Data != NULL) {
+      lldb::offset_t offset = 0;
+      const DWARFDataExtractor &debug_info_data =
+          m_dwarf2Data->get_debug_info_data();
+      while (debug_info_data.ValidOffset(offset)) {
+        DWARFCompileUnitSP cu_sp(new DWARFCompileUnit(m_dwarf2Data));
+        // Out of memory?
+        if (cu_sp.get() == NULL)
+          break;
+
+        if (cu_sp->Extract(debug_info_data, &offset) == false)
+          break;
+
+        m_compile_units.push_back(cu_sp);
+
+        offset = cu_sp->GetNextCompileUnitOffset();
+      }
+    }
+  }
+}
+
+size_t DWARFDebugInfo::GetNumCompileUnits() {
+  ParseCompileUnitHeadersIfNeeded();
+  return m_compile_units.size();
+}
+
+DWARFCompileUnit *DWARFDebugInfo::GetCompileUnitAtIndex(uint32_t idx) {
+  DWARFCompileUnit *cu = NULL;
+  if (idx < GetNumCompileUnits())
+    cu = m_compile_units[idx].get();
+  return cu;
+}
+
+bool DWARFDebugInfo::ContainsCompileUnit(const DWARFCompileUnit *cu) const {
+  // Not a verify efficient function, but it is handy for use in assertions
+  // to make sure that a compile unit comes from a debug information file.
+  CompileUnitColl::const_iterator end_pos = m_compile_units.end();
+  CompileUnitColl::const_iterator pos;
+
+  for (pos = m_compile_units.begin(); pos != end_pos; ++pos) {
+    if (pos->get() == cu)
+      return true;
+  }
+  return false;
+}
+
+bool DWARFDebugInfo::OffsetLessThanCompileUnitOffset(
+    dw_offset_t offset, const DWARFCompileUnitSP &cu_sp) {
+  return offset < cu_sp->GetOffset();
+}
+
+DWARFCompileUnit *DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset,
+                                                 uint32_t *idx_ptr) {
+  DWARFCompileUnitSP cu_sp;
+  uint32_t cu_idx = DW_INVALID_INDEX;
+  if (cu_offset != DW_INVALID_OFFSET) {
     ParseCompileUnitHeadersIfNeeded();
-    return m_compile_units.size();
-}
-
-DWARFCompileUnit*
-DWARFDebugInfo::GetCompileUnitAtIndex(uint32_t idx)
-{
-    DWARFCompileUnit* cu = NULL;
-    if (idx < GetNumCompileUnits())
-        cu = m_compile_units[idx].get();
-    return cu;
-}
-
-bool
-DWARFDebugInfo::ContainsCompileUnit (const DWARFCompileUnit *cu) const
-{
-    // Not a verify efficient function, but it is handy for use in assertions
-    // to make sure that a compile unit comes from a debug information file.
-    CompileUnitColl::const_iterator end_pos = m_compile_units.end();
-    CompileUnitColl::const_iterator pos;
-    
-    for (pos = m_compile_units.begin(); pos != end_pos; ++pos)
-    {
-        if (pos->get() == cu)
-            return true;
-    }
-    return false;
-}
-
-bool
-DWARFDebugInfo::OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& cu_sp)
-{
-    return offset < cu_sp->GetOffset();
-}
 
-DWARFCompileUnit *
-DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr)
-{
-    DWARFCompileUnitSP cu_sp;
-    uint32_t cu_idx = DW_INVALID_INDEX;
-    if (cu_offset != DW_INVALID_OFFSET)
-    {
-        ParseCompileUnitHeadersIfNeeded();
-
-        // Watch out for single compile unit executable as they are pretty common
-        const size_t num_cus = m_compile_units.size();
-        if (num_cus == 1)
-        {
-            if (m_compile_units[0]->GetOffset() == cu_offset)
-            {
-                cu_sp = m_compile_units[0];
-                cu_idx = 0;
-            }
-        }
-        else if (num_cus)
-        {
-            CompileUnitColl::const_iterator end_pos = m_compile_units.end();
-            CompileUnitColl::const_iterator begin_pos = m_compile_units.begin();
-            CompileUnitColl::const_iterator pos = std::upper_bound(begin_pos, end_pos, cu_offset, OffsetLessThanCompileUnitOffset);
-            if (pos != begin_pos)
-            {
-                --pos;
-                if ((*pos)->GetOffset() == cu_offset)
-                {
-                    cu_sp = *pos;
-                    cu_idx = std::distance(begin_pos, pos);
-                }
-            }
-        }
-    }
-    if (idx_ptr)
-        *idx_ptr = cu_idx;
-    return cu_sp.get();
+    // Watch out for single compile unit executable as they are pretty common
+    const size_t num_cus = m_compile_units.size();
+    if (num_cus == 1) {
+      if (m_compile_units[0]->GetOffset() == cu_offset) {
+        cu_sp = m_compile_units[0];
+        cu_idx = 0;
+      }
+    } else if (num_cus) {
+      CompileUnitColl::const_iterator end_pos = m_compile_units.end();
+      CompileUnitColl::const_iterator begin_pos = m_compile_units.begin();
+      CompileUnitColl::const_iterator pos = std::upper_bound(
+          begin_pos, end_pos, cu_offset, OffsetLessThanCompileUnitOffset);
+      if (pos != begin_pos) {
+        --pos;
+        if ((*pos)->GetOffset() == cu_offset) {
+          cu_sp = *pos;
+          cu_idx = std::distance(begin_pos, pos);
+        }
+      }
+    }
+  }
+  if (idx_ptr)
+    *idx_ptr = cu_idx;
+  return cu_sp.get();
+}
+
+DWARFCompileUnit *DWARFDebugInfo::GetCompileUnit(const DIERef &die_ref) {
+  if (die_ref.cu_offset == DW_INVALID_OFFSET)
+    return GetCompileUnitContainingDIEOffset(die_ref.die_offset);
+  else
+    return GetCompileUnit(die_ref.cu_offset);
 }
 
 DWARFCompileUnit *
-DWARFDebugInfo::GetCompileUnit (const DIERef& die_ref)
-{
-    if (die_ref.cu_offset == DW_INVALID_OFFSET)
-        return GetCompileUnitContainingDIEOffset(die_ref.die_offset);
-    else
-        return GetCompileUnit(die_ref.cu_offset);
-}
-
-DWARFCompileUnit*
-DWARFDebugInfo::GetCompileUnitContainingDIEOffset(dw_offset_t die_offset)
-{
-    ParseCompileUnitHeadersIfNeeded();
+DWARFDebugInfo::GetCompileUnitContainingDIEOffset(dw_offset_t die_offset) {
+  ParseCompileUnitHeadersIfNeeded();
 
-    DWARFCompileUnitSP cu_sp;
+  DWARFCompileUnitSP cu_sp;
 
-    // Watch out for single compile unit executable as they are pretty common
-    const size_t num_cus = m_compile_units.size();
-    if (num_cus == 1)
-    {
-        if (m_compile_units[0]->ContainsDIEOffset(die_offset))
-            return m_compile_units[0].get();
-    }
-    else if (num_cus)
-    {
-        CompileUnitColl::const_iterator end_pos = m_compile_units.end();
-        CompileUnitColl::const_iterator begin_pos = m_compile_units.begin();
-        CompileUnitColl::const_iterator pos = std::upper_bound(begin_pos, end_pos, die_offset, OffsetLessThanCompileUnitOffset);
-        if (pos != begin_pos)
-        {
-            --pos;
-            if ((*pos)->ContainsDIEOffset(die_offset))
-                return (*pos).get();
-        }
+  // Watch out for single compile unit executable as they are pretty common
+  const size_t num_cus = m_compile_units.size();
+  if (num_cus == 1) {
+    if (m_compile_units[0]->ContainsDIEOffset(die_offset))
+      return m_compile_units[0].get();
+  } else if (num_cus) {
+    CompileUnitColl::const_iterator end_pos = m_compile_units.end();
+    CompileUnitColl::const_iterator begin_pos = m_compile_units.begin();
+    CompileUnitColl::const_iterator pos = std::upper_bound(
+        begin_pos, end_pos, die_offset, OffsetLessThanCompileUnitOffset);
+    if (pos != begin_pos) {
+      --pos;
+      if ((*pos)->ContainsDIEOffset(die_offset))
+        return (*pos).get();
     }
+  }
 
-    return nullptr;
+  return nullptr;
 }
 
 DWARFDIE
-DWARFDebugInfo::GetDIEForDIEOffset(dw_offset_t die_offset)
-{
-    DWARFCompileUnit* cu = GetCompileUnitContainingDIEOffset(die_offset);
-    if (cu)
-        return cu->GetDIE(die_offset);
-    return DWARFDIE();
+DWARFDebugInfo::GetDIEForDIEOffset(dw_offset_t die_offset) {
+  DWARFCompileUnit *cu = GetCompileUnitContainingDIEOffset(die_offset);
+  if (cu)
+    return cu->GetDIE(die_offset);
+  return DWARFDIE();
 }
 
 //----------------------------------------------------------------------
@@ -263,12 +226,11 @@ DWARFDebugInfo::GetDIEForDIEOffset(dw_of
 // Get the DIE (Debug Information Entry) with the specified offset.
 //----------------------------------------------------------------------
 DWARFDIE
-DWARFDebugInfo::GetDIE(const DIERef& die_ref)
-{
-    DWARFCompileUnit *cu = GetCompileUnit(die_ref);
-    if (cu)
-        return cu->GetDIE (die_ref.die_offset);
-    return DWARFDIE();    // Not found
+DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
+  DWARFCompileUnit *cu = GetCompileUnit(die_ref);
+  if (cu)
+    return cu->GetDIE(die_ref.die_offset);
+  return DWARFDIE(); // Not found
 }
 
 //----------------------------------------------------------------------
@@ -281,88 +243,75 @@ DWARFDebugInfo::GetDIE(const DIERef& die
 // for different tasks such as parsing the file contents into a
 // structured data, dumping, verifying and much more.
 //----------------------------------------------------------------------
-void
-DWARFDebugInfo::Parse(SymbolFileDWARF* dwarf2Data, Callback callback, void* userData)
-{
-    if (dwarf2Data)
-    {
-        lldb::offset_t offset = 0;
-        uint32_t depth = 0;
-        DWARFCompileUnitSP cu(new DWARFCompileUnit(dwarf2Data));
-        if (cu.get() == NULL)
-            return;
-        DWARFDebugInfoEntry die;
-
-        while (cu->Extract(dwarf2Data->get_debug_info_data(), &offset))
-        {
-            const dw_offset_t next_cu_offset = cu->GetNextCompileUnitOffset();
-
-            depth = 0;
-            // Call the callback function with no DIE pointer for the compile unit
-            // and get the offset that we are to continue to parse from
-            offset = callback(dwarf2Data, cu.get(), NULL, offset, depth, userData);
-
-            // Make sure we are within our compile unit
-            if (offset < next_cu_offset)
-            {
-                // We are in our compile unit, parse starting at the offset
-                // we were told to parse
-                bool done = false;
-                while (!done && die.Extract(dwarf2Data, cu.get(), &offset))
-                {
-                    // Call the callback function with DIE pointer that falls within the compile unit
-                    offset = callback(dwarf2Data, cu.get(), &die, offset, depth, userData);
-
-                    if (die.IsNULL())
-                    {
-                        if (depth)
-                            --depth;
-                        else
-                            done = true;    // We are done with this compile unit!
-                    }
-                    else if (die.HasChildren())
-                        ++depth;
-                }
-            }
-
-            // Make sure the offset returned is valid, and if not stop parsing.
-            // Returning DW_INVALID_OFFSET from this callback is a good way to end
-            // all parsing
-            if (!dwarf2Data->get_debug_info_data().ValidOffset(offset))
-                break;
-
-            // See if during the callback anyone retained a copy of the compile
-            // unit other than ourselves and if so, let whomever did own the object
-            // and create a new one for our own use!
-            if (!cu.unique())
-                cu.reset(new DWARFCompileUnit(dwarf2Data));
-
-
-            // Make sure we start on a proper
-            offset = next_cu_offset;
-        }
-    }
-}
-
-typedef struct DumpInfo
-{
-    DumpInfo(Stream* init_strm, uint32_t off, uint32_t depth) :
-        strm(init_strm),
-        die_offset(off),
-        recurse_depth(depth),
-        found_depth(UINT32_MAX),
-        found_die(false),
-        ancestors()
-    {
-    }
-    Stream* strm;
-    const uint32_t die_offset;
-    const uint32_t recurse_depth;
-    uint32_t found_depth;
-    bool found_die;
-    std::vector<DWARFDebugInfoEntry> ancestors;
+void DWARFDebugInfo::Parse(SymbolFileDWARF *dwarf2Data, Callback callback,
+                           void *userData) {
+  if (dwarf2Data) {
+    lldb::offset_t offset = 0;
+    uint32_t depth = 0;
+    DWARFCompileUnitSP cu(new DWARFCompileUnit(dwarf2Data));
+    if (cu.get() == NULL)
+      return;
+    DWARFDebugInfoEntry die;
+
+    while (cu->Extract(dwarf2Data->get_debug_info_data(), &offset)) {
+      const dw_offset_t next_cu_offset = cu->GetNextCompileUnitOffset();
+
+      depth = 0;
+      // Call the callback function with no DIE pointer for the compile unit
+      // and get the offset that we are to continue to parse from
+      offset = callback(dwarf2Data, cu.get(), NULL, offset, depth, userData);
+
+      // Make sure we are within our compile unit
+      if (offset < next_cu_offset) {
+        // We are in our compile unit, parse starting at the offset
+        // we were told to parse
+        bool done = false;
+        while (!done && die.Extract(dwarf2Data, cu.get(), &offset)) {
+          // Call the callback function with DIE pointer that falls within the
+          // compile unit
+          offset =
+              callback(dwarf2Data, cu.get(), &die, offset, depth, userData);
+
+          if (die.IsNULL()) {
+            if (depth)
+              --depth;
+            else
+              done = true; // We are done with this compile unit!
+          } else if (die.HasChildren())
+            ++depth;
+        }
+      }
+
+      // Make sure the offset returned is valid, and if not stop parsing.
+      // Returning DW_INVALID_OFFSET from this callback is a good way to end
+      // all parsing
+      if (!dwarf2Data->get_debug_info_data().ValidOffset(offset))
+        break;
+
+      // See if during the callback anyone retained a copy of the compile
+      // unit other than ourselves and if so, let whomever did own the object
+      // and create a new one for our own use!
+      if (!cu.unique())
+        cu.reset(new DWARFCompileUnit(dwarf2Data));
+
+      // Make sure we start on a proper
+      offset = next_cu_offset;
+    }
+  }
+}
+
+typedef struct DumpInfo {
+  DumpInfo(Stream *init_strm, uint32_t off, uint32_t depth)
+      : strm(init_strm), die_offset(off), recurse_depth(depth),
+        found_depth(UINT32_MAX), found_die(false), ancestors() {}
+  Stream *strm;
+  const uint32_t die_offset;
+  const uint32_t recurse_depth;
+  uint32_t found_depth;
+  bool found_die;
+  std::vector<DWARFDebugInfoEntry> ancestors;
 
-    DISALLOW_COPY_AND_ASSIGN(DumpInfo);
+  DISALLOW_COPY_AND_ASSIGN(DumpInfo);
 } DumpInfo;
 
 //----------------------------------------------------------------------
@@ -375,168 +324,134 @@ typedef struct DumpInfo
 // This function dump DWARF information and obey recurse depth and
 // whether a single DIE is to be dumped (or all of the data).
 //----------------------------------------------------------------------
-static dw_offset_t DumpCallback
-(
-    SymbolFileDWARF* dwarf2Data,
-    DWARFCompileUnit* cu,
-    DWARFDebugInfoEntry* die,
-    const dw_offset_t next_offset,
-    const uint32_t curr_depth,
-    void* userData
-)
-{
-    DumpInfo* dumpInfo = (DumpInfo*)userData;
-    Stream *s = dumpInfo->strm;
-    bool show_parents = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowAncestors);
-
-    if (die)
-    {
-        // Are we dumping everything?
-        if (dumpInfo->die_offset == DW_INVALID_OFFSET)
-        {
-            // Yes we are dumping everything. Obey our recurse level though
-            if (curr_depth < dumpInfo->recurse_depth)
-                die->Dump(dwarf2Data, cu, *s, 0);
-        }
-        else
-        {
-            // We are dumping a specific DIE entry by offset
-            if (dumpInfo->die_offset == die->GetOffset())
-            {
-                // We found the DIE we were looking for, dump it!
-                if (show_parents)
-                {
-                    s->SetIndentLevel(0);
-                    const uint32_t num_ancestors = dumpInfo->ancestors.size();
-                    if (num_ancestors > 0)
-                    {
-                        for (uint32_t i=0; i<num_ancestors-1; ++i)
-                        {
-                            dumpInfo->ancestors[i].Dump(dwarf2Data, cu, *s, 0);
-                            s->IndentMore();
-                        }
-                    }
-                }
-
-                dumpInfo->found_depth = curr_depth;
-
-                die->Dump(dwarf2Data, cu, *s, 0);
-
-                // Note that we found the DIE we were looking for
-                dumpInfo->found_die = true;
-
-                // Since we are dumping a single DIE, if there are no children we are done!
-                if (!die->HasChildren() || dumpInfo->recurse_depth == 0)
-                    return DW_INVALID_OFFSET;   // Return an invalid address to end parsing
-            }
-            else if (dumpInfo->found_die)
-            {
-                // Are we done with all the children?
-                if (curr_depth <= dumpInfo->found_depth)
-                    return DW_INVALID_OFFSET;
-
-                // We have already found our DIE and are printing it's children. Obey
-                // our recurse depth and return an invalid offset if we get done
-                // dumping all of the children
-                if (dumpInfo->recurse_depth == UINT32_MAX || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth)
-                    die->Dump(dwarf2Data, cu, *s, 0);
-            }
-            else if (dumpInfo->die_offset > die->GetOffset())
-            {
-                if (show_parents)
-                    dumpInfo->ancestors.back() = *die;
-            }
-        }
-
-        // Keep up with our indent level
-        if (die->IsNULL())
-        {
-            if (show_parents)
-                dumpInfo->ancestors.pop_back();
-
-            if (curr_depth <= 1)
-                return cu->GetNextCompileUnitOffset();
-            else
-                s->IndentLess();
-        }
-        else if (die->HasChildren())
-        {
-            if (show_parents)
-            {
-                DWARFDebugInfoEntry null_die;
-                dumpInfo->ancestors.push_back(null_die);
-            }
-            s->IndentMore();
-        }
-    }
-    else
-    {
-        if (cu == NULL)
-            s->PutCString("NULL - cu");
-        // We have a compile unit, reset our indent level to zero just in case
-        s->SetIndentLevel(0);
-
-        // See if we are dumping everything?
-        if (dumpInfo->die_offset == DW_INVALID_OFFSET)
-        {
-            // We are dumping everything
-            if (cu)
-            {
-                cu->Dump(s);
-                return cu->GetFirstDIEOffset(); // Return true to parse all DIEs in this Compile Unit
-            }
-            else
-            {
-                return DW_INVALID_OFFSET;
-            }
-        }
-        else
-        {
-            if (show_parents)
-            {
-                dumpInfo->ancestors.clear();
-                dumpInfo->ancestors.resize(1);
-            }
-
-            // We are dumping only a single DIE possibly with it's children and
-            // we must find it's compile unit before we can dump it properly
-            if (cu && dumpInfo->die_offset < cu->GetFirstDIEOffset())
-            {
-                // Not found, maybe the DIE offset provided wasn't correct?
-            //  *ostrm_ptr << "DIE at offset " << HEX32 << dumpInfo->die_offset << " was not found." << endl;
-                return DW_INVALID_OFFSET;
-            }
-            else
-            {
-                // See if the DIE is in this compile unit?
-                if (cu && dumpInfo->die_offset < cu->GetNextCompileUnitOffset())
-                {
-                    // This DIE is in this compile unit!
-                    if (s->GetVerbose())
-                        cu->Dump(s); // Dump the compile unit for the DIE in verbose mode
-
-                    return next_offset;
-                //  // We found our compile unit that contains our DIE, just skip to dumping the requested DIE...
-                //  return dumpInfo->die_offset;
-                }
-                else
-                {
-                    // Skip to the next compile unit as the DIE isn't in the current one!
-                    if (cu)
-                    {
-                        return cu->GetNextCompileUnitOffset();
-                    }
-                    else
-                    {
-                        return DW_INVALID_OFFSET;
-                    }
-                }
-            }
+static dw_offset_t DumpCallback(SymbolFileDWARF *dwarf2Data,
+                                DWARFCompileUnit *cu, DWARFDebugInfoEntry *die,
+                                const dw_offset_t next_offset,
+                                const uint32_t curr_depth, void *userData) {
+  DumpInfo *dumpInfo = (DumpInfo *)userData;
+  Stream *s = dumpInfo->strm;
+  bool show_parents =
+      s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowAncestors);
+
+  if (die) {
+    // Are we dumping everything?
+    if (dumpInfo->die_offset == DW_INVALID_OFFSET) {
+      // Yes we are dumping everything. Obey our recurse level though
+      if (curr_depth < dumpInfo->recurse_depth)
+        die->Dump(dwarf2Data, cu, *s, 0);
+    } else {
+      // We are dumping a specific DIE entry by offset
+      if (dumpInfo->die_offset == die->GetOffset()) {
+        // We found the DIE we were looking for, dump it!
+        if (show_parents) {
+          s->SetIndentLevel(0);
+          const uint32_t num_ancestors = dumpInfo->ancestors.size();
+          if (num_ancestors > 0) {
+            for (uint32_t i = 0; i < num_ancestors - 1; ++i) {
+              dumpInfo->ancestors[i].Dump(dwarf2Data, cu, *s, 0);
+              s->IndentMore();
+            }
+          }
+        }
+
+        dumpInfo->found_depth = curr_depth;
+
+        die->Dump(dwarf2Data, cu, *s, 0);
+
+        // Note that we found the DIE we were looking for
+        dumpInfo->found_die = true;
+
+        // Since we are dumping a single DIE, if there are no children we are
+        // done!
+        if (!die->HasChildren() || dumpInfo->recurse_depth == 0)
+          return DW_INVALID_OFFSET; // Return an invalid address to end parsing
+      } else if (dumpInfo->found_die) {
+        // Are we done with all the children?
+        if (curr_depth <= dumpInfo->found_depth)
+          return DW_INVALID_OFFSET;
+
+        // We have already found our DIE and are printing it's children. Obey
+        // our recurse depth and return an invalid offset if we get done
+        // dumping all of the children
+        if (dumpInfo->recurse_depth == UINT32_MAX ||
+            curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth)
+          die->Dump(dwarf2Data, cu, *s, 0);
+      } else if (dumpInfo->die_offset > die->GetOffset()) {
+        if (show_parents)
+          dumpInfo->ancestors.back() = *die;
+      }
+    }
+
+    // Keep up with our indent level
+    if (die->IsNULL()) {
+      if (show_parents)
+        dumpInfo->ancestors.pop_back();
+
+      if (curr_depth <= 1)
+        return cu->GetNextCompileUnitOffset();
+      else
+        s->IndentLess();
+    } else if (die->HasChildren()) {
+      if (show_parents) {
+        DWARFDebugInfoEntry null_die;
+        dumpInfo->ancestors.push_back(null_die);
+      }
+      s->IndentMore();
+    }
+  } else {
+    if (cu == NULL)
+      s->PutCString("NULL - cu");
+    // We have a compile unit, reset our indent level to zero just in case
+    s->SetIndentLevel(0);
+
+    // See if we are dumping everything?
+    if (dumpInfo->die_offset == DW_INVALID_OFFSET) {
+      // We are dumping everything
+      if (cu) {
+        cu->Dump(s);
+        return cu->GetFirstDIEOffset(); // Return true to parse all DIEs in this
+                                        // Compile Unit
+      } else {
+        return DW_INVALID_OFFSET;
+      }
+    } else {
+      if (show_parents) {
+        dumpInfo->ancestors.clear();
+        dumpInfo->ancestors.resize(1);
+      }
+
+      // We are dumping only a single DIE possibly with it's children and
+      // we must find it's compile unit before we can dump it properly
+      if (cu && dumpInfo->die_offset < cu->GetFirstDIEOffset()) {
+        // Not found, maybe the DIE offset provided wasn't correct?
+        //  *ostrm_ptr << "DIE at offset " << HEX32 << dumpInfo->die_offset << "
+        //  was not found." << endl;
+        return DW_INVALID_OFFSET;
+      } else {
+        // See if the DIE is in this compile unit?
+        if (cu && dumpInfo->die_offset < cu->GetNextCompileUnitOffset()) {
+          // This DIE is in this compile unit!
+          if (s->GetVerbose())
+            cu->Dump(s); // Dump the compile unit for the DIE in verbose mode
+
+          return next_offset;
+          //  // We found our compile unit that contains our DIE, just skip to
+          //  dumping the requested DIE...
+          //  return dumpInfo->die_offset;
+        } else {
+          // Skip to the next compile unit as the DIE isn't in the current one!
+          if (cu) {
+            return cu->GetNextCompileUnitOffset();
+          } else {
+            return DW_INVALID_OFFSET;
+          }
         }
+      }
     }
+  }
 
-    // Just return the current offset to parse the next CU or DIE entry
-    return next_offset;
+  // Just return the current offset to parse the next CU or DIE entry
+  return next_offset;
 }
 
 //----------------------------------------------------------------------
@@ -551,66 +466,52 @@ static dw_offset_t DumpCallback
 // headers and the DW_TAG_compile unit tags. A depth of 2 will also
 // dump all types and functions.
 //----------------------------------------------------------------------
-void
-DWARFDebugInfo::Dump
-(
-    Stream *s,
-    SymbolFileDWARF* dwarf2Data,
-    const uint32_t die_offset,
-    const uint32_t recurse_depth
-)
-{
-    DumpInfo dumpInfo(s, die_offset, recurse_depth);
-    s->PutCString(".debug_info contents");
-    if (dwarf2Data->get_debug_info_data().GetByteSize() > 0)
-    {
-        if (die_offset == DW_INVALID_OFFSET)
-            s->PutCString(":\n");
-        else
-        {
-            s->Printf(" for DIE entry at .debug_info[0x%8.8x]", die_offset);
-            if (recurse_depth != UINT32_MAX)
-                s->Printf(" recursing %u levels deep.", recurse_depth);
-            s->EOL();
-        }
-    }
-    else
-    {
-        s->PutCString(": < EMPTY >\n");
-        return;
-    }
-    DWARFDebugInfo::Parse(dwarf2Data, DumpCallback, &dumpInfo);
+void DWARFDebugInfo::Dump(Stream *s, SymbolFileDWARF *dwarf2Data,
+                          const uint32_t die_offset,
+                          const uint32_t recurse_depth) {
+  DumpInfo dumpInfo(s, die_offset, recurse_depth);
+  s->PutCString(".debug_info contents");
+  if (dwarf2Data->get_debug_info_data().GetByteSize() > 0) {
+    if (die_offset == DW_INVALID_OFFSET)
+      s->PutCString(":\n");
+    else {
+      s->Printf(" for DIE entry at .debug_info[0x%8.8x]", die_offset);
+      if (recurse_depth != UINT32_MAX)
+        s->Printf(" recursing %u levels deep.", recurse_depth);
+      s->EOL();
+    }
+  } else {
+    s->PutCString(": < EMPTY >\n");
+    return;
+  }
+  DWARFDebugInfo::Parse(dwarf2Data, DumpCallback, &dumpInfo);
 }
 
-
 //----------------------------------------------------------------------
 // Dump
 //
 // Dump the contents of this DWARFDebugInfo object as has been parsed
 // and/or modified after it has been parsed.
 //----------------------------------------------------------------------
-void
-DWARFDebugInfo::Dump (Stream *s, const uint32_t die_offset, const uint32_t recurse_depth)
-{
-    DumpInfo dumpInfo(s, die_offset, recurse_depth);
-
-    s->PutCString("Dumping .debug_info section from internal representation\n");
+void DWARFDebugInfo::Dump(Stream *s, const uint32_t die_offset,
+                          const uint32_t recurse_depth) {
+  DumpInfo dumpInfo(s, die_offset, recurse_depth);
+
+  s->PutCString("Dumping .debug_info section from internal representation\n");
+
+  CompileUnitColl::const_iterator pos;
+  uint32_t curr_depth = 0;
+  ParseCompileUnitHeadersIfNeeded();
+  for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos) {
+    DWARFCompileUnit *cu = pos->get();
+    DumpCallback(m_dwarf2Data, cu, NULL, 0, curr_depth, &dumpInfo);
 
-    CompileUnitColl::const_iterator pos;
-    uint32_t curr_depth = 0;
-    ParseCompileUnitHeadersIfNeeded();
-    for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos)
-    {
-        DWARFCompileUnit *cu = pos->get();
-        DumpCallback(m_dwarf2Data, cu, NULL, 0, curr_depth, &dumpInfo);
-        
-        const DWARFDIE die = cu->DIE();
-        if (die)
-            die.Dump(s, recurse_depth);
-    }
+    const DWARFDIE die = cu->DIE();
+    if (die)
+      die.Dump(s, recurse_depth);
+  }
 }
 
-
 //----------------------------------------------------------------------
 // FindCallbackString
 //
@@ -621,46 +522,35 @@ DWARFDebugInfo::Dump (Stream *s, const u
 // This function will find the die_offset of any items whose DW_AT_name
 // matches the given string
 //----------------------------------------------------------------------
-typedef struct FindCallbackStringInfoTag
-{
-    const char* name;
-    bool ignore_case;
-    RegularExpression* regex;
-    vector<dw_offset_t>& die_offsets;
+typedef struct FindCallbackStringInfoTag {
+  const char *name;
+  bool ignore_case;
+  RegularExpression *regex;
+  vector<dw_offset_t> &die_offsets;
 } FindCallbackStringInfo;
 
-static dw_offset_t FindCallbackString
-(
-    SymbolFileDWARF* dwarf2Data,
-    DWARFCompileUnit* cu,
-    DWARFDebugInfoEntry* die,
-    const dw_offset_t next_offset,
-    const uint32_t curr_depth,
-    void* userData
-)
-{
-    FindCallbackStringInfo* info = (FindCallbackStringInfo*)userData;
-
-    if (die)
-    {
-        const char* die_name = die->GetName(dwarf2Data, cu);
-        if (die_name)
-        {
-            if (info->regex)
-            {
-                if (info->regex->Execute(die_name))
-                    info->die_offsets.push_back(die->GetOffset());
-            }
-            else
-            {
-                if ((info->ignore_case ? strcasecmp(die_name, info->name) : strcmp(die_name, info->name)) == 0)
-                    info->die_offsets.push_back(die->GetOffset());
-            }
-        }
+static dw_offset_t
+FindCallbackString(SymbolFileDWARF *dwarf2Data, DWARFCompileUnit *cu,
+                   DWARFDebugInfoEntry *die, const dw_offset_t next_offset,
+                   const uint32_t curr_depth, void *userData) {
+  FindCallbackStringInfo *info = (FindCallbackStringInfo *)userData;
+
+  if (die) {
+    const char *die_name = die->GetName(dwarf2Data, cu);
+    if (die_name) {
+      if (info->regex) {
+        if (info->regex->Execute(die_name))
+          info->die_offsets.push_back(die->GetOffset());
+      } else {
+        if ((info->ignore_case ? strcasecmp(die_name, info->name)
+                               : strcmp(die_name, info->name)) == 0)
+          info->die_offsets.push_back(die->GetOffset());
+      }
     }
+  }
 
-    // Just return the current offset to parse the next CU or DIE entry
-    return next_offset;
+  // Just return the current offset to parse the next CU or DIE entry
+  return next_offset;
 }
 
 //----------------------------------------------------------------------
@@ -671,16 +561,14 @@ static dw_offset_t FindCallbackString
 // .debug_pubnames section). The string must match the entire name
 // and case sensitive searches are an option.
 //----------------------------------------------------------------------
-bool
-DWARFDebugInfo::Find(const char* name, bool ignore_case, vector<dw_offset_t>& die_offsets) const
-{
-    die_offsets.clear();
-    if (name && name[0])
-    {
-        FindCallbackStringInfo info = { name, ignore_case, NULL, die_offsets };
-        DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info);
-    }
-    return !die_offsets.empty();
+bool DWARFDebugInfo::Find(const char *name, bool ignore_case,
+                          vector<dw_offset_t> &die_offsets) const {
+  die_offsets.clear();
+  if (name && name[0]) {
+    FindCallbackStringInfo info = {name, ignore_case, NULL, die_offsets};
+    DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info);
+  }
+  return !die_offsets.empty();
 }
 
 //----------------------------------------------------------------------
@@ -691,11 +579,10 @@ DWARFDebugInfo::Find(const char* name, b
 // .debug_pubnames section). The string must match the supplied regular
 // expression.
 //----------------------------------------------------------------------
-bool
-DWARFDebugInfo::Find(RegularExpression& re, vector<dw_offset_t>& die_offsets) const
-{
-    die_offsets.clear();
-    FindCallbackStringInfo info = { NULL, false, &re, die_offsets };
-    DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info);
-    return !die_offsets.empty();
+bool DWARFDebugInfo::Find(RegularExpression &re,
+                          vector<dw_offset_t> &die_offsets) const {
+  die_offsets.clear();
+  FindCallbackStringInfo info = {NULL, false, &re, die_offsets};
+  DWARFDebugInfo::Parse(m_dwarf2Data, FindCallbackString, &info);
+  return !die_offsets.empty();
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h Tue Sep  6 15:57:50 2016
@@ -10,78 +10,82 @@
 #ifndef SymbolFileDWARF_DWARFDebugInfo_h_
 #define SymbolFileDWARF_DWARFDebugInfo_h_
 
-#include <vector>
 #include <map>
+#include <vector>
 
+#include "DWARFDIE.h"
+#include "SymbolFileDWARF.h"
 #include "lldb/lldb-private.h"
 #include "lldb/lldb-private.h"
-#include "SymbolFileDWARF.h"
-#include "DWARFDIE.h"
 
-typedef std::multimap<const char*, dw_offset_t, CStringCompareFunctionObject> CStringToDIEMap;
+typedef std::multimap<const char *, dw_offset_t, CStringCompareFunctionObject>
+    CStringToDIEMap;
 typedef CStringToDIEMap::iterator CStringToDIEMapIter;
 typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter;
 
-class DWARFDebugInfo
-{
+class DWARFDebugInfo {
 public:
-    typedef dw_offset_t (*Callback)(
-        SymbolFileDWARF* dwarf2Data,
-        DWARFCompileUnit* cu,
-        DWARFDebugInfoEntry* die,
-        const dw_offset_t next_offset,
-        const uint32_t depth,
-        void* userData);
-
-    DWARFDebugInfo();
-    void SetDwarfData(SymbolFileDWARF* dwarf2Data);
-
-    size_t GetNumCompileUnits();
-    bool ContainsCompileUnit (const DWARFCompileUnit *cu) const;
-    DWARFCompileUnit* GetCompileUnitAtIndex (uint32_t idx);
-    DWARFCompileUnit* GetCompileUnit(dw_offset_t cu_offset, uint32_t* idx_ptr = NULL);
-    DWARFCompileUnit* GetCompileUnitContainingDIEOffset (dw_offset_t die_offset);
-    DWARFCompileUnit* GetCompileUnit(const DIERef& die_ref);
-    DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset);
-    DWARFDIE GetDIE (const DIERef& die_ref);
-
-    void Dump(lldb_private::Stream *s, const uint32_t die_offset, const uint32_t recurse_depth);
-    static void Parse(SymbolFileDWARF* parser, Callback callback, void* userData);
-    static void Verify(lldb_private::Stream *s, SymbolFileDWARF* dwarf2Data);
-    static void Dump(lldb_private::Stream *s, SymbolFileDWARF* dwarf2Data, const uint32_t die_offset, const uint32_t recurse_depth);
-    bool Find(const char* name, bool ignore_case, std::vector<dw_offset_t>& die_offsets) const;
-    bool Find(lldb_private::RegularExpression& re, std::vector<dw_offset_t>& die_offsets) const;
-
-    enum
-    {
-        eDumpFlag_Verbose               = (1<<0),   // Verbose dumping
-        eDumpFlag_ShowForm              = (1<<1),   // Show the DW_form type
-        eDumpFlag_ShowAncestors         = (1<<2)    // Show all parent DIEs when dumping single DIEs
-    };
+  typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data,
+                                  DWARFCompileUnit *cu,
+                                  DWARFDebugInfoEntry *die,
+                                  const dw_offset_t next_offset,
+                                  const uint32_t depth, void *userData);
+
+  DWARFDebugInfo();
+  void SetDwarfData(SymbolFileDWARF *dwarf2Data);
+
+  size_t GetNumCompileUnits();
+  bool ContainsCompileUnit(const DWARFCompileUnit *cu) const;
+  DWARFCompileUnit *GetCompileUnitAtIndex(uint32_t idx);
+  DWARFCompileUnit *GetCompileUnit(dw_offset_t cu_offset,
+                                   uint32_t *idx_ptr = NULL);
+  DWARFCompileUnit *GetCompileUnitContainingDIEOffset(dw_offset_t die_offset);
+  DWARFCompileUnit *GetCompileUnit(const DIERef &die_ref);
+  DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset);
+  DWARFDIE GetDIE(const DIERef &die_ref);
+
+  void Dump(lldb_private::Stream *s, const uint32_t die_offset,
+            const uint32_t recurse_depth);
+  static void Parse(SymbolFileDWARF *parser, Callback callback, void *userData);
+  static void Verify(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data);
+  static void Dump(lldb_private::Stream *s, SymbolFileDWARF *dwarf2Data,
+                   const uint32_t die_offset, const uint32_t recurse_depth);
+  bool Find(const char *name, bool ignore_case,
+            std::vector<dw_offset_t> &die_offsets) const;
+  bool Find(lldb_private::RegularExpression &re,
+            std::vector<dw_offset_t> &die_offsets) const;
+
+  enum {
+    eDumpFlag_Verbose = (1 << 0),  // Verbose dumping
+    eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
+    eDumpFlag_ShowAncestors =
+        (1 << 2) // Show all parent DIEs when dumping single DIEs
+  };
 
-    DWARFDebugAranges &
-    GetCompileUnitAranges ();
+  DWARFDebugAranges &GetCompileUnitAranges();
 
 protected:
-    typedef std::shared_ptr<DWARFCompileUnit> DWARFCompileUnitSP;
+  typedef std::shared_ptr<DWARFCompileUnit> DWARFCompileUnitSP;
 
-    static bool
-    OffsetLessThanCompileUnitOffset (dw_offset_t offset, const DWARFCompileUnitSP& cu_sp);
+  static bool OffsetLessThanCompileUnitOffset(dw_offset_t offset,
+                                              const DWARFCompileUnitSP &cu_sp);
 
-    typedef std::vector<DWARFCompileUnitSP>     CompileUnitColl;
+  typedef std::vector<DWARFCompileUnitSP> CompileUnitColl;
 
-    //----------------------------------------------------------------------
-    // Member variables
-    //----------------------------------------------------------------------
-    SymbolFileDWARF* m_dwarf2Data;
-    CompileUnitColl m_compile_units;
-    std::unique_ptr<DWARFDebugAranges> m_cu_aranges_ap; // A quick address to compile unit table
+  //----------------------------------------------------------------------
+  // Member variables
+  //----------------------------------------------------------------------
+  SymbolFileDWARF *m_dwarf2Data;
+  CompileUnitColl m_compile_units;
+  std::unique_ptr<DWARFDebugAranges>
+      m_cu_aranges_ap; // A quick address to compile unit table
 
 private:
-    // All parsing needs to be done partially any managed by this class as accessors are called.
-    void ParseCompileUnitHeadersIfNeeded();
+  // All parsing needs to be done partially any managed by this class as
+  // accessors are called.
+  void ParseCompileUnitHeadersIfNeeded();
 
-    DISALLOW_COPY_AND_ASSIGN (DWARFDebugInfo);
+  DISALLOW_COPY_AND_ASSIGN(DWARFDebugInfo);
 };
 
-#endif  // SymbolFileDWARF_DWARFDebugInfo_h_
+#endif // SymbolFileDWARF_DWARFDebugInfo_h_




More information about the lldb-commits mailing list