[all-commits] [llvm/llvm-project] 693246: [clang-tidy] Modernize-macro-to-enum should skip m...

Richard Thomson via All-commits all-commits at lists.llvm.org
Tue Apr 26 20:10:09 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 693246e03f28eaa72e0959fe6a969cea655b1fdc
      https://github.com/llvm/llvm-project/commit/693246e03f28eaa72e0959fe6a969cea655b1fdc
  Author: Richard <legalize at xmission.com>
  Date:   2022-04-26 (Tue, 26 Apr 2022)

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

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

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.

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

Fixes #54948




More information about the All-commits mailing list