jroelofs wrote:
At the very least, the fixit shouldn't be recommending precisely what the user
wrote, which funnily enough, gcc also gets wrong:
https://clang.godbolt.org/z/88sqM5xET
https://github.com/llvm/llvm-project/pull/74440
___
cfe-commits mai
karka228 wrote:
> I think this diagnostic should not be firing on `%x` format specifiers:
In the C-standard (7.21.6.1 The fprintf function) when reading about the
o,u,x,X format specifiers it say "The unsigned int argument is converted to
unsigned octal (o), unsigned decimal (u), or unsigned h
jroelofs wrote:
I think this diagnostic should not be firing on `%x` format specifiers:
https://clang.godbolt.org/z/YGh1qdq1h
```
#include
void bad() {
int u = 0;
printf("%x\n", u);
}
```
```
:5:20: warning: format specifies type 'unsigned int' but the argument
has type 'int' [-Wfor
https://github.com/karka228 closed
https://github.com/llvm/llvm-project/pull/74440
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/karka228 updated
https://github.com/llvm/llvm-project/pull/74440
>From 1dd6c32ee8e053c900e23f37d50f8c3f4868858a Mon Sep 17 00:00:00 2001
From: Karl-Johan Karlsson
Date: Tue, 5 Dec 2023 10:03:00 +0100
Subject: [PATCH 01/10] [Sema] Implement support for -Wformat-signedness
In
karka228 wrote:
> LGTM!
Thanks. I will rebase and then "squash and merge" this to the main branch.
https://github.com/llvm/llvm-project/pull/74440
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo
https://github.com/AaronBallman approved this pull request.
LGTM!
https://github.com/llvm/llvm-project/pull/74440
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/karka228 updated
https://github.com/llvm/llvm-project/pull/74440
>From aa9d6cd10ff32fdcdd3d1b2ef334aa70f56cccb1 Mon Sep 17 00:00:00 2001
From: Karl-Johan Karlsson
Date: Tue, 5 Dec 2023 10:03:00 +0100
Subject: [PATCH 01/10] [Sema] Implement support for -Wformat-signedness
In
@@ -0,0 +1,223 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+
+// Verify that -Wformat-signedness alone
@@ -0,0 +1,223 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+
+// Verify that -Wformat-signedness alone
@@ -0,0 +1,223 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+
+// Verify that -Wformat-signedness alone
@@ -0,0 +1,223 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+
+// Verify that -Wformat-signedness alone
@@ -0,0 +1,223 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+
+// Verify that -Wformat-signedness alone
@@ -0,0 +1,223 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -std=c11 -fsyntax-only -verify
-Wformat -Wformat-signedness %s
+
+// Verify that -Wformat-signedness alone
karka228 wrote:
> > With the current implementation `-Wformat-signedness` by itself actually
> > turn on the signedness warnings. This is not compatible with how gcc do it.
> > I guess I have thought that it was not that important to be compatible with
> > gcc in this respect. However if it is
https://github.com/karka228 updated
https://github.com/llvm/llvm-project/pull/74440
>From aa9d6cd10ff32fdcdd3d1b2ef334aa70f56cccb1 Mon Sep 17 00:00:00 2001
From: Karl-Johan Karlsson
Date: Tue, 5 Dec 2023 10:03:00 +0100
Subject: [PATCH 1/9] [Sema] Implement support for -Wformat-signedness
In gc
AaronBallman wrote:
> > Can you also add a test showing the difference between `-Wformat
> > -Wformat-signedness` and `-Wformat-signedness` by itself (which does
> > nothing)?
>
> With the current implementation `-Wformat-signedness` by itself actually turn
> on the signedness warnings. This
github-actions[bot] wrote:
:white_check_mark: With the latest revision this PR passed the Python code
formatter.
https://github.com/llvm/llvm-project/pull/74440
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/m
https://github.com/karka228 updated
https://github.com/llvm/llvm-project/pull/74440
>From aa9d6cd10ff32fdcdd3d1b2ef334aa70f56cccb1 Mon Sep 17 00:00:00 2001
From: Karl-Johan Karlsson
Date: Tue, 5 Dec 2023 10:03:00 +0100
Subject: [PATCH 1/8] [Sema] Implement support for -Wformat-signedness
In gc
karka228 wrote:
> Can you also add a test showing the difference between `-Wformat
> -Wformat-signedness` and `-Wformat-signedness` by itself (which does nothing)?
With the current implementation `-Wformat-signedness` by itself actually turn
on the signedness warnings. This is not compatible w
https://github.com/AaronBallman edited
https://github.com/llvm/llvm-project/pull/74440
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/AaronBallman commented:
Can you also add a test showing the difference between `-Wformat
-Wformat-signedness` and `-Wformat-signedness` by itself (which does nothing)?
I'd also like to see a test demonstrating that `#pragma GCC diagnostic ignored
-Wformat` disables the signe
@@ -12465,6 +12465,20 @@ isArithmeticArgumentPromotion(Sema &S, const
ImplicitCastExpr *ICE) {
S.Context.getFloatingTypeOrder(From, To) < 0;
}
+static analyze_format_string::ArgType::MatchKind
+handleFormatSignedness(analyze_format_string::ArgType::MatchKind Match,
+
https://github.com/karka228 updated
https://github.com/llvm/llvm-project/pull/74440
>From aa9d6cd10ff32fdcdd3d1b2ef334aa70f56cccb1 Mon Sep 17 00:00:00 2001
From: Karl-Johan Karlsson
Date: Tue, 5 Dec 2023 10:03:00 +0100
Subject: [PATCH 1/7] [Sema] Implement support for -Wformat-signedness
In gc
karka228 wrote:
> Sorry for the delayed response, this fell off my radar (thanks @Endilll for
> mentioning this after meeting with @hazohelet!).
No problem. As I wrote above I work in an out of tree backend and I have
already implemented this in our downstream repo. Our customer that requested
AaronBallman wrote:
> > I need to extend the tablegen backend ClangDiagnosticsEmitter with some
> > kind of new option to handle this, right?
>
> Alternatively, you could probably use `DiagnosticsEngine::isIgnored` to check
> if the `-Wformat-signedness` is enabled or not, and control whether
@@ -11881,6 +11896,8 @@ CheckPrintfHandler::checkFormatExpr(const
analyze_printf::PrintfSpecifier &FS,
ICE->getType() == S.Context.UnsignedIntTy) {
// All further checking is done on the subexpression
ImplicitMatch = AT.matchesType(S.Context, ExprTy);
https://github.com/karka228 updated
https://github.com/llvm/llvm-project/pull/74440
>From a80bf9d03f19d48c0aca4af7758dc49516da8825 Mon Sep 17 00:00:00 2001
From: Karl-Johan Karlsson
Date: Tue, 5 Dec 2023 10:03:00 +0100
Subject: [PATCH 1/6] [Sema] Implement support for -Wformat-signedness
In gc
karka228 wrote:
> Alternatively, you could probably use `DiagnosticsEngine::isIgnored` to check
> if the `-Wformat-signedness` is enabled or not, and control whether
> `MatchSignedNess` is `NoMatch` or `Match`, as your first implementation did.
> This way we can achieve GCC compatibility for 1
karka228 wrote:
> > 1. The option -Wformat-signedness is default off.
> >
> > 2. The -Wformat-signedness warnings are not enabled alone by the -Wformat
> > option.
> >
> > 3. The -Wformat-signedness warnings are not enabled alone by the
> > -Wformat-signedness option.
> >
> > 4. The -Wformat
https://github.com/karka228 updated
https://github.com/llvm/llvm-project/pull/74440
>From a80bf9d03f19d48c0aca4af7758dc49516da8825 Mon Sep 17 00:00:00 2001
From: Karl-Johan Karlsson
Date: Tue, 5 Dec 2023 10:03:00 +0100
Subject: [PATCH 1/4] [Sema] Implement support for -Wformat-signedness
In gc
AaronBallman wrote:
> > I'd like to understand the need for this diagnostic a bit more. I realize
> > GCC has it, but it's off-by-default in GCC and `-Wformat` does not enable
> > it either: https://godbolt.org/z/Gxczsjdj5
> > We believe that users don't enable off by default warnings often eno
https://github.com/AaronBallman commented:
I'd like to understand the need for this diagnostic a bit more. I realize GCC
has it, but it's off-by-default in GCC and `-Wformat` does not enable it
either: https://godbolt.org/z/Gxczsjdj5
We believe that users don't enable off by default warnings o
https://github.com/inclyc commented:
Also please add release notes to let users know what has been changed :)
See: `clang/docs/ReleaseNotes.rst`
https://github.com/llvm/llvm-project/pull/74440
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
ht
@@ -918,6 +918,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">,
Group,
HelpText<"Enable warnings for deprecated constructs and define
__DEPRECATED">;
def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group,
Visibility<[ClangOption, CC1Option]>;
+def Wformat_signedness
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat -Wformat-signedness
%s
+
+int printf(const char *restrict format, ...);
+int scanf(const char * restrict, ...);
+
+void test_printf_bool(_Bool x)
+{
+printf("%d", x); // no-warning
+printf("%u",
@@ -11815,6 +11815,18 @@ isArithmeticArgumentPromotion(Sema &S, const
ImplicitCastExpr *ICE) {
S.Context.getFloatingTypeOrder(From, To) < 0;
}
+static clang::analyze_format_string::ArgType::MatchKind
inclyc wrote:
```suggestion
static analyze_format
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat -Wformat-signedness
%s
+
+int printf(const char *restrict format, ...);
+int scanf(const char * restrict, ...);
apple-fcloutier wrote:
Please add tests with enum values:
```c
#include
@@ -918,6 +918,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">,
Group,
HelpText<"Enable warnings for deprecated constructs and define
__DEPRECATED">;
def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group,
Visibility<[ClangOption, CC1Option]>;
+def Wformat_signedness
@@ -918,6 +918,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">,
Group,
HelpText<"Enable warnings for deprecated constructs and define
__DEPRECATED">;
def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group,
Visibility<[ClangOption, CC1Option]>;
+def Wformat_signedness
https://github.com/karka228 updated
https://github.com/llvm/llvm-project/pull/74440
>From a80bf9d03f19d48c0aca4af7758dc49516da8825 Mon Sep 17 00:00:00 2001
From: Karl-Johan Karlsson
Date: Tue, 5 Dec 2023 10:03:00 +0100
Subject: [PATCH 1/2] [Sema] Implement support for -Wformat-signedness
In gc
41 matches
Mail list logo