Commit 6ab77aa9 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

qrt_mapper to provide fallback information for InstVisitor<Circuit> cast



This is known to have problem in the MacOS build.

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 6ee30259
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -54,6 +54,19 @@ public:
      : kernelName(top_level_kernel_name) {}
  qrt_mapper() = default;

  // Workaround cross-boundary (dlopen) dynamic type-casting issue (Apple Clang)
  // Construct the RTTI pointer offset map as fallback for dynamic_cast.
  virtual std::unordered_map<std::string, ptrdiff_t>
  getVisitorRttiMap() const override {
    // Currently, looks like only xacc::InstructionVisitor<Circuit> is having
    // this issue, but, technically, we can add all types here if needed to.
    static const std::unordered_map<std::string, ptrdiff_t> result{
        {typeid(Circuit).name(),
         ComputePointerOffset<qrt_mapper,
                              xacc::InstructionVisitor<Circuit>>()}};
    return result;
  }

  auto get_new_src() { return ss.str(); }
  // One-qubit gates
  void visit(Hadamard &h) override { addOneQubitGate("h", h); }