Lagrange
warning.h
1
/*
2
* Copyright 2020 Adobe. All rights reserved.
3
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License. You may obtain a copy
5
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6
*
7
* Unless required by applicable law or agreed to in writing, software distributed under
8
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
* OF ANY KIND, either express or implied. See the License for the specific language
10
* governing permissions and limitations under the License.
11
*/
12
#pragma once
13
29
30
// clang-format off
31
33
#if defined(__clang__)
34
#define LA_PRAGMA(X) _Pragma(#X)
35
#define LA_DISABLE_WARNING_BEGIN LA_PRAGMA(clang diagnostic push)
36
#define LA_DISABLE_WARNING_END LA_PRAGMA(clang diagnostic pop)
37
#define LA_DISABLE_WARNING_CLANG(warning_name) LA_PRAGMA(clang diagnostic ignored #warning_name)
38
#define LA_DISABLE_WARNING_GCC(warning_name)
39
#define LA_DISABLE_WARNING_MSVC(warning_number)
40
#define LA_NOSANITIZE_SIGNED_INTEGER_OVERFLOW __attribute__((no_sanitize("signed-integer-overflow"
)))
41
#elif defined(__GNUC__)
42
#define LA_PRAGMA(X) _Pragma(#X)
43
#define LA_DISABLE_WARNING_BEGIN LA_PRAGMA(GCC diagnostic push)
44
#define LA_DISABLE_WARNING_END LA_PRAGMA(GCC diagnostic pop)
45
#define LA_DISABLE_WARNING_CLANG(warning_name)
46
#define LA_DISABLE_WARNING_GCC(warning_name) LA_PRAGMA(GCC diagnostic ignored #warning_name)
47
#define LA_DISABLE_WARNING_MSVC(warning_number)
48
#define LA_NOSANITIZE_SIGNED_INTEGER_OVERFLOW
49
#elif defined(_MSC_VER)
50
#define LA_DISABLE_WARNING_BEGIN __pragma(warning(push))
51
#define LA_DISABLE_WARNING_END __pragma(warning(pop))
52
#define LA_DISABLE_WARNING_CLANG(warning_name)
53
#define LA_DISABLE_WARNING_GCC(warning_name)
54
#define LA_DISABLE_WARNING_MSVC(warning_number) __pragma(warning( disable : warning_number ))
55
#define LA_NOSANITIZE_SIGNED_INTEGER_OVERFLOW
56
#else
57
#define LA_DISABLE_WARNING_BEGIN
58
#define LA_DISABLE_WARNING_END
59
#define LA_DISABLE_WARNING_CLANG(warning_name)
60
#define LA_DISABLE_WARNING_GCC(warning_name)
61
#define LA_DISABLE_WARNING_MSVC(warning_number)
62
#define LA_NOSANITIZE_SIGNED_INTEGER_OVERFLOW
63
#endif
65
68
#define LA_IGNORE_SHADOW_WARNING_BEGIN LA_DISABLE_WARNING_BEGIN \
69
LA_DISABLE_WARNING_CLANG(-Wshadow) \
70
LA_DISABLE_WARNING_GCC(-Wshadow)
72
#define LA_IGNORE_SHADOW_WARNING_END LA_DISABLE_WARNING_END
73
76
#define LA_IGNORE_DEPRECATION_WARNING_BEGIN LA_DISABLE_WARNING_BEGIN \
77
LA_DISABLE_WARNING_CLANG(-Wdeprecated-declarations) \
78
LA_DISABLE_WARNING_GCC(-Wdeprecated-declarations) \
79
LA_DISABLE_WARNING_MSVC(4996)
81
#define LA_IGNORE_DEPRECATION_WARNING_END LA_DISABLE_WARNING_END
82
85
#define LA_IGNORE_UNUSED_TYPEDEF_BEGIN LA_DISABLE_WARNING_BEGIN \
86
LA_DISABLE_WARNING_CLANG(-Wunused-local-typedefs) \
87
LA_DISABLE_WARNING_GCC(-Wunused-local-typedefs)
89
#define LA_IGNORE_UNUSED_TYPEDEF_END LA_DISABLE_WARNING_END
90
93
#define LA_IGNORE_EXIT_TIME_DTOR_WARNING_BEGIN LA_DISABLE_WARNING_BEGIN \
94
LA_DISABLE_WARNING_CLANG(-Wexit-time-destructors)
96
#define LA_IGNORE_EXIT_TIME_DTOR_WARNING_END LA_DISABLE_WARNING_END
97
100
#define LA_IGNORE_DOCUMENTATION_WARNING_BEGIN LA_DISABLE_WARNING_BEGIN \
101
LA_DISABLE_WARNING_CLANG(-Wdocumentation)
103
#define LA_IGNORE_DOCUMENTATION_WARNING_END LA_DISABLE_WARNING_END
104
107
#define LA_IGNORE_SELF_ASSIGN_WARNING_BEGIN LA_DISABLE_WARNING_BEGIN \
108
LA_DISABLE_WARNING_CLANG(-Wself-assign-overloaded)
110
#define LA_IGNORE_SELF_ASSIGN_WARNING_END LA_DISABLE_WARNING_END
111
114
#if defined(__GNUC__) && __GNUC__ >= 13
115
// -Wself-move is introduced in GCC 13.
116
#define LA_IGNORE_SELF_MOVE_GCC LA_DISABLE_WARNING_GCC(-Wself-move)
117
#else
118
#define LA_IGNORE_SELF_MOVE_GCC
119
#endif
121
#define LA_IGNORE_SELF_MOVE_WARNING_BEGIN LA_DISABLE_WARNING_BEGIN \
122
LA_DISABLE_WARNING_CLANG(-Wself-move) \
123
LA_IGNORE_SELF_MOVE_GCC \
124
LA_DISABLE_WARNING_MSVC(26800)
126
#define LA_IGNORE_SELF_MOVE_WARNING_END LA_DISABLE_WARNING_END
127
130
#define LA_IGNORE_SWITCH_ENUM_WARNING_BEGIN LA_DISABLE_WARNING_BEGIN \
131
LA_DISABLE_WARNING_CLANG(-Wswitch-enum)
133
#define LA_IGNORE_SWITCH_ENUM_WARNING_END LA_DISABLE_WARNING_END
134
137
#define LA_IGNORE_NONVOID_NORETURN_WARNING_BEGIN LA_DISABLE_WARNING_BEGIN \
138
LA_DISABLE_WARNING_MSVC(4646)
140
#define LA_IGNORE_NONVOID_NORETURN_WARNING_END LA_DISABLE_WARNING_END
141
144
#define LA_IGNORE(x) (void)x
145
148
#define LA_IGNORE_RANGE_LOOP_ANALYSIS_BEGIN LA_DISABLE_WARNING_BEGIN \
149
LA_DISABLE_WARNING_CLANG(-Wrange-loop-analysis)
151
#define LA_IGNORE_RANGE_LOOP_ANALYSIS_END LA_DISABLE_WARNING_END
152
157
#define LA_IGNORE_ARRAY_BOUNDS_BEGIN LA_DISABLE_WARNING_BEGIN \
158
LA_DISABLE_WARNING_GCC(-Warray-bounds)
159
LA_DISABLE_WARNING_GCC(-Wstringop-overread)
161
#define LA_IGNORE_ARRAY_BOUNDS_END LA_DISABLE_WARNING_END
162
163
// clang-format on
164
lagrange
utils
warning.h
Generated by
1.9.4