[clang-tools-extra] [clang-tidy][NFC][doc] improve "options" sections of `misc-`, `cppcore-` and other checks (PR #133694)

2025-04-04 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp closed https://github.com/llvm/llvm-project/pull/133694 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-03-22 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: I believe I found something promising: * Revert the parts of the code that sets the TraversalScope. This messes up the `ParentMapContext`. * Apply this change: ``` bool MatchASTVisitor::TraverseDecl(Decl *DeclNode) { if (!DeclNode) { return true; } + if (Options.

[clang-tools-extra] [clang-tidy] Skip system macros in readability-identifier-naming check (PR #132016)

2025-03-19 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp created https://github.com/llvm/llvm-project/pull/132016 Currently, the check is processing system macros. Most importantly, it tries to find .clang-tidy files associated with those files, if the option GetConfigPerFile (on by default) is active. This is probl

[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] [clang-tools-extra] [clang][AST][clang-tidy] Do not set a reduced traversal scope in ASTM… (PR #132725)

2025-03-24 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: @kadircet Are you able to test this PR and confirm it fixes the regressions you encountered? https://github.com/llvm/llvm-project/pull/132725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

[clang] [clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-03-24 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: Ok! Will fix sometime today. I think this topic needs some more careful iteration and we should unblock. Worth noting is that even though a lot of warnings still remain the performance gain was still significant, i.e. going from 10 seconds (baseline) to 3 seconds (proposa

[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-03-29 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp updated https://github.com/llvm/llvm-project/pull/133582 >From 2ecbd54fbc82bbfad2e190529efd3a4cc71bd8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= Date: Sat, 29 Mar 2025 11:55:02 + Subject: [PATCH] [clang-tidy] Fix broken HeaderFilterReg

[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-03-29 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp updated https://github.com/llvm/llvm-project/pull/133582 >From 7f2b6448acee91deef7ff73fd36a92bb9787a674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= Date: Sat, 29 Mar 2025 11:55:02 + Subject: [PATCH] [clang-tidy] Fix broken HeaderFilterReg

[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-03-29 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp updated https://github.com/llvm/llvm-project/pull/133582 >From 99abf89c1ed177be1b9a3f7f2acd85ffb726a757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= Date: Sat, 29 Mar 2025 11:55:02 + Subject: [PATCH] [clang-tidy] Fix broken HeaderFilterReg

[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-03-29 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp created https://github.com/llvm/llvm-project/pull/133582 PR https://github.com/llvm/llvm-project/pull/91400 broke the usage of HeaderFilterRegex via config file, because it is now created at a different point in the execution and leads to a different value. Th

[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-04-02 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp updated https://github.com/llvm/llvm-project/pull/133582 >From 12b63eb35ab09b6ae1aa0fbfa00487f4cad3cac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= Date: Sat, 29 Mar 2025 11:55:02 + Subject: [PATCH] [clang-tidy] Fix broken HeaderFilterReg

[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)

2025-04-03 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp requested changes to this pull request. The changes to the clang-tidy check should be reverted IMO. Also, please provide more information. What do you mean by "code sanitizer", what is the exact error message, etc. https://github.com/llvm/llvm-project/pull/1341

[clang-tools-extra] [NFC] Fixes proposed by code sanitizer. (PR #134138)

2025-04-03 Thread Carlos Galvez via cfe-commits
@@ -260,7 +260,7 @@ static IntegerRange createFromType(const ASTContext &Context, llvm::APSInt LowerValue(PrecisionBits + 2, /*isUnsigned*/ false); LowerValue.setBit(PrecisionBits); LowerValue.setSignBit(); -return {LowerValue, UpperValue}; +return {std::mo

[clang] [clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-03-25 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: So I looked into the problem, and it seems that issue is that the `ParentMapContext` class does not correctly find all the parents due to the reduced AST traversal. One quick & dirty solution that makes the CERT test pass (and keeps all the remaining tests passing) is as f

[clang-tools-extra] [clang-tidy][misc-const-correctness] fix fp when using const array type. (PR #133018)

2025-03-27 Thread Carlos Galvez via cfe-commits
@@ -1007,3 +1007,11 @@ template void f() { x[T{}] = 3; } } // namespace gh127776_false_positive + +namespace gh132931_false_positive { +using T = const int; +void valid(int i) { + const int arr0[] = {1, 2, 3}; + T arr1[] = {1, 2, 3}; carlosgalvezp wrote:

[clang-tools-extra] [clang-tidy][misc-const-correctness] fix fp when using const array type. (PR #133018)

2025-03-27 Thread Carlos Galvez via cfe-commits
@@ -1007,3 +1007,11 @@ template void f() { x[T{}] = 3; } } // namespace gh127776_false_positive + +namespace gh132931_false_positive { +using T = const int; +void valid(int i) { + const int arr0[] = {1, 2, 3}; + T arr1[] = {1, 2, 3}; carlosgalvezp wrote:

[clang-tools-extra] [clang-tidy][misc-const-correctness] fix fp when using const array type. (PR #133018)

2025-03-27 Thread Carlos Galvez via cfe-commits
@@ -89,6 +89,8 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) { const auto ConstReference = hasType(references(isConstQualified())); carlosgalvezp wrote: All the tests (including the FP at hand) pass if you remove `unless(arrayType()` f

[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-04-03 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp closed https://github.com/llvm/llvm-project/pull/133582 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [NFC] Remove dead code detected by code sanitizer. (PR #134385)

2025-04-04 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp approved this pull request. Nice finding! Nit: next time, please add `[clang-tidy]` to the beginning of the commit message, so it's easier to see which part of the repo is affected. https://github.com/llvm/llvm-project/pull/134385 __

[clang-tools-extra] Add option to exclude headers from clang-tidy analysis (PR #91400)

2025-04-04 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: > It seems to be running on my .h files itself(?) In that case, I don't believe clang-tidy considers the header "a header", but actually "the main file" just like when analyzing a .cpp file. In that case, `ExcludeHeaderFilterRegex` won't work. https://github.com/llvm/llv

[clang-tools-extra] [clang-tidy] Fix broken HeaderFilterRegex when read from config file (PR #133582)

2025-04-04 Thread Carlos Galvez via cfe-commits
@@ -0,0 +1 @@ +HeaderFilterRegex: '.*' carlosgalvezp wrote: It appears this use case was broken by this [patch](https://github.com/llvm/llvm-project/commit/0249554ee1ac49e6f1d93fa78a55971fc706f635), @HerrCai0907 . There may be more things to fix. https:/

[clang-tools-extra] [CLANGD] [NFC] Fix proposed by sanitizer. (PR #140116)

2025-05-16 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp approved this pull request. LGTM. In the future, please provide more details about exactly which tool you are using, which you call "sanitizer". For example, what is the name of the tool? "sanitizers" are tools to detect issues at runtime; here you are using a

[clang-tools-extra] [clang-tidy] Disable bugprone-multi-level-pointer-conversion in C code (PR #141209)

2025-05-23 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp created https://github.com/llvm/llvm-project/pull/141209 It is deemed more of an annoyance than a help, since the patterns the check warns about are quite common and idiomatic in C, and there are no good alternatives. Thus, enable the check only for C++, where

[clang-tools-extra] [clang-tidy] Disable bugprone-multi-level-pointer-conversion in C code (PR #141209)

2025-05-23 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: You can check the discussion in the linked issue. The argument is that these casts are idiomatic in C, and does not make sense to pollute the code with casts. There's no other safer alternative either. > then probably they should just disable a check There doesn't appear

[clang-tools-extra] [clang-tidy][NFC] Refactor `modernize-pass-by-value` check code and tests (PR #140753)

2025-05-20 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp requested changes to this pull request. Why are the fixes being removed? CHECK-FIXES is not equivalent to CHECK-MESSAGES-NOT https://github.com/llvm/llvm-project/pull/140753 ___ cfe-commits mailing list cfe-commits@lis

[clang-tools-extra] [clang-tidy][NFC] Refactor `modernize-pass-by-value` check code and tests (PR #140753)

2025-05-20 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: Also, CHECK-MESSAGES-NOT is discouraged, since the testing framework already checked that no other output is produced by default. https://github.com/llvm/llvm-project/pull/140753 ___ cfe-commits mailing list cfe-commits@lists.llvm

[clang-tools-extra] [clang-tidy] Return error code on config parse error (PR #136167)

2025-05-20 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: Apologies for the delay, I will review during this week! https://github.com/llvm/llvm-project/pull/136167 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][NFC] Refactor `modernize-use-trailing-return-type-check` check code and tests (PR #140759)

2025-05-20 Thread Carlos Galvez via cfe-commits
@@ -113,7 +113,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor { }; } // namespace -constexpr llvm::StringLiteral Message = +constexpr llvm::StringLiteral MessageFunction = carlosgalvezp wrote: Nit: I think the name was clearer before. I read this

[clang-tools-extra] [clang-tidy][NFC] Refactor `modernize-use-trailing-return-type-check` check code and tests (PR #140759)

2025-05-20 Thread Carlos Galvez via cfe-commits
@@ -383,6 +382,10 @@ void UseTrailingReturnTypeCheck::keepSpecifiers( } } +UseTrailingReturnTypeCheck::UseTrailingReturnTypeCheck( carlosgalvezp wrote: Nit: typically we keep these in the header in this case, since it's just 1 more line in the header, comp

[clang-tools-extra] [clang-tidy][NFC] Refactor `modernize-pass-by-value` check code and tests (PR #140753)

2025-05-20 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/140753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][NFC] Refactor `modernize-pass-by-value` check code and tests (PR #140753)

2025-05-20 Thread Carlos Galvez via cfe-commits
carlosgalvezp wrote: Thanks, I didn't notice they were the same. In that case they should be removed and have nothing. Optionally one can add a human-readable comment like "Should not trigger here" or something, but it's not necessary. https://github.com/llvm/llvm-project/pull/140753 _

[clang-tools-extra] [clang-tidy][NFC] Refactor `modernize-pass-by-value` check code and tests (PR #140753)

2025-05-21 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp closed https://github.com/llvm/llvm-project/pull/140753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][NFC] Refactor `modernize-use-trailing-return-type-check` check code and tests (PR #140759)

2025-05-21 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/140759 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy][NFC] Refactor `modernize-use-trailing-return-type-check` check code and tests (PR #140759)

2025-05-21 Thread Carlos Galvez via cfe-commits
@@ -113,7 +113,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor { }; } // namespace -constexpr llvm::StringLiteral Message = +constexpr llvm::StringLiteral MessageFunction = carlosgalvezp wrote: Ok! I think this change would have been better to do

[clang-tools-extra] [clang-tidy] Do not flag strerror in concurrency-mt-unsafe (PR #140520)

2025-05-19 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp created https://github.com/llvm/llvm-project/pull/140520 The docs of the check state: > Glibc’s list is compiled from GNU web documentation with a search for MT-Safe > tag And strerror fulfills exactly that: https://www.gnu.org/software/libc/manual/html_node/

[clang-tools-extra] [clang-tidy] Do not flag strerror in concurrency-mt-unsafe (PR #140520)

2025-05-19 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp updated https://github.com/llvm/llvm-project/pull/140520 >From 35769db674fc2ebe7c0dda9ed329806b8b059414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= Date: Mon, 19 May 2025 09:35:30 + Subject: [PATCH 1/2] [clang-tidy] Do not flag strerror i

[clang-tools-extra] [clang-tidy] Do not flag strerror in concurrency-mt-unsafe (PR #140520)

2025-05-19 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp closed https://github.com/llvm/llvm-project/pull/140520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Return error code on config parse error (PR #136167)

2025-05-26 Thread Carlos Galvez via cfe-commits
@@ -46,20 +46,65 @@ TEST(ClangTidyOptionsProvider, InMemoryFileSystems) { FileOptionsProvider FileOpt({}, {}, {}, FileSystem); - ClangTidyOptions File1Options = + llvm::ErrorOr File1Options = FileOpt.getOptions("ProjectRoot/SubDir1/File.cpp"); - ClangTidyOptions F

[clang-tools-extra] [clang-tidy] Return error code on config parse error (PR #136167)

2025-05-26 Thread Carlos Galvez via cfe-commits
@@ -265,8 +265,16 @@ const ClangTidyOptions &ClangTidyContext::getOptions() const { ClangTidyOptions ClangTidyContext::getOptionsForFile(StringRef File) const { // Merge options on top of getDefaults() as a safeguard against options with // unset values. - return ClangTid

[clang-tools-extra] [clang-tidy] Return error code on config parse error (PR #136167)

2025-05-26 Thread Carlos Galvez via cfe-commits
@@ -46,20 +46,65 @@ TEST(ClangTidyOptionsProvider, InMemoryFileSystems) { FileOptionsProvider FileOpt({}, {}, {}, FileSystem); - ClangTidyOptions File1Options = + llvm::ErrorOr File1Options = FileOpt.getOptions("ProjectRoot/SubDir1/File.cpp"); - ClangTidyOptions F

[clang-tools-extra] [clang-tidy] Return error code on config parse error (PR #136167)

2025-05-26 Thread Carlos Galvez via cfe-commits
https://github.com/carlosgalvezp edited https://github.com/llvm/llvm-project/pull/136167 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Return error code on config parse error (PR #136167)

2025-05-26 Thread Carlos Galvez via cfe-commits
@@ -46,20 +46,20 @@ TEST(ClangTidyOptionsProvider, InMemoryFileSystems) { FileOptionsProvider FileOpt({}, {}, {}, FileSystem); - ClangTidyOptions File1Options = + llvm::ErrorOr File1Options = FileOpt.getOptions("ProjectRoot/SubDir1/File.cpp"); - ClangTidyOptions F

<    1   2   3   4   5   6