Split string portion of core/fxcrt/stl_util.h into its own header. Move the recently-added string code in stl_util.h to fx_string_wrappers.h, so bytestring.h can avoid including stl_util.h and reduce its build cost. Then do IWYU to fix the build. Change-Id: I62f695f8284dad242844f7e4592110020aecedfd Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/90870 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h index dfcd700..0f603f2 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.h +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.h
@@ -13,7 +13,7 @@ #include <vector> #include "core/fxcrt/bytestring.h" -#include "core/fxcrt/stl_util.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/unowned_ptr.h" class CPDF_ContentMarks;
diff --git a/core/fpdfapi/edit/cpdf_pagecontentmanager.h b/core/fpdfapi/edit/cpdf_pagecontentmanager.h index 0249d18..d40c87f 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentmanager.h +++ b/core/fpdfapi/edit/cpdf_pagecontentmanager.h
@@ -7,8 +7,8 @@ #include <set> +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/retain_ptr.h" -#include "core/fxcrt/stl_util.h" #include "core/fxcrt/unowned_ptr.h" class CPDF_Array;
diff --git a/core/fpdfapi/edit/cpdf_stringarchivestream.h b/core/fpdfapi/edit/cpdf_stringarchivestream.h index 0b0a489..38e6651 100644 --- a/core/fpdfapi/edit/cpdf_stringarchivestream.h +++ b/core/fpdfapi/edit/cpdf_stringarchivestream.h
@@ -6,7 +6,7 @@ #define CORE_FPDFAPI_EDIT_CPDF_STRINGARCHIVESTREAM_H_ #include "core/fxcrt/fx_stream.h" -#include "core/fxcrt/stl_util.h" +#include "core/fxcrt/fx_string_wrappers.h" class CPDF_StringArchiveStream final : public IFX_ArchiveStream { public:
diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp index 5b6510e..13eab14 100644 --- a/core/fpdfapi/parser/cfdf_document.cpp +++ b/core/fpdfapi/parser/cfdf_document.cpp
@@ -14,7 +14,7 @@ #include "core/fpdfapi/parser/cpdf_syntax_parser.h" #include "core/fpdfapi/parser/fpdf_parser_utility.h" #include "core/fxcrt/cfx_readonlymemorystream.h" -#include "core/fxcrt/stl_util.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "third_party/base/span.h" CFDF_Document::CFDF_Document() = default;
diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h index bb61f8c..eaf2696 100644 --- a/core/fpdfapi/parser/cpdf_stream.h +++ b/core/fpdfapi/parser/cpdf_stream.h
@@ -13,8 +13,8 @@ #include "core/fpdfapi/parser/cpdf_object.h" #include "core/fxcrt/fx_memory_wrappers.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/retain_ptr.h" -#include "core/fxcrt/stl_util.h" class CPDF_Stream final : public CPDF_Object { public:
diff --git a/core/fpdfdoc/cpdf_generateap.cpp b/core/fpdfdoc/cpdf_generateap.cpp index 766d77b..ff876f4 100644 --- a/core/fpdfdoc/cpdf_generateap.cpp +++ b/core/fpdfdoc/cpdf_generateap.cpp
@@ -33,7 +33,7 @@ #include "core/fpdfdoc/cpvt_fontmap.h" #include "core/fpdfdoc/cpvt_variabletext.h" #include "core/fpdfdoc/cpvt_word.h" -#include "core/fxcrt/stl_util.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxge/cfx_renderdevice.h" namespace {
diff --git a/core/fpdfdoc/cpdf_interactiveform.cpp b/core/fpdfdoc/cpdf_interactiveform.cpp index 36bdae1..9c2fcd1 100644 --- a/core/fpdfdoc/cpdf_interactiveform.cpp +++ b/core/fpdfdoc/cpdf_interactiveform.cpp
@@ -28,6 +28,7 @@ #include "core/fpdfdoc/cpdf_filespec.h" #include "core/fpdfdoc/cpdf_formcontrol.h" #include "core/fxcrt/fx_codepage.h" +#include "core/fxcrt/stl_util.h" #include "core/fxge/cfx_substfont.h" #include "core/fxge/fx_font.h" #include "third_party/abseil-cpp/absl/types/optional.h"
diff --git a/core/fpdfdoc/cpdf_linklist.cpp b/core/fpdfdoc/cpdf_linklist.cpp index 0acd1fa..23b324e 100644 --- a/core/fpdfdoc/cpdf_linklist.cpp +++ b/core/fpdfdoc/cpdf_linklist.cpp
@@ -9,6 +9,7 @@ #include "core/fpdfapi/page/cpdf_page.h" #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" +#include "third_party/base/numerics/safe_conversions.h" CPDF_LinkList::CPDF_LinkList() = default;
diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp index dfd4e61..b44353c 100644 --- a/core/fpdfdoc/cpdf_nametree.cpp +++ b/core/fpdfdoc/cpdf_nametree.cpp
@@ -15,6 +15,7 @@ #include "core/fpdfapi/parser/cpdf_reference.h" #include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfapi/parser/fpdf_parser_decode.h" +#include "core/fxcrt/stl_util.h" #include "third_party/base/check.h" #include "third_party/base/ptr_util.h"
diff --git a/core/fpdfdoc/cpdf_structtree.cpp b/core/fpdfdoc/cpdf_structtree.cpp index 133cf5a..bbac010 100644 --- a/core/fpdfdoc/cpdf_structtree.cpp +++ b/core/fpdfdoc/cpdf_structtree.cpp
@@ -13,6 +13,7 @@ #include "core/fpdfapi/parser/cpdf_reference.h" #include "core/fpdfdoc/cpdf_numbertree.h" #include "core/fpdfdoc/cpdf_structelement.h" +#include "core/fxcrt/stl_util.h" namespace {
diff --git a/core/fxcrt/BUILD.gn b/core/fxcrt/BUILD.gn index fb7d04f..9afb408 100644 --- a/core/fxcrt/BUILD.gn +++ b/core/fxcrt/BUILD.gn
@@ -59,6 +59,7 @@ "fx_stream.h", "fx_string.cpp", "fx_string.h", + "fx_string_wrappers.h", "fx_system.cpp", "fx_system.h", "fx_types.h", @@ -165,6 +166,7 @@ "fx_number_unittest.cpp", "fx_random_unittest.cpp", "fx_string_unittest.cpp", + "fx_string_wrappers_unittest.cpp", "fx_system_unittest.cpp", "mask_unittest.cpp", "maybe_owned_unittest.cpp", @@ -175,7 +177,6 @@ "scoped_set_insertion_unittest.cpp", "shared_copy_on_write_unittest.cpp", "span_util_unittest.cpp", - "stl_util_unittest.cpp", "string_pool_template_unittest.cpp", "tree_node_unittest.cpp", "unowned_ptr_unittest.cpp",
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h index 830c50b..8798893 100644 --- a/core/fxcrt/bytestring.h +++ b/core/fxcrt/bytestring.h
@@ -17,8 +17,8 @@ #include <iterator> #include <utility> +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/retain_ptr.h" -#include "core/fxcrt/stl_util.h" #include "core/fxcrt/string_data_template.h" #include "core/fxcrt/string_view_template.h" #include "third_party/abseil-cpp/absl/types/optional.h"
diff --git a/core/fxcrt/fx_string_wrappers.h b/core/fxcrt/fx_string_wrappers.h new file mode 100644 index 0000000..07514bf --- /dev/null +++ b/core/fxcrt/fx_string_wrappers.h
@@ -0,0 +1,25 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CORE_FXCRT_FX_STRING_WRAPPERS_H_ +#define CORE_FXCRT_FX_STRING_WRAPPERS_H_ + +#include <iosfwd> +#include <string> + +#include "core/fxcrt/fx_memory_wrappers.h" + +namespace fxcrt { + +// String that uses partition alloc for backing store. +using string = + std::basic_string<char, std::char_traits<char>, FxStringAllocator<char>>; + +// String stream that uses PartitionAlloc for backing store. +using ostringstream = std:: + basic_ostringstream<char, std::char_traits<char>, FxStringAllocator<char>>; + +} // namespace fxcrt + +#endif // CORE_FXCRT_FX_STRING_WRAPPERS_H_
diff --git a/core/fxcrt/stl_util_unittest.cpp b/core/fxcrt/fx_string_wrappers_unittest.cpp similarity index 92% rename from core/fxcrt/stl_util_unittest.cpp rename to core/fxcrt/fx_string_wrappers_unittest.cpp index ab291a3..788e608 100644 --- a/core/fxcrt/stl_util_unittest.cpp +++ b/core/fxcrt/fx_string_wrappers_unittest.cpp
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "core/fxcrt/stl_util.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/core/fxcrt/stl_util.h b/core/fxcrt/stl_util.h index 7b76f5e..37156af 100644 --- a/core/fxcrt/stl_util.h +++ b/core/fxcrt/stl_util.h
@@ -5,12 +5,9 @@ #ifndef CORE_FXCRT_STL_UTIL_H_ #define CORE_FXCRT_STL_UTIL_H_ -#include <iosfwd> #include <memory> -#include <string> #include <vector> -#include "core/fxcrt/fx_memory_wrappers.h" #include "third_party/base/numerics/safe_conversions.h" #include "third_party/base/numerics/safe_math.h" @@ -47,14 +44,6 @@ return std::vector<T, A>(safe_size.ValueOrDie()); } -// String that uses partition alloc for backing store. -using string = - std::basic_string<char, std::char_traits<char>, FxStringAllocator<char>>; - -// String stream that uses PartitionAlloc for backing store. -using ostringstream = std:: - basic_ostringstream<char, std::char_traits<char>, FxStringAllocator<char>>; - } // namespace fxcrt #endif // CORE_FXCRT_STL_UTIL_H_
diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h index 49d3542..be88677 100644 --- a/core/fxge/win32/cfx_psrenderer.h +++ b/core/fxge/win32/cfx_psrenderer.h
@@ -18,8 +18,8 @@ #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_memory_wrappers.h" #include "core/fxcrt/fx_stream.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/retain_ptr.h" -#include "core/fxcrt/stl_util.h" #include "core/fxcrt/unowned_ptr.h" #include "core/fxge/cfx_graphstatedata.h" #include "third_party/abseil-cpp/absl/types/optional.h"
diff --git a/core/fxge/win32/cgdi_plus_ext.cpp b/core/fxge/win32/cgdi_plus_ext.cpp index 7dffd0e..22297c4 100644 --- a/core/fxge/win32/cgdi_plus_ext.cpp +++ b/core/fxge/win32/cgdi_plus_ext.cpp
@@ -17,8 +17,8 @@ #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/fx_string.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/fx_system.h" -#include "core/fxcrt/stl_util.h" #include "core/fxge/cfx_fillrenderoptions.h" #include "core/fxge/cfx_gemodule.h" #include "core/fxge/cfx_graphstatedata.h"
diff --git a/fpdfsdk/cpdfsdk_appstream.cpp b/fpdfsdk/cpdfsdk_appstream.cpp index 8e884e9..870bac4 100644 --- a/fpdfsdk/cpdfsdk_appstream.cpp +++ b/fpdfsdk/cpdfsdk_appstream.cpp
@@ -27,6 +27,7 @@ #include "core/fpdfdoc/cpdf_formcontrol.h" #include "core/fpdfdoc/cpdf_icon.h" #include "core/fpdfdoc/cpvt_word.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "fpdfsdk/cpdfsdk_formfillenvironment.h" #include "fpdfsdk/cpdfsdk_interactiveform.h" #include "fpdfsdk/cpdfsdk_pageview.h"
diff --git a/fpdfsdk/cpdfsdk_interactiveform.cpp b/fpdfsdk/cpdfsdk_interactiveform.cpp index 892954e..696e16c 100644 --- a/fpdfsdk/cpdfsdk_interactiveform.cpp +++ b/fpdfsdk/cpdfsdk_interactiveform.cpp
@@ -23,7 +23,7 @@ #include "core/fpdfdoc/cpdf_formcontrol.h" #include "core/fpdfdoc/cpdf_interactiveform.h" #include "core/fxcrt/autorestorer.h" -#include "core/fxcrt/stl_util.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_path.h" #include "fpdfsdk/cpdfsdk_actionhandler.h"
diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp index 1feead8..2dd52b2 100644 --- a/fpdfsdk/fpdf_annot.cpp +++ b/fpdfsdk/fpdf_annot.cpp
@@ -30,6 +30,7 @@ #include "core/fpdfdoc/cpdf_generateap.h" #include "core/fpdfdoc/cpdf_interactiveform.h" #include "core/fxcrt/fx_safe_types.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/stl_util.h" #include "core/fxge/cfx_color.h" #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp index 3f84e09..c2fda59 100644 --- a/fpdfsdk/fpdf_edittext.cpp +++ b/fpdfsdk/fpdf_edittext.cpp
@@ -24,6 +24,7 @@ #include "core/fpdfapi/render/charposlist.h" #include "core/fpdftext/cpdf_textpage.h" #include "core/fxcrt/fx_extension.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/stl_util.h" #include "core/fxge/cfx_fontmgr.h" #include "core/fxge/fx_font.h"
diff --git a/fpdfsdk/fpdf_flatten.cpp b/fpdfsdk/fpdf_flatten.cpp index 348a325..1efb188 100644 --- a/fpdfsdk/fpdf_flatten.cpp +++ b/fpdfsdk/fpdf_flatten.cpp
@@ -28,7 +28,7 @@ #include "core/fpdfapi/parser/cpdf_stream.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "core/fpdfdoc/cpdf_annot.h" -#include "core/fxcrt/stl_util.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "fpdfsdk/cpdfsdk_helpers.h" #include "third_party/base/notreached.h"
diff --git a/fpdfsdk/fpdf_ppo.cpp b/fpdfsdk/fpdf_ppo.cpp index 1a7531c..ec42c90 100644 --- a/fpdfsdk/fpdf_ppo.cpp +++ b/fpdfsdk/fpdf_ppo.cpp
@@ -31,6 +31,7 @@ #include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfapi/render/cpdf_pagerendercache.h" #include "core/fxcrt/fx_safe_types.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/unowned_ptr.h" #include "fpdfsdk/cpdfsdk_helpers.h"
diff --git a/fpdfsdk/fpdf_structtree.cpp b/fpdfsdk/fpdf_structtree.cpp index 538ad2e..76fd601 100644 --- a/fpdfsdk/fpdf_structtree.cpp +++ b/fpdfsdk/fpdf_structtree.cpp
@@ -12,6 +12,7 @@ #include "core/fpdfdoc/cpdf_structelement.h" #include "core/fpdfdoc/cpdf_structtree.h" #include "core/fxcrt/fx_safe_types.h" +#include "core/fxcrt/stl_util.h" #include "fpdfsdk/cpdfsdk_helpers.h" namespace {
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp index e142166..ea41d00 100644 --- a/fpdfsdk/fpdf_transformpage.cpp +++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -21,6 +21,7 @@ #include "core/fpdfapi/parser/cpdf_number.h" #include "core/fpdfapi/parser/cpdf_reference.h" #include "core/fpdfapi/parser/cpdf_stream.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxcrt/stl_util.h" #include "core/fxge/cfx_fillrenderoptions.h" #include "core/fxge/cfx_path.h"
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index dce96c4..503d868 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp
@@ -21,7 +21,7 @@ #include "core/fpdfdoc/cpdf_formcontrol.h" #include "core/fpdfdoc/cpdf_interactiveform.h" #include "core/fxcrt/fx_extension.h" -#include "core/fxcrt/stl_util.h" +#include "core/fxcrt/fx_string_wrappers.h" #include "core/fxge/cfx_color.h" #include "fpdfsdk/cpdfsdk_formfillenvironment.h" #include "fpdfsdk/cpdfsdk_interactiveform.h"
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp index 8352247..854471e 100644 --- a/fxjs/xfa/cjx_field.cpp +++ b/fxjs/xfa/cjx_field.cpp
@@ -11,6 +11,7 @@ #include "fxjs/cfx_v8.h" #include "fxjs/fxv8.h" #include "fxjs/js_resources.h" +#include "third_party/base/numerics/safe_conversions.h" #include "v8/include/v8-primitive.h" #include "xfa/fgas/crt/cfgas_decimal.h" #include "xfa/fxfa/cxfa_eventparam.h"