llvm-project/clang-tools-extra/clang-tidy
Richard f547fc89c0 [clang-tidy] Add modernize-macro-to-enum check
[buildbot issues fixed]

This check performs basic analysis of macros and replaces them
with an anonymous unscoped enum.  Using an unscoped anonymous enum
ensures that everywhere the macro token was used previously, the
enumerator name may be safely used.

Potential macros for replacement must meet the following constraints:
- Macros must expand only to integral literal tokens.  The unary
  operators plus, minus and tilde are recognized to allow for positive,
  negative and bitwise negated integers.
- Macros must be defined on sequential source file lines, or with
  only comment lines in between macro definitions.
- Macros must all be defined in the same source file.
- Macros must not be defined within a conditional compilation block.
- Macros must not be defined adjacent to other preprocessor directives.
- Macros must not be used in preprocessor conditions

Each cluster of macros meeting the above constraints is presumed to
be a set of values suitable for replacement by an anonymous enum.
From there, a developer can give the anonymous enum a name and
continue refactoring to a scoped enum if desired.  Comments on the
same line as a macro definition or between subsequent macro definitions
are preserved in the output.  No formatting is assumed in the provided
replacements.

The check cppcoreguidelines-macro-to-enum is an alias for this check.

Fixes #27408

Differential Revision: https://reviews.llvm.org/D117522
2022-04-01 15:24:21 -06:00
..
abseil [libTooling] Generalize string explanation as templated metadata 2022-03-21 20:39:35 +00:00
altera [clang-tidy] Fix crashing altera-struct-pack-align on invalid RecordDecls 2021-11-29 09:56:43 +01:00
android Use StringRef::contains (NFC) 2021-12-24 22:05:34 -08:00
boost [openmp] Add missing dependencies for OMP.h.inc after d90443b 2020-06-23 11:48:04 -04:00
bugprone [clang-tidy] Utilize comparison operation implemented in APInt 2022-03-28 23:32:58 +02:00
cert [clang-tidy][docs] Fix wrong url in DontModifyStdNamespaceCheck 2022-03-13 17:51:00 +01:00
concurrency [clang-tidy] Add new check 'concurrency-thread-canceltype-asynchronous' and alias 'cert-pos47-c'. 2021-02-22 12:42:20 +01:00
cppcoreguidelines [clang-tidy] ProBoundsConstantArrayIndexCheck::check - use cast<> instead of dyn_cast<> to avoid dereference of nullptr 2022-02-12 10:43:21 +00:00
darwin [openmp] Add missing dependencies for OMP.h.inc after d90443b 2020-06-23 11:48:04 -04:00
fuchsia Fix false positives in `fuchsia-trailing-return` check involving deduction guides 2021-12-01 15:28:01 -05:00
google Reland "[AST] Add UsingType: a sugar type for types found via UsingDecl" 2021-12-20 18:03:15 +01:00
hicpp [clang-tidy] Applied clang-tidy fixes. NFC 2021-01-29 01:01:19 +01:00
linuxkernel [openmp] Add missing dependencies for OMP.h.inc after d90443b 2020-06-23 11:48:04 -04:00
llvm [clang-tidy] Fix LLVM include order check policy 2022-02-03 17:32:43 +01:00
llvmlibc [clang-tidy] getOutermostNamespace - remove redundant nullptr check 2022-02-12 10:49:54 +00:00
misc [clang-tidy] Fix false positives in `misc-redundant-expression` check 2022-03-23 00:32:45 +01:00
modernize [clang-tidy] Add modernize-macro-to-enum check 2022-04-01 15:24:21 -06:00
mpi [clang-tidy][NFC] replace some redundant std::string creations 2022-01-19 18:36:35 +00:00
objc [clang-tidy][objc] Finds and fixes improper usages of XCTAssertEquals and XCTAssertNotEquals. 2021-12-02 18:32:16 -05:00
openmp [clang-tidy][NFC] Remove unnecessary includes throughout clang-tidy header files 2020-06-29 16:05:52 +01:00
performance [clang-tidy] NoexceptMoveConstructorCheck::check - use castAs<> instead of getAs<> to avoid dereference of nullptr 2022-02-12 10:57:09 +00:00
plugin [clang-tidy] Fix lint warnings in clang-tidy source code (NFC) 2021-11-02 20:14:25 +13:00
portability [clang-tidy][NFC] Tweak some generation of diag messages 2021-02-26 19:10:25 +00:00
readability [clang-tidy] Skip parentheses in `readability-make-member-function-const` 2022-03-21 14:18:17 +03:00
tool [clang-tidy][run-clang-tidy.py] Add --config-file=<string> option 2022-03-17 07:30:28 -04:00
utils [libTooling] Generalize string explanation as templated metadata 2022-03-21 20:39:35 +00:00
zircon Remove references to the ast_type_traits namespace 2020-12-11 00:58:46 +01:00
CMakeLists.txt Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot 2022-01-27 01:03:27 +13:00
ClangTidy.cpp [clang-tidy] Fix lint warnings in clang-tidy source code (NFC) 2021-11-02 20:14:25 +13:00
ClangTidy.h [clang-tidy] Fix lint warnings in clang-tidy source code (NFC) 2021-11-02 20:14:25 +13:00
ClangTidyCheck.cpp [clang-tidy] Add new case type to check variables with Hungarian notation 2021-08-01 15:22:17 -07:00
ClangTidyCheck.h [clang-tools-extra] Remove unused forward declarations (NFC) 2022-01-30 16:05:00 -08:00
ClangTidyDiagnosticConsumer.cpp Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot 2022-01-27 01:03:27 +13:00
ClangTidyDiagnosticConsumer.h [clang-tools-extra] Remove unused forward declarations (NFC) 2022-01-30 16:05:00 -08:00
ClangTidyForceLinker.h [clang-tidy] add concurrency module 2020-11-30 12:27:17 +03:00
ClangTidyModule.cpp [clang-tidy][NFC] Use StringMap for ClangTidyCheckFactories::FacoryMap 2020-07-30 22:57:33 +01:00
ClangTidyModule.h [clang-tidy][NFC] Remove unnecessary headers 2020-12-28 15:01:51 +00:00
ClangTidyModuleRegistry.h
ClangTidyOptions.cpp [clang-tidy] Applied clang-tidy fixes. NFC 2021-01-29 01:01:19 +01:00
ClangTidyOptions.h [clang-tidy] Fix lint warnings in clang-tidy source code (NFC) 2021-11-02 20:14:25 +13:00
ClangTidyProfiling.cpp [clang-tidy][NFC] Remove unnecessary headers 2020-12-28 15:01:51 +00:00
ClangTidyProfiling.h [clang-tidy][NFC] Remove unnecessary includes throughout clang-tidy header files 2020-06-29 16:05:52 +01:00
ExpandModularHeadersPPCallbacks.cpp [clang] Let PPCallbacks::PragmaWarning() pass specifier as enum instead of string 2021-09-28 19:47:27 -04:00
ExpandModularHeadersPPCallbacks.h [clang] Let PPCallbacks::PragmaWarning() pass specifier as enum instead of string 2021-09-28 19:47:27 -04:00
GlobList.cpp Allow newline characters as separators for checks in Clang-Tidy configurations 2022-03-15 14:30:13 -04:00
GlobList.h [clang-tidy][NFC] Remove Tristate from CachedGlobList 2022-02-23 08:35:31 +00:00
NoLintDirectiveHandler.cpp Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot 2022-01-27 01:03:27 +13:00
NoLintDirectiveHandler.h Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot 2022-01-27 01:03:27 +13:00
add_new_check.py [clang-tidy] Refactor: Prefer single quoted strings over double quoted strings [NFC] 2022-03-11 15:08:24 -07:00
clang-tidy-config.h.cmake Add an explicit toggle for the static analyzer in clang-tidy 2020-09-10 10:48:17 -04:00
rename_check.py Fix python 2-vs-3 issues in add_new_check.py and rename_check.py 2021-09-11 09:52:50 +02:00