summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2018-02-10 00:51:00 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-10 00:51:00 +0000
commitf6ecadb7aea68fb322bfa1dfce703a24cbd1e395 (patch)
tree7ebb4e1f6dcdd4771096920a8383f8b4bd37f80e /core
parent257900b6dae0fe8d82d48ecc91d92e5dbb3a28bf (diff)
downloadpdfium-f6ecadb7aea68fb322bfa1dfce703a24cbd1e395.tar.xz
Renable -Wimplicit-fallthrough for PDFium.
Didn't find any bugs, but also doesn't require much boilerplate. Bug: TODO Change-Id: I5f30183c55216f1333c79fcb46476d281720873e Reviewed-on: https://pdfium-review.googlesource.com/26210 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nico Weber <thakis@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/page/cpdf_allstates.cpp4
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_dibtransferfunc.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp2
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp2
-rw-r--r--core/fxcrt/fx_extension.cpp3
-rw-r--r--core/fxcrt/fx_fallthrough.h20
-rw-r--r--core/fxcrt/xml/cxml_parser.cpp3
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp13
9 files changed, 49 insertions, 2 deletions
diff --git a/core/fpdfapi/page/cpdf_allstates.cpp b/core/fpdfapi/page/cpdf_allstates.cpp
index afc87a2b5a..d2491bbee7 100644
--- a/core/fpdfapi/page/cpdf_allstates.cpp
+++ b/core/fpdfapi/page/cpdf_allstates.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/page/cpdf_streamcontentparser.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
+#include "core/fxcrt/fx_fallthrough.h"
#include "core/fxge/cfx_graphstatedata.h"
#include "third_party/base/stl_util.h"
@@ -89,6 +90,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
if (pGS->KeyExist("TR2")) {
continue;
}
+ FX_FALLTHROUGH;
case FXBSTR_ID('T', 'R', '2', 0):
m_GeneralState.SetTR(pObject && !pObject->IsName() ? pObject : nullptr);
break;
@@ -131,6 +133,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
if (pGS->KeyExist("BG2")) {
continue;
}
+ FX_FALLTHROUGH;
case FXBSTR_ID('B', 'G', '2', 0):
m_GeneralState.SetBG(pObject);
break;
@@ -138,6 +141,7 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
if (pGS->KeyExist("UCR2")) {
continue;
}
+ FX_FALLTHROUGH;
case FXBSTR_ID('U', 'C', 'R', '2'):
m_GeneralState.SetUCR(pObject);
break;
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index af80fd96ab..e871e0a578 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -26,6 +26,7 @@
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
#include "core/fxcrt/cfx_memorystream.h"
#include "core/fxcrt/fx_extension.h"
+#include "core/fxcrt/fx_fallthrough.h"
#include "core/fxcrt/fx_safe_types.h"
#include "third_party/base/numerics/safe_conversions.h"
#include "third_party/base/ptr_util.h"
@@ -133,6 +134,7 @@ bool CPDF_DataAvail::CheckDocStatus() {
return LoadAllFile();
case PDF_DATAAVAIL_PAGE_LATERLOAD:
m_docStatus = PDF_DATAAVAIL_PAGE;
+ FX_FALLTHROUGH;
default:
m_bDocAvail = true;
return true;
diff --git a/core/fpdfapi/render/cpdf_dibtransferfunc.cpp b/core/fpdfapi/render/cpdf_dibtransferfunc.cpp
index 3b0e8b25a9..959fec383d 100644
--- a/core/fpdfapi/render/cpdf_dibtransferfunc.cpp
+++ b/core/fpdfapi/render/cpdf_dibtransferfunc.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/render/cpdf_transferfunc.h"
+#include "core/fxcrt/fx_fallthrough.h"
CPDF_DIBTransferFunc::CPDF_DIBTransferFunc(
const RetainPtr<CPDF_TransferFunc>& pTransferFunc)
@@ -119,6 +120,7 @@ void CPDF_DIBTransferFunc::TranslateScanline(
}
case FXDIB_Rgb32:
bSkip = true;
+ FX_FALLTHROUGH;
case FXDIB_Argb: {
int index = 0;
for (int i = 0; i < m_Width; i++) {
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 66688a2d4c..6525164547 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -49,6 +49,7 @@
#include "core/fpdfdoc/cpdf_occontext.h"
#include "core/fxcrt/autorestorer.h"
#include "core/fxcrt/cfx_fixedbufgrow.h"
+#include "core/fxcrt/fx_fallthrough.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/maybe_owned.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
@@ -1765,6 +1766,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
// Already handled above, but the compiler is not smart enough to
// realize it. Fall through.
NOTREACHED();
+ FX_FALLTHROUGH;
case TextRenderingMode::MODE_CLIP:
return true;
}
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 38c631d820..7da1b2f946 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -16,6 +16,7 @@
#include "core/fpdfdoc/csection.h"
#include "core/fpdfdoc/ipvt_fontmap.h"
#include "core/fxcrt/fx_codepage.h"
+#include "core/fxcrt/fx_fallthrough.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
@@ -317,6 +318,7 @@ void CPDF_VariableText::SetText(const WideString& swText) {
break;
case 0x09:
word = 0x20;
+ FX_FALLTHROUGH;
default:
wp = InsertWord(wp, word, FX_CHARSET_Default);
break;
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 62cf8a0e04..371f1b5211 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -6,6 +6,8 @@
#include "core/fxcrt/fx_extension.h"
+#include "core/fxcrt/fx_fallthrough.h"
+
#include <algorithm>
#include <cwctype>
@@ -21,6 +23,7 @@ float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) {
switch (pwsStr[iUsedLen]) {
case '-':
bNegtive = true;
+ FX_FALLTHROUGH;
case '+':
iUsedLen++;
break;
diff --git a/core/fxcrt/fx_fallthrough.h b/core/fxcrt/fx_fallthrough.h
new file mode 100644
index 0000000000..5587ee2295
--- /dev/null
+++ b/core/fxcrt/fx_fallthrough.h
@@ -0,0 +1,20 @@
+// Copyright 2018 PDFium 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_FALLTHROUGH_H_
+#define CORE_FXCRT_FX_FALLTHROUGH_H_
+
+// When clang suggests inserting [[clang::fallthrough]], it first checks if
+// it knows of a macro expanding to it, and if so suggests inserting the
+// macro. This means that this macro must be used only in code internal
+// to PDFium, so that PDFium's user code doesn't end up getting suggestions
+// for FX_FALLTHROUGH instead of the user-specific fallthrough macro.
+// So do not include this header in any of PDFium's public headers.
+#if defined(__clang__)
+#define FX_FALLTHROUGH [[clang::fallthrough]]
+#else
+#define FX_FALLTHROUGH
+#endif
+
+#endif // CORE_FXCRT_FX_FALLTHROUGH_H_
diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp
index ae5fd6d0fc..64bb0ec530 100644
--- a/core/fxcrt/xml/cxml_parser.cpp
+++ b/core/fxcrt/xml/cxml_parser.cpp
@@ -14,6 +14,7 @@
#include "core/fxcrt/cfx_utf8decoder.h"
#include "core/fxcrt/cfx_widetextbuf.h"
#include "core/fxcrt/fx_extension.h"
+#include "core/fxcrt/fx_fallthrough.h"
#include "core/fxcrt/xml/cxml_content.h"
#include "core/fxcrt/xml/cxml_element.h"
#include "core/fxcrt/xml/cxml_parser.h"
@@ -200,6 +201,7 @@ uint32_t CXML_Parser::GetCharRef() {
break;
}
iState = 1;
+ FX_FALLTHROUGH;
case 1:
m_dwIndex++;
if (ch == ';') {
@@ -226,6 +228,7 @@ uint32_t CXML_Parser::GetCharRef() {
break;
}
iState = 3;
+ FX_FALLTHROUGH;
case 3:
m_dwIndex++;
if (ch == ';') {
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index b394facace..922f39efcd 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -15,6 +15,14 @@
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/dib/cfx_imagerenderer.h"
#include "core/fxge/dib/cfx_imagestretcher.h"
+#include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
+
+// Ignore fallthrough warnings in agg23 headers.
+#if defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
#include "third_party/agg23/agg_conv_dash.h"
#include "third_party/agg23/agg_conv_stroke.h"
#include "third_party/agg23/agg_curves.h"
@@ -23,8 +31,9 @@
#include "third_party/agg23/agg_rasterizer_scanline_aa.h"
#include "third_party/agg23/agg_renderer_scanline.h"
#include "third_party/agg23/agg_scanline_u.h"
-#include "third_party/base/ptr_util.h"
-#include "third_party/base/stl_util.h"
+#if defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
namespace {