[Lldb-commits] [lldb] 6f1ce04 - [lldb] BreakpointResolver::CreateFromStructuredData Gardening (NFC)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 16 10:38:13 PST 2022


Author: Jonas Devlieghere
Date: 2022-02-16T10:38:05-08:00
New Revision: 6f1ce046fdd02458fe2e3824b865ba4bdf129d67

URL: https://github.com/llvm/llvm-project/commit/6f1ce046fdd02458fe2e3824b865ba4bdf129d67
DIFF: https://github.com/llvm/llvm-project/commit/6f1ce046fdd02458fe2e3824b865ba4bdf129d67.diff

LOG: [lldb] BreakpointResolver::CreateFromStructuredData Gardening (NFC)

 - Use an early return.
 - Check for error.Fail() instead of !error.Success().
 - Check the resolver pointer before using instead of relying on the
   error being set.

Added: 
    

Modified: 
    lldb/source/Breakpoint/BreakpointResolver.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp
index 2443befcbfb42..71cbb2b2c6668 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -109,8 +109,7 @@ BreakpointResolverSP BreakpointResolver::CreateFromStructuredData(
     return result_sp;
   }
 
-  BreakpointResolver *resolver;
-
+  BreakpointResolver *resolver = nullptr;
   switch (resolver_type) {
   case FileLineResolver:
     resolver = BreakpointResolverFileLine::CreateFromStructuredData(
@@ -139,13 +138,12 @@ BreakpointResolverSP BreakpointResolver::CreateFromStructuredData(
     llvm_unreachable("Should never get an unresolvable resolver type.");
   }
 
-  if (!error.Success()) {
+  if (!resolver || error.Fail())
     return result_sp;
-  } else {
-    // Add on the global offset option:
-    resolver->SetOffset(offset);
-    return BreakpointResolverSP(resolver);
-  }
+
+  // Add on the global offset option:
+  resolver->SetOffset(offset);
+  return BreakpointResolverSP(resolver);
 }
 
 StructuredData::DictionarySP BreakpointResolver::WrapOptionsDict(


        


More information about the lldb-commits mailing list