Skip to content

Commit e3da573

Browse files
committed
chromium: Backport a patch
Backport a patch to fix building with CLANG 21. Signed-off-by: Zoltán Böszörményi <[email protected]>
1 parent 112fe39 commit e3da573

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

meta-chromium/recipes-browser/chromium/chromium-gn.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SRC_URI += "\
2727
file://0011-fix-check_version-Only-compare-node.js-major-version.patch \
2828
file://0012-chromium-fix-v4l2-compiler-error-on-arm.patch \
2929
file://6aae0e2353c857d98980ff677bf304288d7c58de.patch \
30+
file://b0ff8c3b258a8816c05bdebf472dbba719d3c491.patch \
3031
"
3132

3233
# ARM/AArch64-specific patches.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From b0ff8c3b258a8816c05bdebf472dbba719d3c491 Mon Sep 17 00:00:00 2001
2+
From: Hans Wennborg <[email protected]>
3+
Date: Tue, 10 Jun 2025 09:51:47 -0700
4+
Subject: [PATCH] Don't return an enum from EnumSizeTraits::Count
5+
6+
`Enum::kMaxValue + 1` may be outside the representable range of the
7+
enum, which Clang will treat as an error in constexpr contexts (see
8+
bug).
9+
10+
Bug: 423841920
11+
Change-Id: I629402cf93bd8419a71f94ff9ed9340d4f88a706
12+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6633292
13+
Auto-Submit: Hans Wennborg <[email protected]>
14+
Commit-Queue: Nico Weber <[email protected]>
15+
Reviewed-by: Nico Weber <[email protected]>
16+
Commit-Queue: Hans Wennborg <[email protected]>
17+
Cr-Commit-Position: refs/heads/main@{#1471871}
18+
19+
Upstream-Status: Backport [https://github.com/chromium/chromium/commit/b0ff8c3b258a8816c05bdebf472dbba719d3c491]
20+
---
21+
base/metrics/histogram_macros_internal.h | 6 +++---
22+
1 file changed, 3 insertions(+), 3 deletions(-)
23+
24+
diff --git a/base/metrics/histogram_macros_internal.h b/base/metrics/histogram_macros_internal.h
25+
index 39b232bc1023b8..daa5515c2ab357 100644
26+
--- a/base/metrics/histogram_macros_internal.h
27+
+++ b/base/metrics/histogram_macros_internal.h
28+
@@ -28,16 +28,16 @@ namespace base::internal {
29+
template <typename Enum>
30+
requires(std::is_enum_v<Enum>)
31+
struct EnumSizeTraits {
32+
- static constexpr Enum Count() {
33+
+ static constexpr uintmax_t Count() {
34+
if constexpr (requires { Enum::kMaxValue; }) {
35+
// Since the UMA histogram macros expect a value one larger than the max
36+
// defined enumerator value, add one.
37+
- return static_cast<Enum>(base::to_underlying(Enum::kMaxValue) + 1);
38+
+ return static_cast<uintmax_t>(base::to_underlying(Enum::kMaxValue) + 1);
39+
} else {
40+
static_assert(
41+
sizeof(Enum) == 0,
42+
"enumerator must define kMaxValue enumerator to use this macro!");
43+
- return Enum();
44+
+ return 0;
45+
}
46+
}
47+
};

0 commit comments

Comments
 (0)