CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
67 lines
2.5 KiB
C++
67 lines
2.5 KiB
C++
// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-optional-value-conversion %t
|
|
|
|
namespace std {
|
|
template <typename T> struct optional {
|
|
constexpr optional() noexcept;
|
|
constexpr optional(T &&) noexcept;
|
|
constexpr optional(const T &) noexcept;
|
|
template <typename U> constexpr optional(U &&) noexcept;
|
|
const T &operator*() const;
|
|
T *operator->();
|
|
const T *operator->() const;
|
|
T &operator*();
|
|
const T &value() const;
|
|
T &value();
|
|
const T &get() const;
|
|
T &get();
|
|
T value_or(T) const;
|
|
};
|
|
|
|
template <class T> T &&move(T &x) { return static_cast<T &&>(x); }
|
|
|
|
template <typename T> class default_delete {};
|
|
|
|
template <typename type, typename Deleter = std::default_delete<type>>
|
|
class unique_ptr {};
|
|
|
|
template <typename type>
|
|
class shared_ptr {};
|
|
|
|
template <typename T>
|
|
class initializer_list {};
|
|
|
|
template <class T, class... Args> unique_ptr<T> make_unique(Args &&...args);
|
|
template <class T, class... Args> shared_ptr<T> make_shared(Args &&...args);
|
|
|
|
template <class T>
|
|
constexpr std::optional<__decay(T)> make_optional(T &&value);
|
|
template <class T, class... Args>
|
|
constexpr std::optional<T> make_optional(Args &&...args);
|
|
template <class T, class U, class... Args>
|
|
constexpr std::optional<T> make_optional(std::initializer_list<U> il, Args &&...args);
|
|
|
|
} // namespace std
|
|
|
|
struct A {
|
|
explicit A (int);
|
|
};
|
|
std::optional<int> opt;
|
|
|
|
void invalid() {
|
|
std::make_unique<std::optional<int>>(opt.value());
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: conversion from 'std::optional<int>' into 'int' and back into 'std::optional<int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
|
|
using A = std::optional<int>;
|
|
std::make_unique<A>(opt.value());
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: conversion from 'std::optional<int>' into 'int' and back into 'std::optional<int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
|
|
std::make_shared<std::optional<int>>(opt.value());
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: conversion from 'std::optional<int>' into 'int' and back into 'std::optional<int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
|
|
std::make_optional(opt.value());
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: conversion from 'std::optional<int>' into 'int' and back into 'std::optional<int>', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
|
|
}
|
|
|
|
void valid() {
|
|
std::make_unique<A>(opt.value());
|
|
std::make_shared<A>(opt.value());
|
|
std::make_optional<int>(opt.value());
|
|
}
|