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

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 7 19:12:42 PST 2017


Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).

This check is also should be included into cppcoreguidelines module. Or may be moved there?



================
Comment at: clang-tidy/modernize/UseConstInsteadOfDefineCheck.cpp:41
+/// others like ~ are not so obvious and depend on usage
+bool isReasonableNumberPrefix(const Token &T) {
+  return T.isOneOf(tok::plus, tok::minus);
----------------
In LLVM Functions should be static, not inside anonymous namespace. Same below.


================
Comment at: clang-tidy/modernize/UseConstInsteadOfDefineCheck.cpp:67
+    const Token &MacroNameTok, const MacroInfo *MI) {
+
+  SourceLocation Loc;
----------------
Unnecessary empty line.


================
Comment at: docs/clang-tidy/checks/modernize-use-const-instead-of-define.rst:6
+
+C++ const variables should be preferred over #define statements as #define does
+not obey type checking and scope rules.
----------------
If I'm not mistaken, preprocessor has directives, not statements. Please also enclose #define in ``.


================
Comment at: docs/clang-tidy/checks/modernize-use-const-instead-of-define.rst:9
+
+a rather strange example might be:
+
----------------
A should be capitalized. Please also use code-block.


================
Comment at: test/clang-tidy/modernize-use-const-instead-of-define.cpp:19
+// CHECK-MESSAGES: :[[@LINE-1]]:{{.*}} [modernize-use-const-instead-of-define]
+
+
----------------
Unnecessary empty line.


================
Comment at: test/clang-tidy/modernize-use-const-instead-of-define.cpp:38
+
+
+#define NOT_DETECTED_YET_1(x)          ((unsigned char)(0xff))
----------------
Unnecessary empty line.


Repository:
  rL LLVM

https://reviews.llvm.org/D29692





More information about the cfe-commits mailing list