[clang-tools-extra] a6c355e - [clang-tidy][NFC] Use LLVM's bitmask helpers instead of rolling our own (#173116)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 19 15:23:31 PST 2025
Author: Victor Chernyakin
Date: 2025-12-19T15:23:27-08:00
New Revision: a6c355e2e6a6f8b3bb137275fd695da16a933c39
URL: https://github.com/llvm/llvm-project/commit/a6c355e2e6a6f8b3bb137275fd695da16a933c39
DIFF: https://github.com/llvm/llvm-project/commit/a6c355e2e6a6f8b3bb137275fd695da16a933c39.diff
LOG: [clang-tidy][NFC] Use LLVM's bitmask helpers instead of rolling our own (#173116)
Added:
Modified:
clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
Removed:
################################################################################
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;
More information about the cfe-commits
mailing list