29 lines · cpp
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_GUARD6#define INCLUDE_GUARD7 8#define PROBLEMATIC_CONSTANT 09// CHECK-MESSAGES: [[@LINE-1]]:9: warning: macro 'PROBLEMATIC_CONSTANT' used to declare a constant; consider using a 'constexpr' constant10 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 function13 14#define PROBLEMATIC_VARIADIC(...) (__VA_ARGS__)15// CHECK-MESSAGES: [[@LINE-1]]:9: warning: variadic macro 'PROBLEMATIC_VARIADIC' used; consider using a 'constexpr' variadic template function16 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 function19 20#define DEBUG_CONSTANT 021#define DEBUG_FUNCTION(x, y) ((a) > (b) ? (a) : (b))22#define DEBUG_VARIADIC(...) (__VA_ARGS__)23#define TEST_CONSTANT 024#define TEST_FUNCTION(x, y) ((a) > (b) ? (a) : (b))25#define TEST_VARIADIC(...) (__VA_ARGS__)26#define TEST_VARIADIC2(x, ...) (__VA_ARGS__)27 28#endif29