[all-commits] [llvm/llvm-project] b418ef: [clang-tidy] Reject invalid enum initializers in C...

Richard Thomson via All-commits all-commits at lists.llvm.org
Wed Jun 1 21:57:14 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b418ef5cb90b32657dee46b068ac367787a8d2d6
      https://github.com/llvm/llvm-project/commit/b418ef5cb90b32657dee46b068ac367787a8d2d6
  Author: Richard <legalize at xmission.com>
  Date:   2022-06-01 (Wed, 01 Jun 2022)

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

  Log Message:
  -----------
  [clang-tidy] Reject invalid enum initializers in C files

C requires that enum values fit into an int.  Scan the macro tokens
present in an initializing expression and reject macros that contain
tokens that have suffixes making them larger than int.

C forbids the comma operator in enum initializing expressions, so
optionally reject comma operator.

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

Fixes #55467




More information about the All-commits mailing list