[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-06 Thread Max Coplan via cfe-commits

https://github.com/vegerot created 
https://github.com/llvm/llvm-project/pull/97926

This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in 
-Wextra.

This patch also adds a test to check that -Wimplicit-fallthrough is included in 
-Wextra.

Note: This patch may regress performance when building with -Wextra.
This is because -Wextra requires forming a CFG for every function.


>From 2ba0fe208a6f676cc6ab6ccabb015bb8788e145e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Sat, 6 Jul 2024 17:22:55 -0700
Subject: [PATCH] [clang] Add -Wimplicit-fallthrough to -Wextra

This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in 
-Wextra.

This patch also adds a test to check that -Wimplicit-fallthrough is included in 
-Wextra.

Note: This patch may regress performance when building with -Wextra.
This is because -Wextra requires forming a CFG for every function.
---
 clang/include/clang/Basic/DiagnosticGroups.td| 1 +
 clang/test/Sema/fallthrough-attr.c   | 1 +
 clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2241f8481484e2..a875f665b10f9d 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1063,6 +1063,7 @@ def Extra : DiagGroup<"extra", [
 StringConcatation,
 FUseLdPath,
 CastFunctionTypeMismatch,
+ImplicitFallthrough,
   ]>;
 
 def Most : DiagGroup<"most", [
diff --git a/clang/test/Sema/fallthrough-attr.c 
b/clang/test/Sema/fallthrough-attr.c
index de50ebf39d42f6..6cc19136f30a7e 100644
--- a/clang/test/Sema/fallthrough-attr.c
+++ b/clang/test/Sema/fallthrough-attr.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough 
%s
 
 int fallthrough_attribute_spelling(int n) {
diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp 
b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
index 11df2cbfb53f09..cbbff1f1793b88 100644
--- a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
+++ b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
 
 int fallthrough_compatibility_macro_from_command_line(int n) {
   switch (n) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-06 Thread Max Coplan via cfe-commits

https://github.com/vegerot ready_for_review 
https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-06 Thread Max Coplan via cfe-commits

vegerot wrote:

@AaronBallman please review

https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-06 Thread Max Coplan via cfe-commits

https://github.com/vegerot updated 
https://github.com/llvm/llvm-project/pull/97926

>From c05d739d105b76fcf83985b20762809f6eea6f40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Sat, 6 Jul 2024 17:22:55 -0700
Subject: [PATCH] [clang] Add -Wimplicit-fallthrough to -Wextra

This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in 
-Wextra.

This patch also adds a test to check that -Wimplicit-fallthrough is included in 
-Wextra.

Note: This patch may regress performance when building with -Wextra.
This is because -Wextra requires forming a CFG for every function.
---
 clang/include/clang/Basic/DiagnosticGroups.td| 1 +
 clang/test/Sema/fallthrough-attr.c   | 1 +
 clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2241f8481484e..a875f665b10f9 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1063,6 +1063,7 @@ def Extra : DiagGroup<"extra", [
 StringConcatation,
 FUseLdPath,
 CastFunctionTypeMismatch,
+ImplicitFallthrough,
   ]>;
 
 def Most : DiagGroup<"most", [
diff --git a/clang/test/Sema/fallthrough-attr.c 
b/clang/test/Sema/fallthrough-attr.c
index de50ebf39d42f..6cc19136f30a7 100644
--- a/clang/test/Sema/fallthrough-attr.c
+++ b/clang/test/Sema/fallthrough-attr.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough 
%s
 
 int fallthrough_attribute_spelling(int n) {
diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp 
b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
index 11df2cbfb53f0..cbbff1f1793b8 100644
--- a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
+++ b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
 
 int fallthrough_compatibility_macro_from_command_line(int n) {
   switch (n) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-25 Thread Max Coplan via cfe-commits

vegerot wrote:

I'm pretty sure I enabled the warning correctly.  @AaronBallman are we good to 
land?

https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-26 Thread Max Coplan via cfe-commits
Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl
Message-ID:
In-Reply-To: 


https://github.com/vegerot updated 
https://github.com/llvm/llvm-project/pull/97926

>From eb83d32dcf26cf5a8f749400beaccf6688b9107d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Fri, 26 Jul 2024 14:56:12 -0700
Subject: [PATCH 1/2] [libcxx][regex] add [[clang::fallthrough]] to suppress
 fallthrough warning

---
 libcxx/include/regex | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/regex b/libcxx/include/regex
index b814135121321..463fea1638454 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -3921,7 +3921,7 @@ _ForwardIterator basic_regex<_CharT, 
_Traits>::__parse_character_escape(
   if (__hd == -1)
 __throw_regex_error();
   __sum = 16 * __sum + static_cast(__hd);
-  // fallthrough
+[[clang::fallthrough]];
 case 'x':
   ++__first;
   if (__first == __last)

>From cec4051cf50c29c4bf89db183afd8459578e70fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Sat, 6 Jul 2024 17:22:55 -0700
Subject: [PATCH 2/2] [clang] Add -Wimplicit-fallthrough to -Wextra

This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in 
-Wextra.

This patch also adds a test to check that -Wimplicit-fallthrough is included in 
-Wextra.

Note: This patch may regress performance when building with -Wextra.
This is because -Wextra requires forming a CFG for every function.
---
 clang/include/clang/Basic/DiagnosticGroups.td| 1 +
 clang/test/Sema/fallthrough-attr.c   | 1 +
 clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 19c3f1e043349..2a307679c9283 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1067,6 +1067,7 @@ def Extra : DiagGroup<"extra", [
 StringConcatation,
 FUseLdPath,
 CastFunctionTypeMismatch,
+ImplicitFallthrough,
   ]>;
 
 def Most : DiagGroup<"most", [
diff --git a/clang/test/Sema/fallthrough-attr.c 
b/clang/test/Sema/fallthrough-attr.c
index de50ebf39d42f..6cc19136f30a7 100644
--- a/clang/test/Sema/fallthrough-attr.c
+++ b/clang/test/Sema/fallthrough-attr.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough 
%s
 
 int fallthrough_attribute_spelling(int n) {
diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp 
b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
index 11df2cbfb53f0..cbbff1f1793b8 100644
--- a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
+++ b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
 
 int fallthrough_compatibility_macro_from_command_line(int n) {
   switch (n) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-26 Thread Max Coplan via cfe-commits
Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl
Message-ID:
In-Reply-To: 


vegerot wrote:

@AaronBallman I stacked this diff on top of #100821 to remove that build error.

https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-27 Thread Max Coplan via cfe-commits
Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl
Message-ID:
In-Reply-To: 



@@ -3921,7 +3921,7 @@ _ForwardIterator basic_regex<_CharT, 
_Traits>::__parse_character_escape(
   if (__hd == -1)
 __throw_regex_error();
   __sum = 16 * __sum + static_cast(__hd);
-  // fallthrough
+[[clang::fallthrough]];

vegerot wrote:

Sorry, I'm new to contributing to LLVM.  This was my thought process:

This PR has two stacked commits.  The first commit is the same commit that is 
in #100821.  This is needed so that the CI for the second commit (which is this 
PR) passes.

Once the first PR lands, I'll update this PR to just have a single commit.

Does that make sense?  If I unstack this PR now, the CI will fail.

https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-27 Thread Max Coplan via cfe-commits
Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl
Message-ID:
In-Reply-To: 


https://github.com/vegerot edited 
https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-27 Thread Max Coplan via cfe-commits
Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl
Message-ID:
In-Reply-To: 



@@ -3921,7 +3921,7 @@ _ForwardIterator basic_regex<_CharT, 
_Traits>::__parse_character_escape(
   if (__hd == -1)
 __throw_regex_error();
   __sum = 16 * __sum + static_cast(__hd);
-  // fallthrough
+[[clang::fallthrough]];

vegerot wrote:

edit: just read your other comment 
https://github.com/llvm/llvm-project/pull/100821#issuecomment-2254201186

I will mark this PR as a Draft until the #100821 lands :) 

https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-27 Thread Max Coplan via cfe-commits
Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl
Message-ID:
In-Reply-To: 


https://github.com/vegerot converted_to_draft 
https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-28 Thread Max Coplan via cfe-commits
Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl
Message-ID:
In-Reply-To: 


https://github.com/vegerot updated 
https://github.com/llvm/llvm-project/pull/97926

>From 1f231975f2f6b59375bbe88241e533ec18725aaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Fri, 26 Jul 2024 14:56:12 -0700
Subject: [PATCH 1/2] [libcxx][regex] add `[[__fallthrough__]]` to suppress
 fallthrough warning

Summary:
The diff #97926 is stacked on top of this patch because this file
reports an error when enabling `-Wimplicit-fallthrough` in `-Wextra`.

Test plan:

```sh
$ time (mkdir build_runtimes && cd build_runtimes && set -x && 
CC=../build/bin/clang CXX=../build/bin/clang++ cmake -G Ninja ../runtimes 
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind'  
&& ninja && bin/llvm-lit -sv ../libcxx/test/std/re )
```

note: whether I put a `break;` or fallthrough, the tests pass anyways
which is sus.
---
 libcxx/include/regex | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/regex b/libcxx/include/regex
index b814135121321..17666fe4eaedf 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -3921,7 +3921,7 @@ _ForwardIterator basic_regex<_CharT, 
_Traits>::__parse_character_escape(
   if (__hd == -1)
 __throw_regex_error();
   __sum = 16 * __sum + static_cast(__hd);
-  // fallthrough
+  [[__fallthrough__]];
 case 'x':
   ++__first;
   if (__first == __last)

>From 5767b5f61d8d7d6272004542d9266acb524c1752 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Sat, 6 Jul 2024 17:22:55 -0700
Subject: [PATCH 2/2] [clang] Add -Wimplicit-fallthrough to -Wextra

This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in 
-Wextra.

This patch also adds a test to check that -Wimplicit-fallthrough is included in 
-Wextra.

Note: This patch may regress performance when building with -Wextra.
This is because -Wextra requires forming a CFG for every function.
---
 clang/include/clang/Basic/DiagnosticGroups.td| 1 +
 clang/test/Sema/fallthrough-attr.c   | 1 +
 clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 19c3f1e043349..2a307679c9283 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1067,6 +1067,7 @@ def Extra : DiagGroup<"extra", [
 StringConcatation,
 FUseLdPath,
 CastFunctionTypeMismatch,
+ImplicitFallthrough,
   ]>;
 
 def Most : DiagGroup<"most", [
diff --git a/clang/test/Sema/fallthrough-attr.c 
b/clang/test/Sema/fallthrough-attr.c
index de50ebf39d42f..6cc19136f30a7 100644
--- a/clang/test/Sema/fallthrough-attr.c
+++ b/clang/test/Sema/fallthrough-attr.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough 
%s
 
 int fallthrough_attribute_spelling(int n) {
diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp 
b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
index 11df2cbfb53f0..cbbff1f1793b8 100644
--- a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
+++ b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
 
 int fallthrough_compatibility_macro_from_command_line(int n) {
   switch (n) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-20 Thread Max Coplan via cfe-commits

vegerot wrote:

> I would put up a branch on http://llvm-compile-time-tracker.com (instructions 
> in the `About` page) and see how this impacts compile times. We've always 
> left diagnostics out of -Wextra that require a CFG, so getting performance 
> measurements is important.

Thanks!  The `About` page says

> If you are an LLVM contributor who **regularly** does compile-time sensitive 
> work

Do you think I should still ask for permission or should I leave it to someone 
else?

https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-20 Thread Max Coplan via cfe-commits

https://github.com/vegerot updated 
https://github.com/llvm/llvm-project/pull/97926

>From 9640f00fac2be5984b6a0ee2f7f917a58f7e53d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Sat, 6 Jul 2024 17:22:55 -0700
Subject: [PATCH] [clang] Add -Wimplicit-fallthrough to -Wextra

This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in 
-Wextra.

This patch also adds a test to check that -Wimplicit-fallthrough is included in 
-Wextra.

Note: This patch may regress performance when building with -Wextra.
This is because -Wextra requires forming a CFG for every function.
---
 clang/include/clang/Basic/DiagnosticGroups.td| 1 +
 clang/test/Sema/fallthrough-attr.c   | 1 +
 clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 19c3f1e043349..2a307679c9283 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1067,6 +1067,7 @@ def Extra : DiagGroup<"extra", [
 StringConcatation,
 FUseLdPath,
 CastFunctionTypeMismatch,
+ImplicitFallthrough,
   ]>;
 
 def Most : DiagGroup<"most", [
diff --git a/clang/test/Sema/fallthrough-attr.c 
b/clang/test/Sema/fallthrough-attr.c
index de50ebf39d42f..6cc19136f30a7 100644
--- a/clang/test/Sema/fallthrough-attr.c
+++ b/clang/test/Sema/fallthrough-attr.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough 
%s
 
 int fallthrough_attribute_spelling(int n) {
diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp 
b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
index 11df2cbfb53f0..cbbff1f1793b8 100644
--- a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
+++ b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
 
 int fallthrough_compatibility_macro_from_command_line(int n) {
   switch (n) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-07-21 Thread Max Coplan via cfe-commits

vegerot wrote:

> CTMark is not compiled with `-Wextra`, so we'd not get any useful data out of 
> this patch. What changes does one have to do to enable 
> `-Wimplicit-fallthrough` by default (not just for `-Wextra`)?

@nikic done!  At 
[vegerot/llvm-project/perf/add-implicit-fallthrough-to-wextra](https://github.com/vegerot/llvm-project/tree/perf/add-implicit-fallthrough-to-wextra)

https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-08-23 Thread Max Coplan via cfe-commits

https://github.com/vegerot updated 
https://github.com/llvm/llvm-project/pull/97926

>From 55e3359cf82d766e8b361b6f167d6cc445853eb0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Sat, 6 Jul 2024 17:22:55 -0700
Subject: [PATCH] [clang] Add -Wimplicit-fallthrough to -Wextra

This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in 
-Wextra.

This patch also adds a test to check that -Wimplicit-fallthrough is included in 
-Wextra.

Note: This patch may regress performance when building with -Wextra.
This is because -Wextra requires forming a CFG for every function.
---
 clang/include/clang/Basic/DiagnosticGroups.td| 1 +
 clang/test/Sema/fallthrough-attr.c   | 1 +
 clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 19c3f1e0433496..2a307679c9283a 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1067,6 +1067,7 @@ def Extra : DiagGroup<"extra", [
 StringConcatation,
 FUseLdPath,
 CastFunctionTypeMismatch,
+ImplicitFallthrough,
   ]>;
 
 def Most : DiagGroup<"most", [
diff --git a/clang/test/Sema/fallthrough-attr.c 
b/clang/test/Sema/fallthrough-attr.c
index de50ebf39d42f6..6cc19136f30a7e 100644
--- a/clang/test/Sema/fallthrough-attr.c
+++ b/clang/test/Sema/fallthrough-attr.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough 
%s
 
 int fallthrough_attribute_spelling(int n) {
diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp 
b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
index 11df2cbfb53f09..cbbff1f1793b88 100644
--- a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
+++ b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
 
 int fallthrough_compatibility_macro_from_command_line(int n) {
   switch (n) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-08-23 Thread Max Coplan via cfe-commits

https://github.com/vegerot ready_for_review 
https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-08-23 Thread Max Coplan via cfe-commits

vegerot wrote:

@mordante @AaronBallman This diff is ready for review 🙂 

https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-09-14 Thread Max Coplan via cfe-commits

vegerot wrote:

@AaronBallman sure.  Should I still use http://llvm-compile-time-tracker.com/ , 
or do I run the benchmark another way? 

https://github.com/llvm/llvm-project/pull/97926
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)

2024-09-14 Thread Max Coplan via cfe-commits

https://github.com/vegerot updated 
https://github.com/llvm/llvm-project/pull/97926

>From 7d221cbcf91248f44b016aea107109756fa9f785 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Max=20=F0=9F=91=A8=F0=9F=8F=BD=E2=80=8D=F0=9F=92=BB=20Copl?=
 =?UTF-8?q?an?= 
Date: Sat, 6 Jul 2024 17:22:55 -0700
Subject: [PATCH] [clang] Add -Wimplicit-fallthrough to -Wextra

This patch adds -Wimplicit-fallthrough to -Wextra. GCC already includes it in 
-Wextra.

This patch also adds a test to check that -Wimplicit-fallthrough is included in 
-Wextra.

Note: This patch may regress performance when building with -Wextra.
This is because -Wextra requires forming a CFG for every function.
---
 clang/include/clang/Basic/DiagnosticGroups.td| 1 +
 clang/test/Sema/fallthrough-attr.c   | 1 +
 clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index e250f81a0b52a5..78b412c68ea07c 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1067,6 +1067,7 @@ def Extra : DiagGroup<"extra", [
 StringConcatation,
 FUseLdPath,
 CastFunctionTypeMismatch,
+ImplicitFallthrough,
   ]>;
 
 def Most : DiagGroup<"most", [
diff --git a/clang/test/Sema/fallthrough-attr.c 
b/clang/test/Sema/fallthrough-attr.c
index de50ebf39d42f6..6cc19136f30a7e 100644
--- a/clang/test/Sema/fallthrough-attr.c
+++ b/clang/test/Sema/fallthrough-attr.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
 // RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wextra %s
 // RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough 
%s
 
 int fallthrough_attribute_spelling(int n) {
diff --git a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp 
b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
index 11df2cbfb53f09..cbbff1f1793b88 100644
--- a/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
+++ b/clang/test/SemaCXX/switch-implicit-fallthrough-macro.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCLANG_PREFIX -DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[clang::fallthrough]] %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wimplicit-fallthrough 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -Wextra 
-DCOMMAND_LINE_FALLTHROUGH=[[fallthrough]] -DUNCHOSEN=[[clang::fallthrough]] %s
 
 int fallthrough_compatibility_macro_from_command_line(int n) {
   switch (n) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits