@@ -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
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
@@ -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
@@ -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
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
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
__
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
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
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
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
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
@@ -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
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
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
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
@@ -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
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
@@ -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
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
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
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
@@ -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
@@ -2504,23 +2505,37 @@ sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema
&s)
NumUninitAnalysisVariables(0), MaxUninitAnalysisVariablesPerFunction(0),
NumUninitAnalysisBlockVisits(0),
MaxUninitAnalysisBlockVisitsPerFunction(0) {
+}
+
+// We need this he
@@ -2504,23 +2505,37 @@ sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema
&s)
NumUninitAnalysisVariables(0), MaxUninitAnalysisVariablesPerFunction(0),
NumUninitAnalysisBlockVisits(0),
MaxUninitAnalysisBlockVisitsPerFunction(0) {
+}
+
+// We need this he
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
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
@@ -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
@@ -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
@@ -2504,24 +2505,28 @@ sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema
&s)
NumUninitAnalysisVariables(0), MaxUninitAnalysisVariablesPerFunction(0),
NumUninitAnalysisBlockVisits(0),
MaxUninitAnalysisBlockVisitsPerFunction(0) {
+}
+
+// We need this he
@@ -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
@@ -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
@@ -2504,24 +2505,28 @@ sema::AnalysisBasedWarnings::AnalysisBasedWarnings(Sema
&s)
NumUninitAnalysisVariables(0), MaxUninitAnalysisVariablesPerFunction(0),
NumUninitAnalysisBlockVisits(0),
MaxUninitAnalysisBlockVisitsPerFunction(0) {
+}
+
+// We need this he
@@ -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
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
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/
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
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
46 matches
Mail list logo