[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-07 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > Extending this functionality with transformers is optional and can be done > later in another PR, if someone is willing. Yes and no. If the goal is just to write checks, then clang-tidy is a good home for the functionality. But I had the impression that for some people th

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-05 Thread Piotr Zegar via cfe-commits
PiotrZSL wrote: > I think flattening the configuration items will only reduce readability, > because we cannot define a YAML schema for it. If we put that entire YAML under "custom-call-main-function.Config", that would also be fine. Thing is that with this there could be a way to make all chan

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-05 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: > Hi, I tried to explain everything here: Thanks, I missed that! For RFCs it's preferable to use [Discourse](https://discourse.llvm.org/c/clang/clang-tidy/71), as there is a lot less traffic and can more easily catch the eyes of relevant people. I did not see much discuss

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-05 Thread Ibraim Ganiev via cfe-commits
olologin wrote: @carlosgalvezp Hi, I tried to explain everything here: https://github.com/llvm/llvm-project/issues/107680 https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/c

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-05 Thread Ibraim Ganiev via cfe-commits
olologin wrote: >it sounds like the goal is somewhat less about clang-tidy checks and more >about running code transformations more easily. Original goal was to have just clang-tidy checks. We use it on our CI to guard main branch from people accidentally merging prohibited stuff. If CI informs

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > Hi, I tried to explain everything here: > > Thanks, I missed that! For RFCs it's preferable to use > [Discourse](https://discourse.llvm.org/c/clang/clang-tidy/71), as there is a > lot less traffic and can more easily catch the eyes of relevant people. I did > not see m

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-04 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,20 @@ +set(LLVM_LINK_COMPONENTS + support + ) + +add_clang_library(clangTidyCustomModule STATIC + CustomTidyModule.cpp + QueryCheck.cpp + + LINK_LIBS + clangTidy + clangTidyUtils + + DEPENDS + ClangDriverOptions + ) + +clang_target_link_libraries(clangTidyCust

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-04-04 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-28 Thread Piotr Zegar via cfe-commits
https://github.com/PiotrZSL requested changes to this pull request. I do not like this "CustomChecks" What I would like to have in config is: ``` custom-call-main-function.Engine: Query custom-call-main-function.Language: C custom-call-main-function.Traverse: AsIs custom-call-main-function.Code

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-27 Thread Congcong Cai via cfe-commits
HerrCai0907 wrote: > > It would feel safer if the custom check was passed via command-line > > instead, similar to --config > > But then you will not be able to properly disable such checks for subfolders > (modules) of some huge project, right? it can be done by checks. https://github.com/l

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-26 Thread Ibraim Ganiev via cfe-commits
olologin wrote: > It would feel safer if the custom check was passed via command-line instead, > similar to --config But then you will not be able to properly disable such checks for subfolders (modules) of some huge project, right? https://github.com/llvm/llvm-project/pull/131804

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-26 Thread Congcong Cai via cfe-commits
HerrCai0907 wrote: > It would feel safer if the custom check was passed via command-line instead, > similar to --config good point. should we only support command line for this feature? for me it is enough. https://github.com/llvm/llvm-project/pull/131804 _

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-26 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: My main concern about this patch is putting the implementation into the config file. We must be very careful with what we add to the config file, because it must remain there unchanged forever. We must have an upfront design that we believe will hold for the next N years w

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-20 Thread Congcong Cai via cfe-commits
HerrCai0907 wrote: > clang-query doesn't really lend itself to "find this pattern, replace with > this other pattern", and clang-tidy requires enough boilerplate for checks > that it's a heavy-handed solution. It might make more sense to design a tool > specific for code transformations -- som

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-20 Thread Congcong Cai via cfe-commits
HerrCai0907 wrote: > checkfactories could read name of checks from an options config. Then everything go back. checkfactories or some other part in core will parse the options and create check instance. It is similar as what this pr did. Put everything in config also have some disadvantages, b

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-20 Thread Piotr Zegar via cfe-commits
PiotrZSL wrote: checkfactories could read name of checks from an options config. https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Ibraim Ganiev via cfe-commits
olologin wrote: Splitting config to multiple files is potentially bad because caching wrappers need to be adjusted to take into account this new type of input file (they only know about .clang-tidy file). https://github.com/llvm/llvm-project/pull/131804

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: Sorry for being late for the review. This is a major new feature of clang-tidy, so I believe it would be good to have an RFC before looking at the detailed implementation. What problem does it solve, why should clang-tidy solve it, what the API towards the user should be,

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Congcong Cai via cfe-commits
HerrCai0907 wrote: > However, this may have changed now because of new architecture. It will be too much differences because dependences are the same. only some wrapper code in clangtidy changed. https://github.com/llvm/llvm-project/pull/131804 ___ c

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Congcong Cai via cfe-commits
HerrCai0907 wrote: > I do not see need for errors, always someone can use warnings as errors. Agree. I will remove it if no one against it. https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Congcong Cai via cfe-commits
HerrCai0907 wrote: > Main reason is simple, easy to modify check and add new check in subconfigs. It is also support to add new check in subconfigs, to modify check is thing I did not implement yet. (There are FIXME in merge config part of code) In theory, these two configurations are equivalen

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Ibraim Ganiev via cfe-commits
olologin wrote: I like it if it does not break anything :) One small nitpick: Maybe word "custom" is too broad for this. Maybe something that mentions "clang-query" is more specific. But it is just my opinion and I am not related to clang-tidy, so whatever you guys decide. https://github.com/l

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Carlos Galvez via cfe-commits
@@ -0,0 +1,20 @@ +set(LLVM_LINK_COMPONENTS + support + ) + +add_clang_library(clangTidyCustomModule STATIC + CustomTidyModule.cpp + QueryCheck.cpp + + LINK_LIBS + clangTidy + clangTidyUtils + + DEPENDS + ClangDriverOptions + ) + +clang_target_link_libraries(clangTidyCust

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Piotr Zegar via cfe-commits
@@ -0,0 +1,20 @@ +set(LLVM_LINK_COMPONENTS + support + ) + +add_clang_library(clangTidyCustomModule STATIC + CustomTidyModule.cpp + QueryCheck.cpp + + LINK_LIBS + clangTidy + clangTidyUtils + + DEPENDS + ClangDriverOptions + ) + +clang_target_link_libraries(clangTidyCust

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Baranov Victor via cfe-commits
vbvictor wrote: > Do you know how much build times and binary size are affected by this change? Binary size comparison was addressed in discussion on previous PR, here is comment for reference https://github.com/llvm/llvm-project/pull/123734#discussion_r1925090946. However, this may have chang

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Carlos Galvez via cfe-commits
@@ -0,0 +1,20 @@ +set(LLVM_LINK_COMPONENTS + support + ) + +add_clang_library(clangTidyCustomModule STATIC + CustomTidyModule.cpp + QueryCheck.cpp + + LINK_LIBS + clangTidy + clangTidyUtils + + DEPENDS + ClangDriverOptions + ) + +clang_target_link_libraries(clangTidyCust

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Piotr Zegar via cfe-commits
https://github.com/PiotrZSL edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-19 Thread Piotr Zegar via cfe-commits
https://github.com/PiotrZSL edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/131804 >From a686695e6691fcb824b2055c3dfa8f0fd3727355 Mon Sep 17 00:00:00 2001 From: DeNiCoN Date: Mon, 17 Mar 2025 08:04:32 + Subject: [PATCH 01/11] origin pr --- clang-tools-extra/clang-tidy/CMakeLists.txt

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/131804 >From a686695e6691fcb824b2055c3dfa8f0fd3727355 Mon Sep 17 00:00:00 2001 From: DeNiCoN Date: Mon, 17 Mar 2025 08:04:32 + Subject: [PATCH 01/10] origin pr --- clang-tools-extra/clang-tidy/CMakeLists.txt

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread Baranov Victor via cfe-commits
https://github.com/vbvictor edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread Baranov Victor via cfe-commits
@@ -0,0 +1,50 @@ +#include "../ClangTidy.h" +#include "../ClangTidyModule.h" +#include "../ClangTidyModuleRegistry.h" +#include "../ClangTidyOptions.h" +#include "QueryCheck.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringRef.h" +#in

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread via cfe-commits
@@ -292,6 +293,8 @@ An overview of all the command-line options: Checks - Same as '--checks'. Additionally, the list of globs can be specified as a list instead of a string. +C

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread via cfe-commits
@@ -0,0 +1,102 @@ +//===--- QueryCheck.cpp - clang-tidy --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread via cfe-commits
@@ -0,0 +1,57 @@ + +Query Based Custom Clang-Tidy Checks + + +Introduction + + +This page provides examples of how to add query based custom checks for +:program:`clang-tidy`. + +Custom checks are

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread via cfe-commits
@@ -0,0 +1 @@ +InheritParentConfig: false EugeneZelenko wrote: Please add newline. https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread via cfe-commits
@@ -0,0 +1,57 @@ + +Query Based Custom Clang-Tidy Checks + + +Introduction + + +This page provides examples of how to add query based custom checks for +:program:`clang-tidy`. + +Custom checks are

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: Congcong Cai (HerrCai0907) Changes --- Patch is 31.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/131804.diff 25 Files Affected: - (modified) clang-tools-extra/clang-tidy/CMa

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread Congcong Cai via cfe-commits
HerrCai0907 wrote: --dump-config will create incorrect YAML due to #131694. https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/131804 >From a686695e6691fcb824b2055c3dfa8f0fd3727355 Mon Sep 17 00:00:00 2001 From: DeNiCoN Date: Mon, 17 Mar 2025 08:04:32 + Subject: [PATCH 1/9] origin pr --- clang-tools-extra/clang-tidy/CMakeLists.txt

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/131804 >From a686695e6691fcb824b2055c3dfa8f0fd3727355 Mon Sep 17 00:00:00 2001 From: DeNiCoN Date: Mon, 17 Mar 2025 08:04:32 + Subject: [PATCH 1/9] origin pr --- clang-tools-extra/clang-tidy/CMakeLists.txt

[clang-tools-extra] [clang-tidy] support query based custom check (PR #131804)

2025-03-18 Thread Congcong Cai via cfe-commits
https://github.com/HerrCai0907 edited https://github.com/llvm/llvm-project/pull/131804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits