Hash :
f8ce4a01
Author :
Date :
2025-08-26T18:18:54
Add src/common/unsafe_buffers.h Allow for line-by-line control of unsafe buffers warnings. Bug: b/436880895 Change-Id: I609d60c83611037f39d541d5b8c9aba98a6656a7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6886308 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Auto-Submit: Tom Sepez <tsepez@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
//
// Copyright 2025 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// unsafe_buffers.h: exempts code from unsafe buffers warnings. Based upon
// https://source.chromium.org/chromium/chromium/src/+/main:base/compiler_specific.h
#ifndef COMMON_UNSAFE_BUFFERS_H_
#define COMMON_UNSAFE_BUFFERS_H_
#if defined(__clang__) && defined(__has_attribute)
# if __has_attribute(unsafe_buffer_usage)
# define ANGLE_UNSAFE_BUFFER_USAGE [[clang::unsafe_buffer_usage]]
# endif
#endif
#if !defined(ANGLE_UNSAFE_BUFFER_USAGE)
# define ANGLE_UNSAFE_BUFFER_USAGE
#endif
// Formatting is off so that we can put each _Pragma on its own line.
// clang-format off
#if defined(UNSAFE_BUFFERS_BUILD)
# define ANGLE_UNSAFE_BUFFERS(...) \
_Pragma("clang unsafe_buffer_usage begin") \
__VA_ARGS__ \
_Pragma("clang unsafe_buffer_usage end")
#else
# define ANGLE_UNSAFE_BUFFERS(...) __VA_ARGS__
#endif
// clang-format on
// Like ANGLE_UNSAFE_BUFFERS(), but indicates there is a TODO() task.
#define ANGLE_UNSAFE_TODO(...) ANGLE_UNSAFE_BUFFERS(__VA_ARGS__)
#endif // COMMON_UNSAFE_BUFFERS_H_