[PATCH] D145617: [clang-tidy] Add readability-avoid-unconditional-preprocessor-if check

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 18 11:05:37 PDT 2023


carlosgalvezp added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/readability/AvoidUnconditionalPreprocessorIfCheck.cpp:41
+
+  bool isStatic(SourceManager &SM, const LangOptions &LangOpts,
+                SourceRange ConditionRange) {
----------------
"static" is an overloaded C++ keyword which can lead to confusion in this context (you don't intend to detect whether a token is the `static` keyword). Would it be possible to give this a different name? Same for `isStaticToken`


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/readability/avoid-unconditional-preprocessor-if.cpp:67-69
+#if 10 > DDD
+// some code
+#endif
----------------
PiotrZSL wrote:
> carlosgalvezp wrote:
> > Add case for if 10 < DDD ?
> > 
> > Also, add test case for comparing 2 macros? If people follow the "no magic numbers" policy they'll likely have defines for both sides of the comparison.
> I don't support currently macros, would need to check if they defined unconditionally in same file, and I didn't want to mess with this.
Yes I didn't mean "function-like macros", just a plain define like you just added. Great, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145617/new/

https://reviews.llvm.org/D145617



More information about the cfe-commits mailing list