Switch to NOTREACHED_NORETURN() in various core/ sub-directories
Switch from NOTREACHED() to NOTREACHED_NORETURN().
In CFX_StockFontArray, switch from NOTREACHED() to CHECK_LT().
Bug: pdfium:2008
Change-Id: I2e833fca7073582ee5d304525e05be3980e86f51
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/108972
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: K. Moon <kmoon@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index 7654bc1..5ed2414 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -361,9 +361,8 @@
*buf << "/" << item->GetPropertyName() << " ";
break;
}
- default:
- NOTREACHED();
- break;
+ case CPDF_ContentMarkItem::kNone:
+ NOTREACHED_NORETURN();
}
// Write BDC (begin dictionary content) operator.
@@ -573,8 +572,7 @@
*buf << " W* ";
break;
case CFX_FillRenderOptions::FillType::kNoFill:
- NOTREACHED();
- break;
+ NOTREACHED_NORETURN();
}
// Use a no-op path-painting operator to terminate the path without
diff --git a/core/fpdfapi/edit/cpdf_stringarchivestream.cpp b/core/fpdfapi/edit/cpdf_stringarchivestream.cpp
index 4d9f7f2..48033b0 100644
--- a/core/fpdfapi/edit/cpdf_stringarchivestream.cpp
+++ b/core/fpdfapi/edit/cpdf_stringarchivestream.cpp
@@ -14,8 +14,7 @@
CPDF_StringArchiveStream::~CPDF_StringArchiveStream() = default;
FX_FILESIZE CPDF_StringArchiveStream::CurrentOffset() const {
- NOTREACHED();
- return false;
+ NOTREACHED_NORETURN();
}
bool CPDF_StringArchiveStream::WriteBlock(pdfium::span<const uint8_t> buffer) {
diff --git a/core/fpdfapi/font/cfx_stockfontarray.cpp b/core/fpdfapi/font/cfx_stockfontarray.cpp
index b6793ff..3142525 100644
--- a/core/fpdfapi/font/cfx_stockfontarray.cpp
+++ b/core/fpdfapi/font/cfx_stockfontarray.cpp
@@ -11,7 +11,7 @@
#include "core/fpdfapi/font/cpdf_font.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
-#include "third_party/base/notreached.h"
+#include "third_party/base/check_op.h"
CFX_StockFontArray::CFX_StockFontArray() = default;
@@ -29,10 +29,8 @@
RetainPtr<CPDF_Font> CFX_StockFontArray::GetFont(
CFX_FontMapper::StandardFont index) const {
- if (index < std::size(m_StockFonts))
- return m_StockFonts[index];
- NOTREACHED();
- return nullptr;
+ CHECK_LT(index, std::size(m_StockFonts));
+ return m_StockFonts[index];
}
void CFX_StockFontArray::SetFont(CFX_FontMapper::StandardFont index,
diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp
index 1eda1d9..63eba37 100644
--- a/core/fpdfdoc/cpdf_defaultappearance.cpp
+++ b/core/fpdfdoc/cpdf_defaultappearance.cpp
@@ -135,8 +135,7 @@
static_cast<int>(g * 255 + 0.5f),
static_cast<int>(b * 255 + 0.5f)));
}
- NOTREACHED();
- return absl::nullopt;
+ NOTREACHED_NORETURN();
}
// static
diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp
index d26655f..b492b5f 100644
--- a/core/fpdfdoc/cpvt_fontmap.cpp
+++ b/core/fpdfdoc/cpvt_fontmap.cpp
@@ -77,17 +77,14 @@
int32_t CPVT_FontMap::GetWordFontIndex(uint16_t word,
FX_Charset charset,
int32_t nFontIndex) {
- NOTREACHED();
- return 0;
+ NOTREACHED_NORETURN();
}
int32_t CPVT_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) {
- NOTREACHED();
- return 0;
+ NOTREACHED_NORETURN();
}
FX_Charset CPVT_FontMap::CharSetFromUnicode(uint16_t word,
FX_Charset nOldCharset) {
- NOTREACHED();
- return FX_Charset::kANSI;
+ NOTREACHED_NORETURN();
}