[PATCH] D124316: [clang-tidy] Modernize-macro-to-enum should skip macros used in other macros

Richard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 22 18:41:23 PDT 2022


LegalizeAdulthood created this revision.
LegalizeAdulthood added reviewers: aaron.ballman, alexfh.
LegalizeAdulthood added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
LegalizeAdulthood requested review of this revision.

If a macro is used in the expansion of another macro, that can cause
a compile error if the macro is replaced with an enum.  Token-pasting is
an example where converting a macro defined as an integral constant can
cause code to no longer compile.

This change causes such macros to be skipped from the conversion
process in order to prevent fixits from creating code that no longer
compiles.

A subsequent enhancement will examine macro usage in more detail to
allow more cases to be handled without breaking code.

Fixes #54948 <https://github.com/llvm/llvm-project/issues/54948>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124316

Files:
  clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-macro-to-enum.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124316.424677.patch
Type: text/x-patch
Size: 4329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220423/521218c3/attachment.bin>


More information about the cfe-commits mailing list