[Lldb-commits] [PATCH] D136890: [lldb-vscode] Don't call SBValue.GetError after generating a summary.

Jorge Gorbe Moya via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 27 15:06:01 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG7d4d25c42a68: [lldb-vscode] Don't call SBValue.GetError after generating a summary. (authored by jgorbe).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136890/new/

https://reviews.llvm.org/D136890

Files:
  lldb/tools/lldb-vscode/JSONUtils.cpp


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===================================================================
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -132,27 +132,28 @@
 
 void SetValueForKey(lldb::SBValue &v, llvm::json::Object &object,
                     llvm::StringRef key) {
-
-  llvm::StringRef value = v.GetValue();
-  llvm::StringRef summary = v.GetSummary();
-  llvm::StringRef type_name = v.GetType().GetDisplayTypeName();
-  lldb::SBError error = v.GetError();
-
   std::string result;
   llvm::raw_string_ostream strm(result);
+
+  lldb::SBError error = v.GetError();
   if (!error.Success()) {
     strm << "<error: " << error.GetCString() << ">";
-  } else if (!value.empty()) {
-    strm << value;
-    if (!summary.empty())
+  } else {
+    llvm::StringRef value = v.GetValue();
+    llvm::StringRef summary = v.GetSummary();
+    llvm::StringRef type_name = v.GetType().GetDisplayTypeName();
+    if (!value.empty()) {
+      strm << value;
+      if (!summary.empty())
+        strm << ' ' << summary;
+    } else if (!summary.empty()) {
       strm << ' ' << summary;
-  } else if (!summary.empty()) {
-    strm << ' ' << summary;
-  } else if (!type_name.empty()) {
-    strm << type_name;
-    lldb::addr_t address = v.GetLoadAddress();
-    if (address != LLDB_INVALID_ADDRESS)
-      strm << " @ " << llvm::format_hex(address, 0);
+    } else if (!type_name.empty()) {
+      strm << type_name;
+      lldb::addr_t address = v.GetLoadAddress();
+      if (address != LLDB_INVALID_ADDRESS)
+        strm << " @ " << llvm::format_hex(address, 0);
+    }
   }
   strm.flush();
   EmplaceSafeString(object, key, result);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136890.471301.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221027/2fdad8dc/attachment.bin>


More information about the lldb-commits mailing list