[Lldb-commits] [lldb] 107200a - [lldb][nfc] early exit/continue

Konrad Kleine via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 3 05:51:38 PDT 2020


Author: Konrad Kleine
Date: 2020-04-03T14:50:08+02:00
New Revision: 107200ae0a032f2e6024f45d665a0f2b7c732a62

URL: https://github.com/llvm/llvm-project/commit/107200ae0a032f2e6024f45d665a0f2b7c732a62
DIFF: https://github.com/llvm/llvm-project/commit/107200ae0a032f2e6024f45d665a0f2b7c732a62.diff

LOG: [lldb][nfc] early exit/continue

Summary:
This commit just tries to invert some `if`'s logic to
`return`/`continue` early.

Reviewers: jankratochvil, teemperor

Reviewed By: jankratochvil, teemperor

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77377

Added: 
    

Modified: 
    lldb/source/Breakpoint/BreakpointResolverName.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 2eb0d3ab5888..25f5bb3f6eed 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -332,65 +332,66 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
 
   // Remove any duplicates between the function list and the symbol list
   SymbolContext sc;
-  if (func_list.GetSize()) {
-    for (uint32_t i = 0; i < func_list.GetSize(); i++) {
-      if (func_list.GetContextAtIndex(i, sc)) {
-        bool is_reexported = false;
-
-        if (sc.block && sc.block->GetInlinedFunctionInfo()) {
-          if (!sc.block->GetStartAddress(break_addr))
-            break_addr.Clear();
-        } else if (sc.function) {
-          break_addr = sc.function->GetAddressRange().GetBaseAddress();
-          if (m_skip_prologue && break_addr.IsValid()) {
-            const uint32_t prologue_byte_size =
-                sc.function->GetPrologueByteSize();
-            if (prologue_byte_size)
-              break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
-          }
-        } else if (sc.symbol) {
-          if (sc.symbol->GetType() == eSymbolTypeReExported) {
-            const Symbol *actual_symbol =
-                sc.symbol->ResolveReExportedSymbol(breakpoint.GetTarget());
-            if (actual_symbol) {
-              is_reexported = true;
-              break_addr = actual_symbol->GetAddress();
-            }
-          } else {
-            break_addr = sc.symbol->GetAddress();
-          }
-
-          if (m_skip_prologue && break_addr.IsValid()) {
-            const uint32_t prologue_byte_size =
-                sc.symbol->GetPrologueByteSize();
-            if (prologue_byte_size)
-              break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
-            else {
-              const Architecture *arch =
-                  breakpoint.GetTarget().GetArchitecturePlugin();
-              if (arch)
-                arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
-            }
-          }
+  if (!func_list.GetSize())
+    return Searcher::eCallbackReturnContinue;
+
+  for (uint32_t i = 0; i < func_list.GetSize(); i++) {
+    if (!func_list.GetContextAtIndex(i, sc))
+      continue;
+
+    bool is_reexported = false;
+
+    if (sc.block && sc.block->GetInlinedFunctionInfo()) {
+      if (!sc.block->GetStartAddress(break_addr))
+        break_addr.Clear();
+    } else if (sc.function) {
+      break_addr = sc.function->GetAddressRange().GetBaseAddress();
+      if (m_skip_prologue && break_addr.IsValid()) {
+        const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
+        if (prologue_byte_size)
+          break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+      }
+    } else if (sc.symbol) {
+      if (sc.symbol->GetType() == eSymbolTypeReExported) {
+        const Symbol *actual_symbol =
+            sc.symbol->ResolveReExportedSymbol(breakpoint.GetTarget());
+        if (actual_symbol) {
+          is_reexported = true;
+          break_addr = actual_symbol->GetAddress();
         }
+      } else {
+        break_addr = sc.symbol->GetAddress();
+      }
 
-        if (break_addr.IsValid()) {
-          if (filter.AddressPasses(break_addr)) {
-            bool new_location;
-            BreakpointLocationSP bp_loc_sp(
-                AddLocation(break_addr, &new_location));
-            bp_loc_sp->SetIsReExported(is_reexported);
-            if (bp_loc_sp && new_location && !breakpoint.IsInternal()) {
-              if (log) {
-                StreamString s;
-                bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
-                LLDB_LOGF(log, "Added location: %s\n", s.GetData());
-              }
-            }
-          }
+      if (m_skip_prologue && break_addr.IsValid()) {
+        const uint32_t prologue_byte_size = sc.symbol->GetPrologueByteSize();
+        if (prologue_byte_size)
+          break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+        else {
+          const Architecture *arch =
+              breakpoint.GetTarget().GetArchitecturePlugin();
+          if (arch)
+            arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
         }
       }
     }
+
+    if (!break_addr.IsValid())
+      continue;
+
+    if (!filter.AddressPasses(break_addr))
+      continue;
+
+    bool new_location;
+    BreakpointLocationSP bp_loc_sp(AddLocation(break_addr, &new_location));
+    bp_loc_sp->SetIsReExported(is_reexported);
+    if (bp_loc_sp && new_location && !breakpoint.IsInternal()) {
+      if (log) {
+        StreamString s;
+        bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
+        LLDB_LOGF(log, "Added location: %s\n", s.GetData());
+      }
+    }
   }
 
   return Searcher::eCallbackReturnContinue;


        


More information about the lldb-commits mailing list