1 | // RUN: %check_clang_tidy %s cppcoreguidelines-macro-usage %t \ |
2 | // RUN: -config="{CheckOptions: \ |
3 | // RUN: {cppcoreguidelines-macro-usage.AllowedRegexp: 'DEBUG_*|TEST_*'}}" -- |
4 | |
5 | #ifndef INCLUDE_GUARD |
6 | #define INCLUDE_GUARD |
7 | |
8 | #define PROBLEMATIC_CONSTANT 0 |
9 | // CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro 'PROBLEMATIC_CONSTANT' used to declare a constant; consider using a 'constexpr' constant |
10 | |
11 | #define PROBLEMATIC_FUNCTION(x, y) ((a) > (b) ? (a) : (b)) |
12 | // CHECK-MESSAGES: [[@LINE-1]]:9: warning: function-like macro 'PROBLEMATIC_FUNCTION' used; consider a 'constexpr' template function |
13 | |
14 | #define PROBLEMATIC_VARIADIC(...) (__VA_ARGS__) |
15 | // CHECK-MESSAGES: [[@LINE-1]]:9: warning: variadic macro 'PROBLEMATIC_VARIADIC' used; consider using a 'constexpr' variadic template function |
16 | |
17 | #define PROBLEMATIC_VARIADIC2(x, ...) (__VA_ARGS__) |
18 | // CHECK-MESSAGES: [[@LINE-1]]:9: warning: variadic macro 'PROBLEMATIC_VARIADIC2' used; consider using a 'constexpr' variadic template function |
19 | |
20 | #define DEBUG_CONSTANT 0 |
21 | #define DEBUG_FUNCTION(x, y) ((a) > (b) ? (a) : (b)) |
22 | #define DEBUG_VARIADIC(...) (__VA_ARGS__) |
23 | #define TEST_CONSTANT 0 |
24 | #define TEST_FUNCTION(x, y) ((a) > (b) ? (a) : (b)) |
25 | #define TEST_VARIADIC(...) (__VA_ARGS__) |
26 | #define TEST_VARIADIC2(x, ...) (__VA_ARGS__) |
27 | |
28 | #endif |
29 | |