mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 11:55:01 +01:00
Note that ptr.h also includes an enable_if change, to help avoid https://bugs.llvm.org/show_bug.cgi?id=51881
24 lines
776 B
C++
24 lines
776 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef EXECUTABLE_SEMANTICS_COMMON_PTR_H_
|
|
#define EXECUTABLE_SEMANTICS_COMMON_PTR_H_
|
|
|
|
#include <type_traits>
|
|
|
|
namespace Carbon {
|
|
|
|
// A non-nullable pointer. Written as `Nonnull<T*>` instead of `T*`.
|
|
//
|
|
// Note LLVM primarily enforces the attribute on function calls that can be
|
|
// proven to be called with nullptr; in other places, this is essentially a
|
|
// comment.
|
|
template <typename T,
|
|
typename std::enable_if_t<std::is_pointer_v<T>>* = nullptr>
|
|
using Nonnull = T _Nonnull __attribute__((nonnull));
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // EXECUTABLE_SEMANTICS_COMMON_PTR_H_
|