[PATCH] D124066: [clang-tidy] Ignore macros defined within declarations in modernize-macro-to-enum

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 20 13:26:31 PDT 2022


aaron.ballman added a comment.

This seems like a case where we might want a configuration option (maybe). Some of the test cases where you silence the diagnostic look like places I would expect us to be able to use a (local) enumeration. e.g.,

  void g(int x)
  {
    if (x != 0) {
  #define INSIDE1 1
  #define INSIDE2 2
  // No reason the above can't be replaced with enum { INSIDE1 = 1, INSIDE2 = 2 };
      if (INSIDE1 > 1) {
        f();
      }
    } else {
      if (INSIDE2 == 1) {
        f();
      }
    }
  }
  
  struct S {
  #define INSIDE5 5
  #define INSIDE6 6
  // The above could reasonably be: enum { INSIDE5 = 5, INSIDE6 = 6 }; especially in C++
    char storage[INSIDE5];
  };

WDYT?


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

https://reviews.llvm.org/D124066



More information about the cfe-commits mailing list