ronantakizawa/codereview-bench huggingface dataset:
Repository: llvm/llvm-project
File: libc/include/llvm-libc-types/struct_ipc_perm.h (C/C++)

Code before:
//===-- Definition of struct ipc_perm -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_TYPES_STRUCT_IPC_PERM_H
#define LLVM_LIBC_TYPES_STRUCT_IPC_PERM_H

#include "gid_t.h"
#include "key_t.h"
#include "uid_t.h"

#ifdef __linux__
struct ipc_perm {
  key_t __key;
  uid_t uid;
  gid_t gid;
  uid_t cuid;
  gid_t cgid;
  unsigned short mode;
  unsigned short seq;
  unsigned short padding;
  unsigned long unused_0;
  unsigned long unused_1;
};
#else
#error "ipc_perm not defined for the target platform"
#endif

#endif // LLVM_LIBC_TYPES_STRUCT_IPC_PERM_H


Review comment (suggestion):
Shouldn't this be `mode_t`? (https://man7.org/linux/man-pages/man0/sys_ipc.h.0p.html)

Also, I wonder why you need to specify the rest of the fields here (e.g. padding/unused).

Code after:
//===-- Definition of struct ipc_perm -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_TYPES_STRUCT_IPC_PERM_H
#define LLVM_LIBC_TYPES_STRUCT_IPC_PERM_H

#include "gid_t.h"
#include "key_t.h"
#include "mode_t.h"
#include "uid_t.h"

#ifdef __linux__
struct ipc_perm {
  key_t __key;
  uid_t uid;
  gid_t gid;
  uid_t cuid;
  gid_t cgid;
  mode_t mode;
  unsigned short __seq;
  unsigned short __padding;
  unsigned long __unused_0;
  unsigned long __unused_1;
};
#else
#error "ipc_perm not defined for the target platform"
#endif

#endif // LLVM_LIBC_TYPES_STRUCT_IPC_PERM_H
Repository: llvm/llvm-project
File: libc/src/sys/ipc/linux/ftok.cpp (C++)

Code before:
//===-- Linux implementation of ftok -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/sys/ipc/ftok.h"

#include "src/__support/common.h"
#include "src/sys/stat/stat.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(key_t, ftok, (const char *path, int id)) {

  // ftok implements based on stat
  struct stat st;
  if (LIBC_NAMESPACE::stat(path, &st) < 0)
    return -1;

  return static_cast<key_t>(((id & 0xff) << 24) |
                            ((static_cast<int>(st.st_dev) & 0xff) << 16) |
                            (static_cast<int>(st.st_ino) & 0xffff));
}

} // namespace LIBC_NAMESPACE_DECL


Review comment (refactor):
We should not be calling one public function from the implementation of a different public function. E.g. here you'll probably need to call `stat` syscall, instead of stat function.

@michaelrj-google has a pending refactor (https://discourse.llvm.org/t/rfc-linux-syscall-cleanup/87248) that would make it simpler.

Code after:
//===-- Linux implementation of ftok --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "src/sys/ipc/ftok.h"

#include "src/__support/common.h"
#include "src/__support/error_or.h"
#include "src/__support/libc_errno.h"

#include "kernel_statx.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(key_t, ftok, (const char *path, int id)) {
  struct statx xbuf;

  ErrorOr<int> err = statx_for_ftok(path, xbuf);

  if (!err.has_value()) {
    libc_errno = err.error();
    return -1;
  }

  // key layout based on user input and file stats metadata
  // 31            24              16             0
  // +-------------+---------------+--------------+
  // user input id + minor dev num + file inode num
  return static_cast<key_t>(
      ((id & 0xff) << 24) |
      ((static_cast<int>(xbuf.stx_dev_minor) & 0xff) << 16) |
      (static_cast<int>(xbuf.stx_ino) & 0xffff));
}

} // namespace LIBC_NAMESPACE_DECL
Repository: llvm/llvm-project
File: libc/src/sys/ipc/ftok.h (C/C++)

Code before:
//===-- Implementation header for ftok ---------------------------*- C++
//-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_SYS_IPC_FTOK_H
#define LLVM_LIBC_SRC_SYS_IPC_FTOK_H

#include "src/__support/macros/config.h"
#include <sys/ipc.h>

namespace LIBC_NAMESPACE_DECL {

key_t ftok(const char *path, int id);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_SYS_IPC_FTOK_H


Review comment (suggestion):
We shouldn't be including system headers. In this case, you'd probably need to declare a proxy header in `hdr/` to get the `key_t` type definition.

Code after:
//===-- Implementation header for ftok --------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_SYS_IPC_FTOK_H
#define LLVM_LIBC_SRC_SYS_IPC_FTOK_H

#include "hdr/types/key_t.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

key_t ftok(const char *path, int id);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_SYS_IPC_FTOK_H
Repository: llvm/llvm-project
File: libc/src/sys/ipc/linux/kernel_statx.h (C/C++)

Code before:
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_SYS_IPC_LINUX_KERNEL_STATX_H
#define LLVM_LIBC_SRC_SYS_IPC_LINUX_KERNEL_STATX_H

#include "hdr/fcntl_macros.h"
#include "src/__support/OSUtil/syscall.h"
#include "sys/syscall.h"

#include <linux/stat.h>

namespace LIBC_NAMESPACE_DECL {

LIBC_INLINE int statx_for_ftok(const char *path, struct statx &xbuf) {

  // store the file stats metadata into xbuf
  int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_statx, AT_FDCWD, path, 0,
                                              STATX_BASIC_STATS, &xbuf);

  if (ret < 0)
    return -ret;
  return 0;
}

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_SYS_IPC_LINUX_KERNEL_STATX_H


Review comment (suggestion):
Since it's an internal wrapper, I think the recommendation is to use `ErrorOr<int>` as a return value here, to make the error-handling logic transparent at the call site.

@michaelrj-google 

Code after:
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_SYS_IPC_LINUX_KERNEL_STATX_H
#define LLVM_LIBC_SRC_SYS_IPC_LINUX_KERNEL_STATX_H

#include "hdr/fcntl_macros.h"
#include "src/__support/OSUtil/syscall.h"
#include "src/__support/error_or.h"
#include "sys/syscall.h"

#include <linux/stat.h>

namespace LIBC_NAMESPACE_DECL {

LIBC_INLINE ErrorOr<int> statx_for_ftok(const char *path, struct statx &xbuf) {

  // store the file stats metadata into xbuf
  int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_statx, AT_FDCWD, path, 0,
                                              STATX_BASIC_STATS, &xbuf);

  if (ret < 0)
    return Error(-ret);
  return 0;
}

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_SYS_IPC_LINUX_KERNEL_STATX_H
Repository: llvm/llvm-project
File: clang/include/clang/DependencyScanning/InProcessModuleCache.h (C/C++)

Code before:
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_DEPENDENCYSCANNING_INPROCESSMODULECACHE_H
#define LLVM_CLANG_DEPENDENCYSCANNING_INPROCESSMODULECACHE_H

#include "clang/Serialization/ModuleCache.h"
#include "llvm/ADT/StringMap.h"

#include <atomic>
#include <mutex>
#include <shared_mutex>

namespace clang {
namespace dependencies {

struct ModuleCacheEntry {
  std::shared_mutex CompilationMutex;
  std::atomic<std::time_t> Timestamp = 0;
};

struct ModuleCacheEntries {
  std::mutex Mutex;
  llvm::StringMap<std::unique_ptr<ModuleCacheEntry>> Map;
};

std::shared_ptr<ModuleCache>
makeInProcessModuleCache(ModuleCacheEntries &Entries);

} // namespace dependencies
} // namespace clang

#endif // LLVM_CLANG_DEPENDENCYSCANNING_INPROCESSMODULECACHE_H

Review comment (suggestion):
This file should have inline documentation about when this implementation is used. This can be addressed in a separate PR. 

Code after:
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_DEPENDENCYSCANNING_INPROCESSMODULECACHE_H
#define LLVM_CLANG_DEPENDENCYSCANNING_INPROCESSMODULECACHE_H

#include "clang/Serialization/ModuleCache.h"
#include "llvm/ADT/StringMap.h"

#include <atomic>
#include <condition_variable>
#include <mutex>

namespace clang {
namespace dependencies {

struct ModuleCacheEntry {
  std::mutex Mutex;
  std::condition_variable CondVar;
  bool Locked = false;
  unsigned Generation = 0;

  std::atomic<std::time_t> Timestamp = 0;
};

struct ModuleCacheEntries {
  std::mutex Mutex;
  llvm::StringMap<std::unique_ptr<ModuleCacheEntry>> Map;
};

std::shared_ptr<ModuleCache>
makeInProcessModuleCache(ModuleCacheEntries &Entries);
Repository: llvm/llvm-project
File: llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp (C++)

Code before:
  const auto *ZExt = cast<ZExtInst>(I);

  const Value *Op = ZExt->getOperand(0);
  MVT::SimpleValueType From = getSimpleType(Op->getType());
  MVT::SimpleValueType To = getLegalType(getSimpleType(ZExt->getType()));
  Register In = getRegForValue(Op);
  if (In == 0)
    return false;
  unsigned Reg = zeroExtend(In, Op, From, To);
  if (Reg == 0)
    return false;

  updateValueMap(ZExt, Reg);
  return true;
}

bool WebAssemblyFastISel::selectSExt(const Instruction *I) {
  const auto *SExt = cast<SExtInst>(I);

  const Value *Op = SExt->getOperand(0);
  MVT::SimpleValueType From = getSimpleType(Op->getType());
  MVT::SimpleValueType To = getLegalType(getSimpleType(SExt->getType()));
  Register In = getRegForValue(Op);
  if (In == 0)
    return false;

  unsigned Reg = signExtend(In, Op, From, To);
  if (Reg == 0)
    return false;

  updateValueMap(SExt, Reg);
  return true;
}

bool WebAssemblyFastISel::selectICmp(const Instruction *I) {
  const auto *ICmp = cast<ICmpInst>(I);

  bool I32 = getSimpleType(ICmp->getOperand(0)->getType()) != MVT::i64;
  unsigned Opc;
  bool IsSigned = false;
  switch (ICmp->getPredicate()) {
  case ICmpInst::ICMP_EQ:
    Opc = I32 ? WebAssembly::EQ_I32 : WebAssembly::EQ_I64;
    break;
  case ICmpInst::ICMP_NE:
    Opc = I32 ? WebAssembly::NE_I32 : WebAssembly::NE_I64;
    break;
  case ICmpInst::ICMP_UGT:
    Opc = I32 ? WebAssembly::GT_U_I32 : WebAssembly::GT_U_I64;
    break;
  case ICmpInst::ICMP_UGE:

Review comment (suggestion):
Remove unrelated newline (probably leftover from earlier changes).
```suggestion
```

Code after:
  if (Reg == 0)
    return false;

  updateValueMap(ZExt, Reg);
  return true;
}

bool WebAssemblyFastISel::selectSExt(const Instruction *I) {
  const auto *SExt = cast<SExtInst>(I);

  const Value *Op = SExt->getOperand(0);
  MVT::SimpleValueType From = getSimpleType(Op->getType());
  MVT::SimpleValueType To = getLegalType(getSimpleType(SExt->getType()));
  Register In = getRegForValue(Op);
  if (In == 0)
    return false;
  unsigned Reg = signExtend(In, Op, From, To);
  if (Reg == 0)
    return false;

  updateValueMap(SExt, Reg);
  return true;
}

bool WebAssemblyFastISel::selectICmp(const Instruction *I) {
  const auto *ICmp = cast<ICmpInst>(I);

  bool I32 = getSimpleType(ICmp->getOperand(0)->getType()) != MVT::i64;
  unsigned Opc;
  bool IsSigned = false;
  switch (ICmp->getPredicate()) {
  case ICmpInst::ICMP_EQ:
    Opc = I32 ? WebAssembly::EQ_I32 : WebAssembly::EQ_I64;
    break;
  case ICmpInst::ICMP_NE:
    Opc = I32 ? WebAssembly::NE_I32 : WebAssembly::NE_I64;
    break;
  case ICmpInst::ICMP_UGT:
    Opc = I32 ? WebAssembly::GT_U_I32 : WebAssembly::GT_U_I64;
    break;
  case ICmpInst::ICMP_UGE:
    Opc = I32 ? WebAssembly::GE_U_I32 : WebAssembly::GE_U_I64;
    break;
  case ICmpInst::ICMP_ULT:
    Opc = I32 ? WebAssembly::LT_U_I32 : WebAssembly::LT_U_I64;
    break;
  case ICmpInst::ICMP_ULE:
    Opc = I32 ? WebAssembly::LE_U_I32 : WebAssembly::LE_U_I64;
    break;
  case ICmpInst::ICMP_SGT:
    Opc = I32 ? WebAssembly::GT_S_I32 : WebAssembly::GT_S_I64;
Repository: llvm/llvm-project
File: libsycl/src/detail/platform_impl.hpp (C++)

Code before:
  /// Calls "callback" with every root device of type == DeviceType associated
  /// with this platform
  void iterateDevices(info::device_type DeviceType,
                      std::function<void(DeviceImpl *)> callback) const;

  /// Returns all root devices for platform
  ///
  /// \return reference to collection of root devices
  const std::vector<DeviceImplUPtr> &getRootDevices() const;

  /// Returns context dummy (w/o liboffload handle) that represents all devices
  /// in platform.
  ///
  /// \return context implementation object
  ContextImpl &getDefaultContext();

private:
  const ol_platform_handle_t MOffloadPlatform{};
  const size_t MOffloadPlatformIndex{};

  ol_platform_backend_t MOffloadBackend;
  backend MBackend;

  std::vector<DeviceImplUPtr> MRootDevices;

  // To be redesigned  once liboffload supports context
  std::shared_ptr<ContextImpl> MDefaultContext;
};

} // namespace detail
_LIBSYCL_END_NAMESPACE_SYCL

#endif // _LIBSYCL_PLATFORM_IMPL


Review comment (suggestion):
```suggestion
  // FIXME: To be redesigned  once liboffload supports context
```
I see that LLVM sources use `// TODO:` or `// FIXME:` for this type of comments.

Code after:
  void iterateDevices(info::device_type DeviceType,
                      std::function<void(DeviceImpl *)> callback) const;

  // TODO: liboffload doesn't support context now, l0 plugin creates default
  // context for all devices on its level. This method should be removed or
  // reimplemented once native context support is added to liboffload.
  /// \return the default context that represents all devices in platform.
  ContextImpl &getDefaultContext();

private:
  /// \return reference to collection of root devices for platform
  const std::vector<DeviceImplUPtr> &getRootDevices() const;

  const ol_platform_handle_t MOffloadPlatform{};
  const size_t MOffloadPlatformIndex{};

  ol_platform_backend_t MOffloadBackend{OL_PLATFORM_BACKEND_UNKNOWN};
  backend MBackend{};

  std::vector<DeviceImplUPtr> MRootDevices;

  std::shared_ptr<ContextImpl> MDefaultContext;
};

} // namespace detail
_LIBSYCL_END_NAMESPACE_SYCL

#endif // _LIBSYCL_PLATFORM_IMPL
Repository: llvm/llvm-project
File: libsycl/include/sycl/__impl/context.hpp (C++)

Code before:
template <typename T>
using is_context_info_desc_t = typename is_info_desc<T, context>::return_type;
} // namespace detail

// SYCL 2020 4.6.3. Context class
class _LIBSYCL_EXPORT context {
public:
  context(const context &rhs) = default;

  context(context &&rhs) = default;

  context &operator=(const context &rhs) = default;

  context &operator=(context &&rhs) = default;

  friend bool operator==(const context &lhs, const context &rhs) {
    return lhs.impl == rhs.impl;
  }

  friend bool operator!=(const context &lhs, const context &rhs) {
    return !(lhs == rhs);
  }

  /// Returns the backend associated with this context.
  ///
  /// \return the backend associated with this context.
  backend get_backend() const noexcept;

  /// Gets platform associated with this SYCL context.
  ///
  /// \return a valid instance of SYCL platform.
  platform get_platform() const;

  /// Gets devices associated with this SYCL context.
  ///
  /// \return a vector of valid SYCL device instances.
  std::vector<device> get_devices() const;

  /// Queries this SYCL context for information.
  ///
  /// The return type depends on information being queried.
  template <typename Param>
  detail::is_context_info_desc_t<Param> get_info() const;

  /// Queries this SYCL context for SYCL backend-specific information.
  ///
  /// The return type depends on information being queried.
  template <typename Param>
  typename Param::return_type get_backend_info() const;

private:

Review comment (suggestion):
```suggestion
  /// \return the backend associated with this context.
```

Code after:
template <typename T>
using is_context_info_desc_t = typename is_info_desc<T, context>::return_type;
} // namespace detail

// SYCL 2020 4.6.3. Context class
class _LIBSYCL_EXPORT context {
public:
  context(const context &rhs) = default;

  context(context &&rhs) = default;

  context &operator=(const context &rhs) = default;

  context &operator=(context &&rhs) = default;

  friend bool operator==(const context &lhs, const context &rhs) {
    return lhs.impl == rhs.impl;
  }

  friend bool operator!=(const context &lhs, const context &rhs) {
    return !(lhs == rhs);
  }

  /// \return the backend associated with this context.
  backend get_backend() const noexcept;

  /// \return the platform associated with this SYCL context.
  platform get_platform() const;

  /// \return a vector of valid SYCL devices associated with this SYCL context.
  std::vector<device> get_devices() const;

  /// Queries this SYCL context for information.
  ///
  /// The return type depends on information being queried.
  template <typename Param>
  detail::is_context_info_desc_t<Param> get_info() const;

  /// Queries this SYCL context for SYCL backend-specific information.
  ///
  /// The return type depends on information being queried.
  template <typename Param>
  typename Param::return_type get_backend_info() const;

private:
  context(const std::shared_ptr<detail::ContextImpl> &Impl) : impl(Impl) {}
  std::shared_ptr<detail::ContextImpl> impl;

  friend sycl::detail::ImplUtils;
}; // class context
Repository: llvm/llvm-project
File: libsycl/src/detail/context_impl.cpp (C++)

Code before:
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <detail/context_impl.hpp>
#include <detail/platform_impl.hpp>

_LIBSYCL_BEGIN_NAMESPACE_SYCL

namespace detail {

void ContextImpl::iterateDevices(
    const std::function<void(DeviceImpl *)> &callback) const {
  // Intentionally don't store devices in context now. This class should be
  // reimplemented once liboffload adds context support. Treat context as
  // default context that is associated with all devices in the platform.
  return MPlatform.iterateDevices(info::device_type::all, callback);
}

backend ContextImpl::getBackend() const { return MPlatform.getBackend(); }

} // namespace detail
_LIBSYCL_END_NAMESPACE_SYCL


Review comment (suggestion):
```suggestion
  // FIXME: Intentionally don't store devices in context now. This class should be
  // reimplemented once liboffload adds context support. Treat context as
  // default context that is associated with all devices in the platform.
```

Code after:
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <detail/context_impl.hpp>
#include <detail/platform_impl.hpp>

_LIBSYCL_BEGIN_NAMESPACE_SYCL

namespace detail {

void ContextImpl::iterateDevices(
    const std::function<void(DeviceImpl *)> &callback) const {
  // TODO: Intentionally don't store devices in context now. This class should
  // be reimplemented once liboffload adds context support. Treat context as
  // default context that is associated with all devices in the platform.
  return MPlatform.iterateDevices(info::device_type::all, callback);
}

backend ContextImpl::getBackend() const { return MPlatform.getBackend(); }

} // namespace detail
_LIBSYCL_END_NAMESPACE_SYCL
Repository: llvm/llvm-project
File: libsycl/src/context.cpp (C++)

Code before:
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <sycl/__impl/device.hpp>

#include <detail/context_impl.hpp>
#include <detail/platform_impl.hpp>

_LIBSYCL_BEGIN_NAMESPACE_SYCL

backend context::get_backend() const noexcept { return impl->getBackend(); }

platform context::get_platform() const {
  return detail::createSyclObjFromImpl<platform>(impl->getPlatformImpl());
}

std::vector<device> context::get_devices() const {
  std::vector<device> Devices;

  impl->iterateDevices([&Devices](detail::DeviceImpl *DevImpl) {
    assert(DevImpl && "Device impl can't be nullptr");
    Devices.push_back(detail::createSyclObjFromImpl<device>(*DevImpl));
  });

  return Devices;
}

_LIBSYCL_END_NAMESPACE_SYCL


Review comment (suggestion):
```suggestion
#include <detail/platform_impl.hpp>

#include <vector>
#include <cassert>
```

Code after:
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <sycl/__impl/device.hpp>

#include <detail/context_impl.hpp>
#include <detail/platform_impl.hpp>

#include <cassert>

_LIBSYCL_BEGIN_NAMESPACE_SYCL

backend context::get_backend() const noexcept { return impl->getBackend(); }

platform context::get_platform() const {
  return detail::createSyclObjFromImpl<platform>(impl->getPlatformImpl());
}

std::vector<device> context::get_devices() const {
  std::vector<device> Devices;

  impl->iterateDevices([&Devices](detail::DeviceImpl *DevImpl) {
    assert(DevImpl && "Device impl can't be nullptr");
    Devices.push_back(detail::createSyclObjFromImpl<device>(*DevImpl));
  });

  return Devices;
}

_LIBSYCL_END_NAMESPACE_SYCL