Declare __fake_use_va_args as a constexpr function.

* Need a body and return value for this function
  so the constexpr check can inline it.
* C mode can just use an extern function declaration, but not constexpr.

Bug: 116854606
Bug: 111614304
Test: build with WITH_TIDY=1 and enable static analyzer checks
Change-Id: Ie3f4efbcabed99416d196b6c361a772b8c6a4035
This commit is contained in:
Chih-Hung Hsieh 2018-10-02 14:46:48 -07:00
parent dcee6d22fb
commit 9cb232b4de
1 changed files with 14 additions and 5 deletions

View File

@ -56,15 +56,24 @@ __BEGIN_DECLS
/*
* Use __VA_ARGS__ if running a static analyzer,
* to avoid warnings of unused variables in __VA_ARGS__.
* __FAKE_USE_VA_ARGS is undefined at link time,
* so don't link with __clang_analyzer__ defined.
* Use contexpr function in C++ mode, so these macros can be used
* in other constexpr functions without warning.
*/
#ifdef __clang_analyzer__
extern void __fake_use_va_args(int, ...);
#define __FAKE_USE_VA_ARGS(...) __fake_use_va_args(0, ##__VA_ARGS__)
#ifdef __cplusplus
extern "C++" {
template <typename... Ts>
constexpr int __fake_use_va_args(Ts...) {
return 0;
}
}
#else
extern int __fake_use_va_args(int, ...);
#endif /* __cplusplus */
#define __FAKE_USE_VA_ARGS(...) ((void)__fake_use_va_args(0, ##__VA_ARGS__))
#else
#define __FAKE_USE_VA_ARGS(...) ((void)(0))
#endif
#endif /* __clang_analyzer__ */
#ifndef __predict_false
#define __predict_false(exp) __builtin_expect((exp) != 0, 0)