[all-commits] [llvm/llvm-project] b985b6: [clang-tidy] Ignore macros defined within declarat...

Richard Thomson via All-commits all-commits at lists.llvm.org
Fri Apr 22 16:47:13 PDT 2022


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

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

  Log Message:
  -----------
  [clang-tidy] Ignore macros defined within declarations

Modernize-macro-to-enum shouldn't try to convert macros to enums
when they are defined inside a declaration or definition, only
when the macros are defined at the top level.  Since preprocessing
is disconnected from AST traversal, match nodes in the AST and then
invalidate source ranges spanning AST nodes before issuing diagnostics.

ClangTidyCheck::onEndOfTranslationUnit is called before
PPCallbacks::EndOfMainFile, so defer final diagnostics to the
PPCallbacks implementation.

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

Fixes #54883




More information about the All-commits mailing list