Add NOLINTNEXTLINE() to public methods with murky ownership.
Otherwise, clang analyzer is concerned about object lifetimes.
See chromium's docs/clang_tidy.md for a description of this style
of NOLINT comment.
Change-Id: Id0df8df0f50d1c4a84a663d22993de65a69eb016
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/100680
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
index d27999d..7c7d420 100644
--- a/fpdfsdk/fpdf_annot.cpp
+++ b/fpdfsdk/fpdf_annot.cpp
@@ -1415,8 +1415,9 @@
if (FPDFAnnot_GetSubtype(annot) != FPDF_ANNOT_LINK)
return nullptr;
+ // Unretained reference in public API. NOLINTNEXTLINE
return FPDFLinkFromCPDFDictionary(
- CPDFAnnotContextFromFPDFAnnotation(annot)->GetMutableAnnotDict().Get());
+ CPDFAnnotContextFromFPDFAnnotation(annot)->GetMutableAnnotDict());
}
FPDF_EXPORT int FPDF_CALLCONV
diff --git a/fpdfsdk/fpdf_attachment.cpp b/fpdfsdk/fpdf_attachment.cpp
index 22f3b3a..44367e8 100644
--- a/fpdfsdk/fpdf_attachment.cpp
+++ b/fpdfsdk/fpdf_attachment.cpp
@@ -87,7 +87,8 @@
if (!name_tree->AddValueAndName(pFile->MakeReference(pDoc), wsName))
return nullptr;
- return FPDFAttachmentFromCPDFObject(pFile.Get());
+ // Unretained reference in public API. NOLINTNEXTLINE
+ return FPDFAttachmentFromCPDFObject(pFile);
}
FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV
@@ -101,8 +102,10 @@
return nullptr;
WideString csName;
+
+ // Unretained reference in public API. NOLINTNEXTLINE
return FPDFAttachmentFromCPDFObject(
- name_tree->LookupValueAndName(index, &csName).Get());
+ name_tree->LookupValueAndName(index, &csName));
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
diff --git a/fpdfsdk/fpdf_doc.cpp b/fpdfsdk/fpdf_doc.cpp
index 6e51eff..746e45c 100644
--- a/fpdfsdk/fpdf_doc.cpp
+++ b/fpdfsdk/fpdf_doc.cpp
@@ -317,7 +317,8 @@
CPDF_Link link = pLinkList->GetLinkAtPoint(
pPage, CFX_PointF(static_cast<float>(x), static_cast<float>(y)), nullptr);
- return FPDFLinkFromCPDFDictionary(link.GetMutableDict().Get());
+ // Unretained reference in public API. NOLINTNEXTLINE
+ return FPDFLinkFromCPDFDictionary(link.GetMutableDict());
}
FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page,
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 1677d89..467a8f3 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -704,7 +704,8 @@
if (!pTextObj)
return nullptr;
- return FPDFFontFromCPDFFont(pTextObj->GetFont().Get());
+ // Unretained reference in public API. NOLINTNEXTLINE
+ return FPDFFontFromCPDFFont(pTextObj->GetFont());
}
FPDF_EXPORT unsigned long FPDF_CALLCONV
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index 65b3c9d..211de79 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -1003,7 +1003,9 @@
if (!pDoc)
return nullptr;
CPDF_ViewerPreferences viewRef(pDoc);
- return FPDFPageRangeFromCPDFArray(viewRef.PrintPageRange().Get());
+
+ // Unretained reference in public API. NOLINTNEXTLINE
+ return FPDFPageRangeFromCPDFArray(viewRef.PrintPageRange());
}
FPDF_EXPORT size_t FPDF_CALLCONV
@@ -1082,9 +1084,10 @@
return nullptr;
ByteString dest_name(name);
+
// TODO(tsepez): murky ownership, should caller get a reference?
- return FPDFDestFromCPDFArray(
- CPDF_NameTree::LookupNamedDest(pDoc, dest_name).Get());
+ // Unretained reference in public API. NOLINTNEXTLINE
+ return FPDFDestFromCPDFArray(CPDF_NameTree::LookupNamedDest(pDoc, dest_name));
}
#ifdef PDF_ENABLE_V8