[PATCH] D125622: [clang-tidy] Reject invalid enum initializers in C files

Richard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat May 14 19:49:25 PDT 2022


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

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.

Fixes #55467


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125622

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125622.429504.patch
Type: text/x-patch
Size: 16308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220515/7fa0325e/attachment.bin>


More information about the cfe-commits mailing list