================
@@ -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 =
----------------
ashgti wrote:

I think that may run into issues with the c++ type system since the type is 
just a typedef like `typedef uint64_t addr_t;` I think c++ doesn't make a 
distinction between other `uint64_t` types and `addr_t`. I could be wrong on 
that though, but that may be an an issue with generalizing this to much.

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