mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 06:20:11 +01:00
Only the special nullability attributes (`_Nonnull`) work correctly through type aliases like we're using with `Ptr`. But they aren't strictly UB and so have to be specially enabled in our sanitizer config in order to usefully catch nullness errors early. Turn on those sanitizers as well. Also, now that we are using fully remote build output caching for our CI and not trying to squeeze under an arbitrary size limit, re-enable the nice error messages for all the UBSan checks. Note that this will have a (very) slow CI run as it will have to recompile ~everything and upload fresh artifacts. But those should then be effective cache hits going forward.
23 lines
746 B
C++
23 lines
746 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*`.
|
|
//
|
|
// Sanitizers enforce this dynamically on assignment, return, and when passing
|
|
// as an argument. Static analysis will also track erroneous uses of `nullptr`.
|
|
template <typename T,
|
|
typename std::enable_if_t<std::is_pointer_v<T>>* = nullptr>
|
|
using Nonnull = T _Nonnull;
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // EXECUTABLE_SEMANTICS_COMMON_PTR_H_
|