https://github.com/localspook created https://github.com/llvm/llvm-project/pull/173116
None >From 0e528dbd7ae33617d0cafb2377faf68c94538224 Mon Sep 17 00:00:00 2001 From: Victor Chernyakin <[email protected]> Date: Fri, 19 Dec 2025 15:04:35 -0800 Subject: [PATCH] [clang-tidy][NFC] Use LLVM's bitmask helpers instead of rolling our own --- .../FunctionCognitiveComplexityCheck.cpp | 30 ++----------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp index a966f1f6e24c5..f1216e0a39f0b 100644 --- a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp @@ -20,7 +20,7 @@ #include "clang/Basic/DiagnosticIDs.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" -#include "llvm/ADT/STLForwardCompat.h" +#include "llvm/ADT/BitmaskEnum.h" #include "llvm/Support/ErrorHandling.h" #include <array> #include <cassert> @@ -79,6 +79,8 @@ struct CognitiveComplexity final { PenalizeNesting = 1U << 2, All = Increment | PenalizeNesting | IncrementNesting, + + LLVM_MARK_AS_BITMASK_ENUM(PenalizeNesting), }; // The helper struct used to record one increment occurrence, with all the @@ -164,32 +166,6 @@ static const std::array<const StringRef, 4> Msgs = {{ "nesting level increased to %2", }}; -// Criteria is a bitset, thus a few helpers are needed. -static CognitiveComplexity::Criteria -operator|(CognitiveComplexity::Criteria LHS, - CognitiveComplexity::Criteria RHS) { - return static_cast<CognitiveComplexity::Criteria>(llvm::to_underlying(LHS) | - llvm::to_underlying(RHS)); -} -static CognitiveComplexity::Criteria -operator&(CognitiveComplexity::Criteria LHS, - CognitiveComplexity::Criteria RHS) { - return static_cast<CognitiveComplexity::Criteria>(llvm::to_underlying(LHS) & - llvm::to_underlying(RHS)); -} -static CognitiveComplexity::Criteria & -operator|=(CognitiveComplexity::Criteria &LHS, - CognitiveComplexity::Criteria RHS) { - LHS = operator|(LHS, RHS); - return LHS; -} -static CognitiveComplexity::Criteria & -operator&=(CognitiveComplexity::Criteria &LHS, - CognitiveComplexity::Criteria RHS) { - LHS = operator&(LHS, RHS); - return LHS; -} - void CognitiveComplexity::account(SourceLocation Loc, unsigned short Nesting, Criteria C) { C &= Criteria::All; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
