Skip to content

Commit 805f58f

Browse files
committed
Add a patch to fix compilation issue with Clang 14
1 parent 078c651 commit 805f58f

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
From 43fe09b8ca54e9a38dbd1451796299cc9299635f Mon Sep 17 00:00:00 2001
2+
From: Anatol Pomozov <anatol.pomozov@gmail.com>
3+
Date: Thu, 22 Sep 2022 10:13:05 -0700
4+
Subject: [PATCH] Move Theme::Entry type definition up, before it is used
5+
6+
This helps to fix clang compile error caused by forward declaration
7+
type usage. It tested with Clang 14 at Arch Linux.
8+
9+
What is interesting is GCC 12 does not need this patch. It looks like it
10+
can figure out the forward declaration by itself.
11+
12+
ome/anatol/sources/android-tools/vendor/base/libs/androidfw/AssetManager2.cpp
13+
In file included from /home/anatol/sources/android-tools/vendor/base/libs/androidfw/AssetManager2.cpp:19:
14+
In file included from /home/anatol/sources/android-tools/vendor/base/libs/androidfw/include/androidfw/AssetManager2.h:27:
15+
In file included from /home/anatol/sources/android-tools/vendor/base/libs/androidfw/include/androidfw/ApkAssets.h:26:
16+
In file included from /home/anatol/sources/android-tools/vendor/base/libs/androidfw/include/androidfw/Asset.h:30:
17+
In file included from /home/anatol/sources/android-tools/vendor/incremental_delivery/incfs/util/include/util/map_ptr.h:19:
18+
In file included from /home/anatol/sources/android-tools/vendor/libbase/include/android-base/logging.h:65:
19+
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/functional:62:
20+
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/vector:64:
21+
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/stl_vector.h:1917:54: error: invalid application of 'sizeof' to an incomplete type 'android::Theme::Entry'
22+
= __gnu_cxx::__numeric_traits<ptrdiff_t>::__max / sizeof(_Tp);
23+
^~~~~~~~~~~
24+
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/stl_vector.h:994:16: note: in instantiation of member function 'std::vector<android::Theme::Entry>::_S_max_size' requested here
25+
{ return _S_max_size(_M_get_Tp_allocator()); }
26+
^
27+
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/vector.tcc:70:23: note: in instantiation of member function 'std::vector<android::Theme::Entry>::max_size' requested here
28+
if (__n > this->max_size())
29+
^
30+
/home/anatol/sources/android-tools/vendor/base/libs/androidfw/AssetManager2.cpp:1350:19: note: in instantiation of member function 'std::vector<android::Theme::Entry>::reserve' requested here
31+
theme->entries_.reserve(kInitialReserveSize);
32+
^
33+
/home/anatol/sources/android-tools/vendor/base/libs/androidfw/include/androidfw/AssetManager2.h:554:10: note: forward declaration of 'android::Theme::Entry'
34+
struct Entry;
35+
^
36+
---
37+
libs/androidfw/AssetManager2.cpp | 14 +++++++-------
38+
1 file changed, 7 insertions(+), 7 deletions(-)
39+
40+
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
41+
index 8896a03e3a29..65e50d028b63 100644
42+
--- a/libs/androidfw/AssetManager2.cpp
43+
+++ b/libs/androidfw/AssetManager2.cpp
44+
@@ -1344,6 +1344,13 @@ uint8_t AssetManager2::GetAssignedPackageId(const LoadedPackage* package) const
45+
return 0;
46+
}
47+
48+
+struct Theme::Entry {
49+
+ uint32_t attr_res_id;
50+
+ ApkAssetsCookie cookie;
51+
+ uint32_t type_spec_flags;
52+
+ Res_value value;
53+
+};
54+
+
55+
std::unique_ptr<Theme> AssetManager2::NewTheme() {
56+
constexpr size_t kInitialReserveSize = 32;
57+
auto theme = std::unique_ptr<Theme>(new Theme(this));
58+
@@ -1356,13 +1363,6 @@ Theme::Theme(AssetManager2* asset_manager) : asset_manager_(asset_manager) {
59+
60+
Theme::~Theme() = default;
61+
62+
-struct Theme::Entry {
63+
- uint32_t attr_res_id;
64+
- ApkAssetsCookie cookie;
65+
- uint32_t type_spec_flags;
66+
- Res_value value;
67+
-};
68+
-
69+
namespace {
70+
struct ThemeEntryKeyComparer {
71+
bool operator() (const Theme::Entry& entry, uint32_t attr_res_id) const noexcept {
72+
--
73+
2.37.3
74+

0 commit comments

Comments
 (0)