[PATCH] D29692: [clang-tidy] add check modernize-use-const-instead-of-define

Alexander Lanin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 14 10:51:30 PST 2017


AlexanderLanin added a comment.

Thanks for the feedback. As I'm new to this I cannot say whether checking only the file in question fits better with clang-tidy’s policy or not.
Also, I’m not sure about ODR. Of course, it’s a possibility, but isn’t the programmer responsible for that? This will be more of an issue as soon as this check provides a Fix-It solution.

As for the other part, I've checked some guidelines (without any order or selection process)
MISRA C++: Don’t use `#define`, use `const` variables; Also don’t do math on enums
CppCoreGuidelines: Don’t use `#define`, use `constexpr` variables 
SEI CERT C++: No mention of `#define` as far as I can tell
JSF AV C++: Don’t use `#define`, use `const` variables
HIC++: Don’t use `#define`, use `const` objects (reference to JSF AV C++ and MISRA C++)

So basically they're all the same. The only question is `const` vs `constexpr`


https://reviews.llvm.org/D29692





More information about the cfe-commits mailing list