Skip to content

Commit 9d80200

Browse files
committed
switch to standard C++ fallthrough attribute
We require C++20 now, so we can switch to the C++17 [[fallthrough]]. Change-Id: I5c34cd4154bca28f4d950524e5b2ffb1e7ec8afd Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/6388177 Reviewed-by: Lei Zhang <[email protected]>
1 parent 10fc52d commit 9d80200

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

src/common/convert_UTF.cc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,15 @@ ConversionResult ConvertUTF16toUTF8 (const UTF16** sourceStart, const UTF16* sou
297297
case 4:
298298
*--target = (UTF8)((ch | byteMark) & byteMask);
299299
ch >>= 6;
300-
BP_FALLTHROUGH;
300+
[[fallthrough]];
301301
case 3:
302302
*--target = (UTF8)((ch | byteMark) & byteMask);
303303
ch >>= 6;
304-
BP_FALLTHROUGH;
304+
[[fallthrough]];
305305
case 2:
306306
*--target = (UTF8)((ch | byteMark) & byteMask);
307307
ch >>= 6;
308-
BP_FALLTHROUGH;
308+
[[fallthrough]];
309309
case 1:
310310
*--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
311311
}
@@ -338,10 +338,10 @@ Boolean isLegalUTF8(const UTF8 *source, int length) {
338338
/* Everything else falls through when "true"... */
339339
case 4:
340340
if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
341-
BP_FALLTHROUGH;
341+
[[fallthrough]];
342342
case 3:
343343
if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
344-
BP_FALLTHROUGH;
344+
[[fallthrough]];
345345
case 2:
346346
if ((a = (*--srcptr)) > 0xBF) return false;
347347

@@ -353,7 +353,7 @@ Boolean isLegalUTF8(const UTF8 *source, int length) {
353353
case 0xF4: if (a > 0x8F) return false; break;
354354
default: if (a < 0x80) return false;
355355
}
356-
BP_FALLTHROUGH;
356+
[[fallthrough]];
357357
case 1: if (*source >= 0x80 && *source < 0xC2) return false;
358358
}
359359
if (*source > 0xF4) return false;
@@ -399,12 +399,12 @@ ConversionResult ConvertUTF8toUTF16 (const UTF8** sourceStart, const UTF8* sourc
399399
*/
400400
switch (extraBytesToRead) {
401401
/* remember, illegal UTF-8 */
402-
case 5: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
402+
case 5: ch += *source++; ch <<= 6; [[fallthrough]];
403403
/* remember, illegal UTF-8 */
404-
case 4: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
405-
case 3: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
406-
case 2: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
407-
case 1: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
404+
case 4: ch += *source++; ch <<= 6; [[fallthrough]];
405+
case 3: ch += *source++; ch <<= 6; [[fallthrough]];
406+
case 2: ch += *source++; ch <<= 6; [[fallthrough]];
407+
case 1: ch += *source++; ch <<= 6; [[fallthrough]];
408408
case 0: ch += *source++;
409409
}
410410
ch -= offsetsFromUTF8[extraBytesToRead];
@@ -493,15 +493,15 @@ ConversionResult ConvertUTF32toUTF8 (const UTF32** sourceStart, const UTF32* sou
493493
case 4:
494494
*--target = (UTF8)((ch | byteMark) & byteMask);
495495
ch >>= 6;
496-
BP_FALLTHROUGH;
496+
[[fallthrough]];
497497
case 3:
498498
*--target = (UTF8)((ch | byteMark) & byteMask);
499499
ch >>= 6;
500-
BP_FALLTHROUGH;
500+
[[fallthrough]];
501501
case 2:
502502
*--target = (UTF8)((ch | byteMark) & byteMask);
503503
ch >>= 6;
504-
BP_FALLTHROUGH;
504+
[[fallthrough]];
505505
case 1:
506506
*--target = (UTF8) (ch | firstByteMark[bytesToWrite]);
507507
}
@@ -534,11 +534,11 @@ ConversionResult ConvertUTF8toUTF32 (const UTF8** sourceStart, const UTF8* sourc
534534
* The cases all fall through. See "Note A" below.
535535
*/
536536
switch (extraBytesToRead) {
537-
case 5: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
538-
case 4: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
539-
case 3: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
540-
case 2: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
541-
case 1: ch += *source++; ch <<= 6; BP_FALLTHROUGH;
537+
case 5: ch += *source++; ch <<= 6; [[fallthrough]];
538+
case 4: ch += *source++; ch <<= 6; [[fallthrough]];
539+
case 3: ch += *source++; ch <<= 6; [[fallthrough]];
540+
case 2: ch += *source++; ch <<= 6; [[fallthrough]];
541+
case 1: ch += *source++; ch <<= 6; [[fallthrough]];
542542
case 0: ch += *source++;
543543
}
544544
ch -= offsetsFromUTF8[extraBytesToRead];

src/common/macros.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@
3131

3232
#include <stddef.h>
3333

34-
// Ensure that this macro definition stays in a private header file: clang
35-
// suggests the first macro expanding to [[clang::fallthrough]] in its
36-
// diagnostics, so if BP_FALLTHROUGH is visible in code depending on breakpad,
37-
// clang would suggest BP_FALLTHROUGH for code depending on breakpad, instead of
38-
// the client code's own fallthrough macro.
39-
// TODO(thakis): Once everyone uses C++17, use its [[fallthrough]] instead.
40-
#if defined(__clang__)
41-
#define BP_FALLTHROUGH [[clang::fallthrough]]
42-
#else
43-
#define BP_FALLTHROUGH
44-
#endif
45-
4634
// TODO: Delete when we require C++23.
4735
#ifndef unreachable
4836
#define unreachable() __builtin_unreachable()

src/processor/minidump.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,7 @@ string MinidumpModule::code_identifier() const {
24692469
break;
24702470
}
24712471
// Otherwise fall through to the case below.
2472-
BP_FALLTHROUGH;
2472+
[[fallthrough]];
24732473
}
24742474

24752475
case MD_OS_MAC_OS_X:
@@ -5823,7 +5823,7 @@ bool Minidump::Read() {
58235823
stream_type << ", but can only deal with one";
58245824
return false;
58255825
}
5826-
BP_FALLTHROUGH;
5826+
[[fallthrough]];
58275827
}
58285828

58295829
default: {

0 commit comments

Comments
 (0)