================
@@ -782,4 +785,89 @@ bool fromJSON(const llvm::json::Value &Params, 
InstructionBreakpoint &IB,
          O.mapOptional("mode", IB.mode);
 }
 
+bool fromJSON(const llvm::json::Value &Params,
+              DisassembledInstruction::PresentationHint &PH,
+              llvm::json::Path P) {
+  auto rawHint = Params.getAsString();
+  if (!rawHint) {
+    P.report("expected a string");
+    return false;
+  }
+  std::optional<DisassembledInstruction::PresentationHint> hint =
+      StringSwitch<std::optional<DisassembledInstruction::PresentationHint>>(
+          *rawHint)
+          .Case("normal", DisassembledInstruction::
+                              eDisassembledInstructionPresentationHintNormal)
+          .Case("invalid", DisassembledInstruction::
+                               eDisassembledInstructionPresentationHintInvalid)
+          .Default(std::nullopt);
+  if (!hint) {
+    P.report("unexpected value");
+    return false;
+  }
+  PH = *hint;
+  return true;
+}
+
+llvm::json::Value toJSON(const DisassembledInstruction::PresentationHint &PH) {
+  switch (PH) {
+  case DisassembledInstruction::eDisassembledInstructionPresentationHintNormal:
+    return "normal";
+  case 
DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid:
+    return "invalid";
+  }
+  llvm_unreachable("unhandled presentation hint.");
+}
+
+bool fromJSON(const llvm::json::Value &Params, DisassembledInstruction &DI,
+              llvm::json::Path P) {
+  std::optional<llvm::StringRef> raw_address =
----------------
JDevlieghere wrote:

I think the current approach of special casing this per request is fine because 
it forces us to think about the representation. Also `addr_t` is just a typedef 
for `uint64_t` so adding an overload would require a separate type.

https://github.com/llvm/llvm-project/pull/140482
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to