Max =?utf-8?b?8J+RqPCfj73igI3wn5K7?= Copl Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/97...@github.com>
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?= <mchc...@gmail.com> 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<regex_constants::error_escape>(); __sum = 16 * __sum + static_cast<unsigned>(__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?= <mchc...@gmail.com> 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