Exemplo n.º 1
0
  /// \brief Get the function address of the wrapper of the destructor.
  void* Value::GetDtorWrapperPtr(const clang::RecordDecl* RD) const {
    std::string funcname;
    {
      llvm::raw_string_ostream namestr(funcname);
      namestr << "__cling_StoredValue_Destruct_" << RD;
    }

    // Check whether the function exists before calling
    // utils::TypeName::GetFullyQualifiedName which is expensive
    // (memory-wise). See ROOT-6909.
    std::string code;
    if (!m_Interpreter->getAddressOfGlobal(funcname)) {
      code = "extern \"C\" void ";
      clang::QualType RDQT(RD->getTypeForDecl(), 0);
      std::string typeName
        = utils::TypeName::GetFullyQualifiedName(RDQT, RD->getASTContext());
      std::string dtorName = RD->getNameAsString();
      code += funcname + "(void* obj){((" + typeName + "*)obj)->~"
        + dtorName + "();}";
    }
    // else we have an empty code string - but the function alreday exists
    // so we'll be fine and take the existing one (ifUniq = true).

    return m_Interpreter->compileFunction(funcname, code, true /*ifUniq*/,
                                          false /*withAccessControl*/);
  }
Exemplo n.º 2
0
/// \brief Get the function address of the wrapper of the destructor.
void* Value::GetDtorWrapperPtr(const clang::RecordDecl* RD,
                               Interpreter& interp) const {
  std::string funcname;
  {
    llvm::raw_string_ostream namestr(funcname);
    namestr << "__cling_StoredValue_Destruct_" << RD;
  }

  std::string code("extern \"C\" void ");
  {
    clang::QualType RDQT(RD->getTypeForDecl(), 0);
    std::string typeName
      = utils::TypeName::GetFullyQualifiedName(RDQT, RD->getASTContext());
    std::string dtorName = RD->getNameAsString();
    code += funcname + "(void* obj){((" + typeName + "*)obj)->~"
      + dtorName + "();}";
  }

  return interp.compileFunction(funcname, code, true /*ifUniq*/,
                                false /*withAccessControl*/);
}