[clang-tools-extra] [clang-tidy] Adds readability-redundant-const check (PR #189733)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 12 06:50:22 PDT 2026
================
@@ -70,20 +70,56 @@ void RedundantConstCheck::registerMatchers(MatchFinder *Finder) {
this);
}
+static bool hasProblemSibling(const VarDecl *VD, SourceLocation ConstLoc,
+ const SourceManager &SM, const LangOptions &LO) {
+ const SourceLocation Semi =
+ utils::lexer::findNextAnyTokenKind(ConstLoc, SM, LO, tok::semi);
+ if (Semi.isInvalid())
+ return false;
+
+ const SourceLocation Comma =
+ utils::lexer::findNextAnyTokenKind(ConstLoc, SM, LO, tok::comma);
+ if (Comma.isInvalid() || !SM.isBeforeInTranslationUnit(Comma, Semi))
+ return false;
+
+ for (Decl *D : VD->getDeclContext()->decls()) {
----------------
vbvictor wrote:
I don't think we need to find all decls in declcontext for this case.
You can match `DeclStmt` class which incapsulates multiple decls and then check how much decls you have. If one you can process with normal path, if multiple then check that all decls are non-reference, non-etc... as you do with `Sib->getType()`.
So I think whole "hasProblemSibling" with lexing is not needed.
https://github.com/llvm/llvm-project/pull/189733
More information about the cfe-commits
mailing list