80// NOTE: We use a double operator not here to avoid issues with passing certain class objects directly into __analysis_assume (which may cause a bogus compiler warning)
84// Does a simple 'if (Condition)', but disables warnings about using constants in the condition. Helps with some macro expansions.
85 #define CA_CONSTANT_IF(Condition) __pragma(warning(push)) __pragma(warning(disable:6326)) if (Condition) __pragma(warning(pop))
86
87
88//
89// Disable some code analysis warnings that we are NEVER interested in
90//
91
92// NOTE: Please be conservative about adding new suppressions here! If you add a suppression, please
93// add a comment that explains the rationale.
94
95// We don't use exceptions or care to gracefully handle _alloca() failure. Also, we wrap _alloca in an
96// appAlloca macro (not inline methods) and don't want to suppress at all call sites.
97 #pragma warning(disable : 6255) // warning C6255: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead.
98
99// This a very common false positive warning (but some cases are not false positives!). Disabling for now so that we
100// can more quickly see the benefits of static analysis on new code.
101 #pragma warning(disable : 6102) // warning C6102: Using 'variable' from failed function call at line 'line'.
102
103// We use this exception handler in Windows code, it may be worth a closer look, but disabling for now
104// so we can get the benefits of analysis on cross-platform code sooner.
105 #pragma warning(disable : 6320) // warning C6320: Exception-filter expression is the constant EXCEPTION_EXECUTE_HANDLER. This might mask exceptions that were not intended to be handled.
106
107// Branching on constants allows us to ensure code paths compile even if they are inactive (eg. if(PLATFORM_FOO){ ... }), and is good practice that should not be discouraged.
108 #pragma warning(disable : 6326) // warning C6326 : Potential comparison of a constant with another constant.
109
110// Likewise, expressions involving constants can also be valuable to check code paths compile.
111 #pragma warning(disable : 6240) // warning C6240 : (<expression> && <non-zero constant>) always evaluates to the result of <expression>. Did you intend to use the bitwise-and operator?
112
113// This is a warning that a static array is exactly 365 members long. We get false positives because our code gen can make arrays exactly this size.
114// EX: 365 properties in a UObject will auto gen a table exactly this long.
115 #pragma warning(disable : 6393) // warning C6393: A lookup table of size 365 is not sufficient to handle leap years.
116
117#else // defined(__clang_analyzer__)
118
119// A fake function marked with noreturn that acts as a marker for CA_ASSUME to ensure the
120// static analyzer doesn't take an analysis path that is assumed not to be navigable.