File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // Copyright 2025 The ANGLE Project Authors. All rights reserved.
3+ // Use of this source code is governed by a BSD-style license that can be
4+ // found in the LICENSE file.
5+ //
6+
7+ // unsafe_buffers.h: exempts code from unsafe buffers warnings. Based upon
8+ // https://source.chromium.org/chromium/chromium/src/+/main:base/compiler_specific.h
9+
10+ #ifndef COMMON_UNSAFE_BUFFERS_H_
11+ #define COMMON_UNSAFE_BUFFERS_H_
12+
13+ #if defined(__clang__ ) && defined(__has_attribute )
14+ # if __has_attribute (unsafe_buffer_usage )
15+ # define ANGLE_UNSAFE_BUFFER_USAGE [[clang::unsafe_buffer_usage]]
16+ # endif
17+ #endif
18+ #if !defined(ANGLE_UNSAFE_BUFFER_USAGE )
19+ # define ANGLE_UNSAFE_BUFFER_USAGE
20+ #endif
21+
22+ // Formatting is off so that we can put each _Pragma on its own line.
23+ // clang-format off
24+ #if defined(UNSAFE_BUFFERS_BUILD )
25+ # define ANGLE_UNSAFE_BUFFERS (...) \
26+ _Pragma("clang unsafe_buffer_usage begin") \
27+ __VA_ARGS__ \
28+ _Pragma("clang unsafe_buffer_usage end")
29+ #else
30+ # define ANGLE_UNSAFE_BUFFERS (...) __VA_ARGS__
31+ #endif
32+ // clang-format on
33+
34+ // Like ANGLE_UNSAFE_BUFFERS(), but indicates there is a TODO() task.
35+ #define ANGLE_UNSAFE_TODO (...) ANGLE_UNSAFE_BUFFERS(__VA_ARGS__)
36+
37+ #endif // COMMON_UNSAFE_BUFFERS_H_
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ libangle_common_headers = [
6363 " src/common/system_utils.h" ,
6464 " src/common/tls.h" ,
6565 " src/common/uniform_type_info_autogen.h" ,
66+ " src/common/unsafe_buffers.h" ,
6667 " src/common/utilities.h" ,
6768 " src/common/vector_utils.h" ,
6869 " src/libANGLE/CLBitField.h" ,
You can’t perform that action at this time.
0 commit comments