[clang-tidy] Support parenthesized literals in modernize-macro-to-enum
authorRichard <legalize@xmission.com>
Mon, 11 Apr 2022 01:15:22 +0000 (19:15 -0600)
committerRichard <legalize@xmission.com>
Mon, 11 Apr 2022 20:06:48 +0000 (14:06 -0600)
commitd563c2d0e52a738ab2038db02a76dc4c27ec7124
treec445121781c32ad15eb07dabee84a83125628782
parentcbcb3bcee3efc8ea4e72bc36ae5cbaf946804b58
[clang-tidy] Support parenthesized literals in modernize-macro-to-enum

When scanning a macro expansion to examine it as a candidate enum,
first strip off arbitrary matching parentheses from the outside in,
then examine what remains to see if it is Lit, +Lit, -Lit or ~Lit.
If not, reject it as a possible enum candidate.

Differential Revision: https://reviews.llvm.org/D123479

Fixes #54843
clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/modernize-macro-to-enum.rst
clang-tools-extra/test/clang-tidy/checkers/modernize-macro-to-enum.cpp