diff options
author | 2023-08-09 23:43:37 -0700 | |
---|---|---|
committer | 2023-08-31 19:06:45 -0700 | |
commit | 42d2e51bf78bec72031e5f7a70422851b302d1f4 (patch) | |
tree | 1325e08734a349786c7e699bb00b2e4f928e7ea8 /tools/aapt2/dump | |
parent | 41e15a0f45e4adc9d8193efd0933e6ca879b3c22 (diff) |
Fix std::unique_ptr error with incomplete CommonFeatureGroup
After upgrading libc++, Clang fails to compile DumpManifest.cpp.
prebuilts/clang/host/linux-x86/clang-r498229/include/c++/v1/__memory/unique_ptr.h:63:19: error: invalid application of 'sizeof' to an incomplete type 'aapt::CommonFeatureGroup'
static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type");
^~~~~~~~~~~
Fix the problem by deferring the instantiation of ~unique_ptr, by
making the ManifestExtractor constructor out-of-line and moving it and
the initialization of commonFeatureGroup_ to a point after
CommonFeatureGroup has been defined.
Bug: b/175635923
Test: treehugger
Change-Id: I9ab51f29724fded24773344aa36763ffeea02d00
Diffstat (limited to 'tools/aapt2/dump')
-rw-r--r-- | tools/aapt2/dump/DumpManifest.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp index 6bf265d2e363..a2b48187c24f 100644 --- a/tools/aapt2/dump/DumpManifest.cpp +++ b/tools/aapt2/dump/DumpManifest.cpp @@ -216,9 +216,7 @@ class SupportsScreen; class ManifestExtractor { public: - - explicit ManifestExtractor(LoadedApk* apk, DumpManifestOptions& options) - : apk_(apk), options_(options) { } + explicit ManifestExtractor(LoadedApk* apk, DumpManifestOptions& options); class Element { public: @@ -509,7 +507,7 @@ class ManifestExtractor { private: std::unique_ptr<xml::XmlResource> doc_; - std::unique_ptr<CommonFeatureGroup> commonFeatureGroup_ = util::make_unique<CommonFeatureGroup>(); + std::unique_ptr<CommonFeatureGroup> commonFeatureGroup_; std::map<std::string, ConfigDescription> locales_; std::map<uint16_t, ConfigDescription> densities_; std::vector<Element*> parent_stack_; @@ -2471,6 +2469,12 @@ static void ToProto(ManifestExtractor::Element* el, pb::Badging* out_badging) { } } +// Define this constructor after the CommonFeatureGroup class definition to avoid errors with using +// std::unique_ptr on an incomplete type. +ManifestExtractor::ManifestExtractor(LoadedApk* apk, DumpManifestOptions& options) + : apk_(apk), options_(options), commonFeatureGroup_(util::make_unique<CommonFeatureGroup>()) { +} + bool ManifestExtractor::Extract(android::IDiagnostics* diag) { // Load the manifest doc_ = apk_->LoadXml("AndroidManifest.xml", diag); |