[Lldb-commits] [lldb] 268e11f - Convert condition to early exit (NFC)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 14 09:39:14 PST 2019


Author: Adrian Prantl
Date: 2019-11-14T09:38:49-08:00
New Revision: 268e11f95d331a6268f08bf94ce86d04efbb7baa

URL: https://github.com/llvm/llvm-project/commit/268e11f95d331a6268f08bf94ce86d04efbb7baa
DIFF: https://github.com/llvm/llvm-project/commit/268e11f95d331a6268f08bf94ce86d04efbb7baa.diff

LOG: Convert condition to early exit (NFC)

Added: 
    

Modified: 
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 4d4a0d8b7bc9..727334f3717b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1639,52 +1639,54 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
         die.GetAttributeValueAsString(DW_AT_GNU_dwo_name, nullptr);
     if (!dwo_path)
       dwo_path = die.GetAttributeValueAsString(DW_AT_dwo_name, nullptr);
-    if (dwo_path) {
-      ModuleSpec dwo_module_spec;
-      dwo_module_spec.GetFileSpec().SetFile(dwo_path, FileSpec::Style::native);
-      if (dwo_module_spec.GetFileSpec().IsRelative()) {
-        const char *comp_dir =
-            die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr);
-        if (comp_dir) {
-          dwo_module_spec.GetFileSpec().SetFile(comp_dir,
-                                                FileSpec::Style::native);
-          FileSystem::Instance().Resolve(dwo_module_spec.GetFileSpec());
-          dwo_module_spec.GetFileSpec().AppendPathComponent(dwo_path);
-        }
-      }
-      dwo_module_spec.GetArchitecture() =
-          m_objfile_sp->GetModule()->GetArchitecture();
-
-      // When LLDB loads "external" modules it looks at the presence
-      // of DW_AT_dwo_name. However, when the already created module
-      // (corresponding to .dwo itself) is being processed, it will
-      // see the presence of DW_AT_dwo_name (which contains the name
-      // of dwo file) and will try to call ModuleList::GetSharedModule
-      // again. In some cases (i.e., for empty files) Clang 4.0
-      // generates a *.dwo file which has DW_AT_dwo_name, but no
-      // DW_AT_comp_dir. In this case the method
-      // ModuleList::GetSharedModule will fail and the warning will be
-      // printed. However, as one can notice in this case we don't
-      // actually need to try to load the already loaded module
-      // (corresponding to .dwo) so we simply skip it.
-      if (m_objfile_sp->GetFileSpec().GetFileNameExtension() == ".dwo" &&
-          llvm::StringRef(m_objfile_sp->GetFileSpec().GetPath())
-              .endswith(dwo_module_spec.GetFileSpec().GetPath())) {
-        continue;
-      }
+    if (!dwo_path)
+      continue;
 
-      Status error = ModuleList::GetSharedModule(dwo_module_spec, module_sp,
-                                                 nullptr, nullptr, nullptr);
-      if (!module_sp) {
-        GetObjectFile()->GetModule()->ReportWarning(
-            "0x%8.8x: unable to locate module needed for external types: "
-            "%s\nerror: %s\nDebugging will be degraded due to missing "
-            "types. Rebuilding your project will regenerate the needed "
-            "module files.",
-            die.GetOffset(), dwo_module_spec.GetFileSpec().GetPath().c_str(),
-            error.AsCString("unknown error"));
+    ModuleSpec dwo_module_spec;
+    dwo_module_spec.GetFileSpec().SetFile(dwo_path, FileSpec::Style::native);
+    if (dwo_module_spec.GetFileSpec().IsRelative()) {
+      const char *comp_dir =
+          die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr);
+      if (comp_dir) {
+        dwo_module_spec.GetFileSpec().SetFile(comp_dir,
+                                              FileSpec::Style::native);
+        FileSystem::Instance().Resolve(dwo_module_spec.GetFileSpec());
+        dwo_module_spec.GetFileSpec().AppendPathComponent(dwo_path);
       }
     }
+    dwo_module_spec.GetArchitecture() =
+        m_objfile_sp->GetModule()->GetArchitecture();
+
+    // When LLDB loads "external" modules it looks at the presence of
+    // DW_AT_dwo_name. However, when the already created module
+    // (corresponding to .dwo itself) is being processed, it will see
+    // the presence of DW_AT_dwo_name (which contains the name of dwo
+    // file) and will try to call ModuleList::GetSharedModule
+    // again. In some cases (i.e., for empty files) Clang 4.0
+    // generates a *.dwo file which has DW_AT_dwo_name, but no
+    // DW_AT_comp_dir. In this case the method
+    // ModuleList::GetSharedModule will fail and the warning will be
+    // printed. However, as one can notice in this case we don't
+    // actually need to try to load the already loaded module
+    // (corresponding to .dwo) so we simply skip it.
+    if (m_objfile_sp->GetFileSpec().GetFileNameExtension() == ".dwo" &&
+        llvm::StringRef(m_objfile_sp->GetFileSpec().GetPath())
+            .endswith(dwo_module_spec.GetFileSpec().GetPath())) {
+      continue;
+    }
+
+    Status error = ModuleList::GetSharedModule(dwo_module_spec, module_sp,
+                                               nullptr, nullptr, nullptr);
+    if (!module_sp) {
+      GetObjectFile()->GetModule()->ReportWarning(
+          "0x%8.8x: unable to locate module needed for external types: "
+          "%s\nerror: %s\nDebugging will be degraded due to missing "
+          "types. Rebuilding your project will regenerate the needed "
+          "module files.",
+          die.GetOffset(), dwo_module_spec.GetFileSpec().GetPath().c_str(),
+          error.AsCString("unknown error"));
+      continue;
+    }
   }
 }
 


        


More information about the lldb-commits mailing list