[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-06-06 Thread Shafik Yaghmour via cfe-commits
@@ -16597,7 +16597,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, BD->setCaptures(Context, Captures, BSI->CXXThisCaptureIndex != 0); // Pop the block scope now but keep it alive to the end of this function. - AnalysisBasedWarnings::Policy WP = Analysis

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-06-06 Thread Balazs Benics via cfe-commits
https://github.com/steakhal edited https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-06-06 Thread Balazs Benics via cfe-commits
@@ -16597,7 +16597,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, BD->setCaptures(Context, Captures, BSI->CXXThisCaptureIndex != 0); // Pop the block scope now but keep it alive to the end of this function. - AnalysisBasedWarnings::Policy WP = Analysis

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-06-05 Thread Shafik Yaghmour via cfe-commits
@@ -16597,7 +16597,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, BD->setCaptures(Context, Captures, BSI->CXXThisCaptureIndex != 0); // Pop the block scope now but keep it alive to the end of this function. - AnalysisBasedWarnings::Policy WP = Analysis

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-23 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > FYI this introduces some overhead: > > https://llvm-compile-time-tracker.com/compare.php?from=2a9f77f6bd48d757b2d45aadcb6cf76ef4b4ef32&to=71ce9e26aec00e4af27a69ccfab8ca1773ed7018&stat=instructions:u > > About 0.3% on clang files. > > Thank you for the notification! Shoo

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-23 Thread Nikita Popov via cfe-commits
nikic wrote: FYI this introduces some overhead: https://llvm-compile-time-tracker.com/compare.php?from=2a9f77f6bd48d757b2d45aadcb6cf76ef4b4ef32&to=71ce9e26aec00e4af27a69ccfab8ca1773ed7018&stat=instructions:u About 0.3% on clang files. https://github.com/llvm/llvm-project/pull/136323 __

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-23 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-22 Thread Erich Keane via cfe-commits
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-22 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/136323 >From 3beecb29772e13c6a1a41877e5e8cbbfb17a88f2 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 18 Apr 2025 12:26:36 -0400 Subject: [PATCH 1/5] Control analysis-based diagnostics with #pragma Previo

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-22 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: Any other changes needed, or are you happy @haoNoQ? @erichkeane @Sirraide want to re-review given the significant reworking? https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing list cfe-commits@lists.llvm.org h

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-21 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/136323 >From 3beecb29772e13c6a1a41877e5e8cbbfb17a88f2 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 18 Apr 2025 12:26:36 -0400 Subject: [PATCH 1/5] Control analysis-based diagnostics with #pragma Previo

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-21 Thread Aaron Ballman via cfe-commits
@@ -202,6 +202,43 @@ class SemaPPCallbacks : public PPCallbacks { break; } } + void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, +diag::Severity Mapping, StringRef Str) override { +// If one of the analysis-based diagnostics

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-21 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > > The current patch actually WILL work with it ONLY enabled on the line > > inside of the function, which I think is much more intuitive. > > Ooo whoa this is awesome!! Sorry for the confusion, I've updated the patch summary accordingly https://github.com/llvm/llvm-proje

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-21 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > The current patch actually WILL work with it ONLY enabled on the line inside > of the function, which I think is much more intuitive. Ooo whoa this is awesome!! https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Erich Keane via cfe-commits
@@ -202,6 +202,43 @@ class SemaPPCallbacks : public PPCallbacks { break; } } + void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, +diag::Severity Mapping, StringRef Str) override { +// If one of the analysis-based diagnostics

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Erich Keane via cfe-commits
erichkeane wrote: > So from the user's perspective we're checking the flag twice: once at the `}` > to see if we need to ramp up the analysis, then again at the diagnostic > location to see if the diagnostic should be discarded. The warning will only > be emitted if it's enabled at both source

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Artem Dergachev via cfe-commits
@@ -202,6 +202,43 @@ class SemaPPCallbacks : public PPCallbacks { break; } } + void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, +diag::Severity Mapping, StringRef Str) override { +// If one of the analysis-based diagnostics

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: So from the user's perspective we're checking the flag twice: once at the `}` to see if we need to ramp up the analysis, then again at the diagnostic location to see if the diagnostic should be discarded. The warning will only be emitted if it's enabled at

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/136323 >From 3beecb29772e13c6a1a41877e5e8cbbfb17a88f2 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 18 Apr 2025 12:26:36 -0400 Subject: [PATCH 1/5] Control analysis-based diagnostics with #pragma Previo

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
@@ -2493,9 +2493,10 @@ class sema::AnalysisBasedWarnings::InterProceduralData { CalledOnceInterProceduralData CalledOnceData; }; -static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag) { - return (unsigned)!D.isIgnored(diag, SourceLocation()); -} +template +static

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
@@ -2504,23 +2505,37 @@ sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema &s) NumUninitAnalysisVariables(0), MaxUninitAnalysisVariablesPerFunction(0), NumUninitAnalysisBlockVisits(0), MaxUninitAnalysisBlockVisitsPerFunction(0) { +} + +// We need this he

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Erich Keane via cfe-commits
@@ -2504,23 +2505,37 @@ sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema &s) NumUninitAnalysisVariables(0), MaxUninitAnalysisVariablesPerFunction(0), NumUninitAnalysisBlockVisits(0), MaxUninitAnalysisBlockVisitsPerFunction(0) { +} + +// We need this he

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Erich Keane via cfe-commits
@@ -2493,9 +2493,10 @@ class sema::AnalysisBasedWarnings::InterProceduralData { CalledOnceInterProceduralData CalledOnceData; }; -static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag) { - return (unsigned)!D.isIgnored(diag, SourceLocation()); -} +template +static

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/136323 >From 3beecb29772e13c6a1a41877e5e8cbbfb17a88f2 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 18 Apr 2025 12:26:36 -0400 Subject: [PATCH 1/4] Control analysis-based diagnostics with #pragma Previo

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
@@ -2493,35 +2493,44 @@ class sema::AnalysisBasedWarnings::InterProceduralData { CalledOnceInterProceduralData CalledOnceData; }; -static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag) { - return (unsigned)!D.isIgnored(diag, SourceLocation()); +static bool isEnable

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
@@ -2493,35 +2493,44 @@ class sema::AnalysisBasedWarnings::InterProceduralData { CalledOnceInterProceduralData CalledOnceData; }; -static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag) { - return (unsigned)!D.isIgnored(diag, SourceLocation()); +static bool isEnable

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread via cfe-commits
@@ -1202,6 +1202,30 @@ Clang also allows you to push and pop the current warning state. This is particularly useful when writing a header file that will be compiled by other people, because you don't know what warning flags they build with. +Note that the following diagnostic

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread via cfe-commits
@@ -2493,35 +2493,44 @@ class sema::AnalysisBasedWarnings::InterProceduralData { CalledOnceInterProceduralData CalledOnceData; }; -static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag) { - return (unsigned)!D.isIgnored(diag, SourceLocation()); +static bool isEnable

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread via cfe-commits
@@ -2493,35 +2493,44 @@ class sema::AnalysisBasedWarnings::InterProceduralData { CalledOnceInterProceduralData CalledOnceData; }; -static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag) { - return (unsigned)!D.isIgnored(diag, SourceLocation()); +static bool isEnable

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
@@ -1202,6 +1202,30 @@ Clang also allows you to push and pop the current warning state. This is particularly useful when writing a header file that will be compiled by other people, because you don't know what warning flags they build with. +Note that the following diagnostic

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/136323 >From 3beecb29772e13c6a1a41877e5e8cbbfb17a88f2 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 18 Apr 2025 12:26:36 -0400 Subject: [PATCH 1/2] Control analysis-based diagnostics with #pragma Previo

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Erich Keane via cfe-commits
@@ -1202,6 +1202,30 @@ Clang also allows you to push and pop the current warning state. This is particularly useful when writing a header file that will be compiled by other people, because you don't know what warning flags they build with. +Note that the following diagnostic

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread via cfe-commits
https://github.com/Sirraide approved this pull request. https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Werror=unreachable-code-aggressive %s + +// Test that analysis-based warnings honor #pragma diagnostic controls. These +// diagnostics are triggered at the end of a function body, so the pragma needs +// to be enabled thr

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread via cfe-commits
@@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Werror=unreachable-code-aggressive %s + +// Test that analysis-based warnings honor #pragma diagnostic controls. These +// diagnostics are triggered at the end of a function body, so the pragma needs +// to be enabled thr

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread via cfe-commits
@@ -2504,24 +2505,28 @@ sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema &s) NumUninitAnalysisVariables(0), MaxUninitAnalysisVariablesPerFunction(0), NumUninitAnalysisBlockVisits(0), MaxUninitAnalysisBlockVisitsPerFunction(0) { +} + +// We need this he

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
@@ -1202,6 +1202,30 @@ Clang also allows you to push and pop the current warning state. This is particularly useful when writing a header file that will be compiled by other people, because you don't know what warning flags they build with. +Note that the following diagnostic

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread via cfe-commits
@@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Werror=unreachable-code-aggressive %s + +// Test that analysis-based warnings honor #pragma diagnostic controls. These +// diagnostics are triggered at the end of a function body, so the pragma needs +// to be enabled thr

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Erich Keane via cfe-commits
@@ -2504,24 +2505,28 @@ sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema &s) NumUninitAnalysisVariables(0), MaxUninitAnalysisVariablesPerFunction(0), NumUninitAnalysisBlockVisits(0), MaxUninitAnalysisBlockVisitsPerFunction(0) { +} + +// We need this he

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Erich Keane via cfe-commits
@@ -1202,6 +1202,30 @@ Clang also allows you to push and pop the current warning state. This is particularly useful when writing a header file that will be compiled by other people, because you don't know what warning flags they build with. +Note that the following diagnostic

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Erich Keane via cfe-commits
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- clang/test/Analysis/pragma-diag-control.cpp clang/

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-analysis Author: Aaron Ballman (AaronBallman) Changes Previously, analysis-based diagnostics (like -Wconsumed) had to be enabled at file scope in order to be run at the end of each function body. This meant that they did not respect #pragma clang

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/136323 Previously, analysis-based diagnostics (like -Wconsumed) had to be enabled at file scope in order to be run at the end of each function body. This meant that they did not respect #pragma clang diagnostic e