Resolve remaining unowned ptr exclusion warnings.
This should allow enabling the GN argument
pdf_enable_unowned_ptr_exclusion = true
on at least the linux bots. This will become important to prevent
backsliding once PDFium builds against raw_ptr.
Change-Id: Id07edfc3340c5633fdcb4940e4d10e3e7cf9f41a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107211
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcodec/jbig2/JBig2_GrdProc.h b/core/fxcodec/jbig2/JBig2_GrdProc.h
index e1e05f3..c543ea1 100644
--- a/core/fxcodec/jbig2/JBig2_GrdProc.h
+++ b/core/fxcodec/jbig2/JBig2_GrdProc.h
@@ -29,7 +29,7 @@
ProgressiveArithDecodeState();
~ProgressiveArithDecodeState();
- std::unique_ptr<CJBig2_Image>* pImage;
+ UnownedPtr<std::unique_ptr<CJBig2_Image>> pImage;
UnownedPtr<CJBig2_ArithDecoder> pArithDecoder;
UnownedPtr<JBig2ArithCtx> gbContext;
UnownedPtr<PauseIndicatorIface> pPause;
diff --git a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
index 1c0f882..16a87cc 100644
--- a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
@@ -13,6 +13,10 @@
#include "core/fxcodec/jbig2/JBig2_GrdProc.h"
#include "core/fxcodec/jbig2/JBig2_Image.h"
+CJBig2_HTRDProc::CJBig2_HTRDProc() = default;
+
+CJBig2_HTRDProc::~CJBig2_HTRDProc() = default;
+
std::unique_ptr<CJBig2_Image> CJBig2_HTRDProc::DecodeArith(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
diff --git a/core/fxcodec/jbig2/JBig2_HtrdProc.h b/core/fxcodec/jbig2/JBig2_HtrdProc.h
index 30e9d9c..2073d8b 100644
--- a/core/fxcodec/jbig2/JBig2_HtrdProc.h
+++ b/core/fxcodec/jbig2/JBig2_HtrdProc.h
@@ -13,6 +13,7 @@
#include <vector>
#include "core/fxcodec/jbig2/JBig2_Image.h"
+#include "core/fxcrt/unowned_ptr.h"
class CJBig2_ArithDecoder;
class CJBig2_BitStream;
@@ -21,6 +22,9 @@
class CJBig2_HTRDProc {
public:
+ CJBig2_HTRDProc();
+ ~CJBig2_HTRDProc();
+
std::unique_ptr<CJBig2_Image> DecodeArith(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
PauseIndicatorIface* pPause);
@@ -33,7 +37,7 @@
bool HMMR;
uint8_t HTEMPLATE;
uint32_t HNUMPATS;
- const std::vector<std::unique_ptr<CJBig2_Image>>* HPATS;
+ UnownedPtr<const std::vector<std::unique_ptr<CJBig2_Image>>> HPATS;
bool HDEFPIXEL;
JBig2ComposeOp HCOMBOP;
bool HENABLESKIP;
diff --git a/core/fxcodec/jbig2/JBig2_TrdProc.h b/core/fxcodec/jbig2/JBig2_TrdProc.h
index 7962c70..bd887d9 100644
--- a/core/fxcodec/jbig2/JBig2_TrdProc.h
+++ b/core/fxcodec/jbig2/JBig2_TrdProc.h
@@ -14,6 +14,7 @@
#include "core/fxcodec/jbig2/JBig2_Image.h"
#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxcrt/unowned_ptr_exclusion.h"
class CJBig2_ArithDecoder;
class CJBig2_ArithIaidDecoder;
@@ -71,7 +72,7 @@
uint32_t SBSTRIPS;
uint32_t SBNUMSYMS;
std::vector<JBig2HuffmanCode> SBSYMCODES;
- CJBig2_Image** SBSYMS;
+ UNOWNED_PTR_EXCLUSION CJBig2_Image** SBSYMS;
JBig2ComposeOp SBCOMBOP;
JBig2Corner REFCORNER;
UnownedPtr<const CJBig2_HuffmanTable> SBHUFFFS;
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index 34c70a8..ea79ecf 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -19,6 +19,7 @@
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_memory_wrappers.h"
#include "core/fxcrt/stl_util.h"
+#include "core/fxcrt/unowned_ptr_exclusion.h"
#include "core/fxge/cfx_fontmgr.h"
#include "core/fxge/cfx_substfont.h"
#include "core/fxge/fx_font.h"
@@ -390,7 +391,7 @@
private:
UnownedPtr<SystemFontInfoIface> const font_info_;
- void* const font_;
+ UNOWNED_PTR_EXCLUSION void* const font_; // void type incompatible.
};
} // namespace
diff --git a/core/fxge/cfx_gemodule.h b/core/fxge/cfx_gemodule.h
index f1f00f6..8560a49 100644
--- a/core/fxge/cfx_gemodule.h
+++ b/core/fxge/cfx_gemodule.h
@@ -12,6 +12,7 @@
#include <memory>
#include "build/build_config.h"
+#include "core/fxcrt/unowned_ptr_exclusion.h"
#if BUILDFLAG(IS_APPLE)
#include "third_party/base/span.h"
@@ -52,7 +53,9 @@
std::unique_ptr<PlatformIface> const m_pPlatform;
std::unique_ptr<CFX_FontMgr> const m_pFontMgr;
std::unique_ptr<CFX_FontCache> const m_pFontCache;
- const char** const m_pUserFontPaths;
+
+ // Exclude because taken from public API.
+ UNOWNED_PTR_EXCLUSION const char** const m_pUserFontPaths;
};
#endif // CORE_FXGE_CFX_GEMODULE_H_
diff --git a/core/fxge/dib/cfx_imagetransformer.h b/core/fxge/dib/cfx_imagetransformer.h
index abd60c4..fbac2aa 100644
--- a/core/fxge/dib/cfx_imagetransformer.h
+++ b/core/fxge/dib/cfx_imagetransformer.h
@@ -11,6 +11,7 @@
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/retain_ptr.h"
+#include "core/fxcrt/unowned_ptr_exclusion.h"
#include "core/fxge/dib/cfx_bitmapstorer.h"
class CFX_DIBBase;
@@ -32,7 +33,7 @@
};
struct CalcData {
- CFX_DIBitmap* bitmap;
+ UNOWNED_PTR_EXCLUSION CFX_DIBitmap* bitmap; // POD struct.
const CFX_Matrix& matrix;
const uint8_t* buf;
uint32_t pitch;
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp
index e4f85eb..f0ce101 100644
--- a/fpdfsdk/fpdf_dataavail.cpp
+++ b/fpdfsdk/fpdf_dataavail.cpp
@@ -17,6 +17,7 @@
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxcrt/unowned_ptr_exclusion.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
#include "public/fpdf_formfill.h"
#include "third_party/base/numerics/safe_conversions.h"
@@ -64,7 +65,8 @@
}
private:
- FX_FILEAVAIL* const avail_;
+ // TODO(tsepez): fix murky ownership in tests.
+ UNOWNED_PTR_EXCLUSION FX_FILEAVAIL* const avail_;
};
class FPDF_FileAccessContext final : public IFX_SeekableReadStream {
@@ -95,7 +97,8 @@
explicit FPDF_FileAccessContext(FPDF_FILEACCESS* file) : file_(file) {}
~FPDF_FileAccessContext() override = default;
- FPDF_FILEACCESS* const file_;
+ // TODO(tsepez): fix murky ownership in tests.
+ UNOWNED_PTR_EXCLUSION FPDF_FILEACCESS* const file_;
};
class FPDF_DownloadHintsContext final : public CPDF_DataAvail::DownloadHints {
diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h
index b10b59a..752fed1 100644
--- a/fpdfsdk/pwl/cpwl_wnd.h
+++ b/fpdfsdk/pwl/cpwl_wnd.h
@@ -14,6 +14,7 @@
#include "core/fxcrt/mask.h"
#include "core/fxcrt/observed_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxcrt/unowned_ptr_exclusion.h"
#include "core/fxcrt/widestring.h"
#include "core/fxge/cfx_color.h"
#include "core/fxge/cfx_renderdevice.h"
@@ -118,7 +119,8 @@
CPWL_Dash sDash;
// Ignore, used internally only:
- CPWL_MsgControl* pMsgControl = nullptr;
+ // TODO(tsepez): fix murky ownership, bare delete.
+ UNOWNED_PTR_EXCLUSION CPWL_MsgControl* pMsgControl = nullptr;
IPWL_FillerNotify::CursorStyle eCursorType =
IPWL_FillerNotify::CursorStyle::kArrow;
};
diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index 090d638..02cb47a 100644
--- a/xfa/fgas/font/cfgas_fontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -66,9 +66,9 @@
uint32_t m_dwCsb[2] = {};
};
-class CFGAS_FontDescriptorInfo {
+struct CFGAS_FontDescriptorInfo {
public:
- CFGAS_FontDescriptor* pFont;
+ UNOWNED_PTR_EXCLUSION CFGAS_FontDescriptor* pFont; // POD struct.
int32_t nPenalty;
bool operator>(const CFGAS_FontDescriptorInfo& other) const {
diff --git a/xfa/fgas/layout/cfgas_txtbreak.h b/xfa/fgas/layout/cfgas_txtbreak.h
index ae69a24..c7b9931 100644
--- a/xfa/fgas/layout/cfgas_txtbreak.h
+++ b/xfa/fgas/layout/cfgas_txtbreak.h
@@ -12,6 +12,8 @@
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/retain_ptr.h"
+#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxcrt/unowned_ptr_exclusion.h"
#include "xfa/fgas/layout/cfgas_break.h"
#include "xfa/fgas/layout/cfgas_char.h"
@@ -49,9 +51,9 @@
Run(const Run& other);
~Run();
- CFGAS_TxtBreak::Engine* pEdtEngine = nullptr;
+ UnownedPtr<CFGAS_TxtBreak::Engine> pEdtEngine;
WideString wsStr;
- int32_t* pWidths = nullptr;
+ UNOWNED_PTR_EXCLUSION int32_t* pWidths = nullptr;
// TODO(thestig): These 2 members probably should be size_t.
int32_t iStart = 0;
int32_t iLength = 0;
@@ -61,7 +63,7 @@
int32_t iHorizontalScale = 100;
int32_t iVerticalScale = 100;
uint32_t dwCharStyles = 0;
- const CFX_RectF* pRect = nullptr;
+ UnownedPtr<const CFX_RectF> pRect;
bool bSkipSpace = true;
};
diff --git a/xfa/fwl/cfwl_event.h b/xfa/fwl/cfwl_event.h
index 385abec..ab9606d 100644
--- a/xfa/fwl/cfwl_event.h
+++ b/xfa/fwl/cfwl_event.h
@@ -7,6 +7,7 @@
#ifndef XFA_FWL_CFWL_EVENT_H_
#define XFA_FWL_CFWL_EVENT_H_
+#include "core/fxcrt/unowned_ptr.h"
#include "v8/include/cppgc/macros.h"
class CFWL_Widget;
@@ -41,8 +42,8 @@
private:
const Type m_type;
- CFWL_Widget* const m_pSrcTarget = nullptr;
- CFWL_Widget* const m_pDstTarget = nullptr;
+ UnownedPtr<CFWL_Widget> const m_pSrcTarget;
+ UnownedPtr<CFWL_Widget> const m_pDstTarget;
};
#endif // XFA_FWL_CFWL_EVENT_H_
diff --git a/xfa/fwl/cfwl_listbox.h b/xfa/fwl/cfwl_listbox.h
index 9f27b65..2236842 100644
--- a/xfa/fwl/cfwl_listbox.h
+++ b/xfa/fwl/cfwl_listbox.h
@@ -10,6 +10,7 @@
#include <memory>
#include <vector>
+#include "core/fxcrt/unowned_ptr.h"
#include "xfa/fwl/cfwl_edit.h"
#include "xfa/fwl/cfwl_event.h"
#include "xfa/fwl/cfwl_listbox.h"
@@ -136,8 +137,8 @@
bool m_bLButtonDown = false;
float m_fItemHeight = 0.0f;
float m_fScorllBarWidth = 0.0f;
- Item* m_hAnchor = nullptr;
- std::vector<std::unique_ptr<Item>> m_ItemArray;
+ std::vector<std::unique_ptr<Item>> m_ItemArray; // Must outlive `m_hAnchor`.
+ UnownedPtr<Item> m_hAnchor;
};
#endif // XFA_FWL_CFWL_LISTBOX_H_
diff --git a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.h b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.h
index e48c9df..859621d 100644
--- a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.h
+++ b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.h
@@ -13,6 +13,7 @@
#include <vector>
#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxcrt/unowned_ptr_exclusion.h"
#include "fxjs/gc/heap.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "v8/include/cppgc/garbage-collected.h"
@@ -33,16 +34,16 @@
struct BreakData {
CPPGC_STACK_ALLOCATED(); // Raw/Unowned pointers allowed.
public:
- CXFA_Node* pLeader;
- CXFA_Node* pTrailer;
+ UNOWNED_PTR_EXCLUSION CXFA_Node* pLeader; // POD struct.
+ UNOWNED_PTR_EXCLUSION CXFA_Node* pTrailer; // POD struct.
bool bCreatePage;
};
struct OverflowData {
CPPGC_STACK_ALLOCATED(); // Raw/Unowned pointers allowed.
public:
- CXFA_Node* pLeader;
- CXFA_Node* pTrailer;
+ UNOWNED_PTR_EXCLUSION CXFA_Node* pLeader; // POD struct.
+ UNOWNED_PTR_EXCLUSION CXFA_Node* pTrailer; // POD struct.
};
CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;