[all-commits] [llvm/llvm-project] 88a750: [clang-tidy] Deal with keyword tokens in preproces...

Richard Thomson via All-commits all-commits at lists.llvm.org
Fri Apr 8 15:07:11 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 88a7508b1fd87c7dd7f155cb1541c61f4c1f1bc8
      https://github.com/llvm/llvm-project/commit/88a7508b1fd87c7dd7f155cb1541c61f4c1f1bc8
  Author: Richard <legalize at xmission.com>
  Date:   2022-04-08 (Fri, 08 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] Deal with keyword tokens in preprocessor conditions

When a "keyword" token like __restrict was present in a macro condition,
modernize-macro-to-enum would assert in non-release builds.  However,
even for a "keyword" token, calling getIdentifierInfo()->getName() would
retrieve the text of the token, which is what we want.  Our intention is
to scan names that appear in conditional expressions in potential enum
clusters and invalidate those clusters if they contain the name.

Also, guard against "raw identifiers" appearing as potential enums.
This shouldn't happen, but it doesn't hurt to generalize the code.

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

Fixes #54775




More information about the All-commits mailing list