Kaydet (Commit) 14cd5182 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Replace fallthrough comments with new SAL_FALLTHROUGH macro

...which (in LIBO_INTERNAL_ONLY) for Clang expands to [[clang::fallthrough]] in
preparation of enabling -Wimplicit-fallthrough.  (This is only relevant for
C++11, as neither C nor old C++ has a way to annotate intended fallthroughs.)

Could use BOOST_FALLTHROUGH instead of introducing our own SAL_FALLTHROUGH, but
that would require adding back in dependencies on boost_headers to many
libraries where we carefully removed any remaining Boost dependencies only
recently.  (At least make SAL_FALLTHROUGH strictly LIBO_INTERNAL_ONLY, so its
future evolution will not have any impact on the stable URE interface.)  C++17
will have a proper [[fallthroug]], eventually removing the need for a macro
altogether.

Change-Id: I342a7610a107db7d7a344ea9cbddfd9714d7e9ca
üst e4bb2b4f
......@@ -617,7 +617,7 @@ void VCLXAccessibleToolBox::ProcessWindowEvent( const VclWindowEvent& rVclWindow
}
m_aAccessibleChildren.clear();
//!!! no break to call base class
SAL_FALLTHROUGH; // call base class
}
default:
......
......@@ -757,7 +757,7 @@ namespace basegfx
}
else
{
// wanted fall-through to default
SAL_FALLTHROUGH; // wanted fall-through to default
}
}
default: // B2DLineJoin::Bevel
......
......@@ -109,8 +109,7 @@ namespace basegfx
o_rPolyPolygon.append(aCurrPoly);
aCurrPoly.clear();
}
// FALLTHROUGH intended to add coordinate data as 1st point of new polygon
SAL_FALLTHROUGH; // to add coordinate data as 1st point of new polygon
}
case 'l' :
case 'L' :
......@@ -150,7 +149,7 @@ namespace basegfx
case 'h' :
{
bRelative = true;
// FALLTHROUGH intended
SAL_FALLTHROUGH;
}
case 'H' :
{
......@@ -180,7 +179,7 @@ namespace basegfx
case 'v' :
{
bRelative = true;
// FALLTHROUGH intended
SAL_FALLTHROUGH;
}
case 'V' :
{
......@@ -210,7 +209,7 @@ namespace basegfx
case 's' :
{
bRelative = true;
// FALLTHROUGH intended
SAL_FALLTHROUGH;
}
case 'S' :
{
......@@ -269,7 +268,7 @@ namespace basegfx
case 'c' :
{
bRelative = true;
// FALLTHROUGH intended
SAL_FALLTHROUGH;
}
case 'C' :
{
......@@ -319,7 +318,7 @@ namespace basegfx
case 'q' :
{
bRelative = true;
// FALLTHROUGH intended
SAL_FALLTHROUGH;
}
case 'Q' :
{
......@@ -370,7 +369,7 @@ namespace basegfx
case 't' :
{
bRelative = true;
// FALLTHROUGH intended
SAL_FALLTHROUGH;
}
case 'T' :
{
......@@ -444,7 +443,7 @@ namespace basegfx
case 'a' :
{
bRelative = true;
// FALLTHROUGH intended
SAL_FALLTHROUGH;
}
case 'A' :
{
......
......@@ -546,7 +546,8 @@ void SbiParser::Resume()
{
aGen.Gen( SbiOpcode::RESUME_, 0 );
break;
} // fall through
}
SAL_FALLTHROUGH;
case SYMBOL:
if( MayBeLabel() )
{
......@@ -554,7 +555,8 @@ void SbiParser::Resume()
aGen.Gen( SbiOpcode::RESUME_, nLbl );
Next();
break;
} // fall through
}
SAL_FALLTHROUGH;
default:
Error( ERRCODE_BASIC_LABEL_EXPECTED );
}
......
......@@ -171,7 +171,7 @@ bool IncomingRequest::execute_throw(
}
break;
}
// fall through
SAL_FALLTHROUGH;
default:
{
OSL_ASSERT(object_.is());
......
......@@ -194,7 +194,7 @@ void Marshal::writeValue(
break;
case typelib_TypeClass_BOOLEAN:
assert(*static_cast< sal_uInt8 const * >(value) <= 1);
// fall through
SAL_FALLTHROUGH;
case typelib_TypeClass_BYTE:
write8(buffer, *static_cast< sal_uInt8 const * >(value));
break;
......
......@@ -364,7 +364,8 @@ typelib_TypeClass cpp_vtable_call(
}
TYPELIB_DANGER_RELEASE( pTD );
}
} // else perform queryInterface()
SAL_FALLTHROUGH; // else perform queryInterface()
}
default:
{
typelib_InterfaceMethodTypeDescription *pMethodTD =
......
......@@ -424,7 +424,8 @@ void unoInterfaceProxyDispatch(
}
TYPELIB_DANGER_RELEASE( pTD );
}
} // else perform queryInterface()
SAL_FALLTHROUGH; // else perform queryInterface()
}
default:
// dependent dispatch
cpp_call(
......
......@@ -1738,7 +1738,7 @@ void Bridge::map_to_java(
jni.ensure_no_exception();
break;
}
// fall through
SAL_FALLTHROUGH;
}
default:
{
......
......@@ -1215,7 +1215,7 @@ namespace cairocanvas
{
case rendering::PathJoinType::NONE:
bNoLineJoin = true;
// cairo doesn't have join type NONE so we use MITER as it's pretty close
SAL_FALLTHROUGH; // cairo doesn't have join type NONE so we use MITER as it's pretty close
case rendering::PathJoinType::MITER:
cairo_set_line_join( mpCairo.get(), CAIRO_LINE_JOIN_MITER );
break;
......
......@@ -288,7 +288,7 @@ namespace cairocanvas
case rendering::TextDirection::WEAK_RIGHT_TO_LEFT:
nLayoutMode |= TEXT_LAYOUT_BIDI_RTL;
// FALLTHROUGH intended
SAL_FALLTHROUGH;
case rendering::TextDirection::STRONG_RIGHT_TO_LEFT:
nLayoutMode |= TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG;
nLayoutMode |= TEXT_LAYOUT_TEXTORIGIN_RIGHT;
......
......@@ -608,7 +608,7 @@ namespace vclcanvas
case rendering::TextDirection::WEAK_RIGHT_TO_LEFT:
nLayoutMode |= TEXT_LAYOUT_BIDI_RTL;
// FALLTHROUGH intended
SAL_FALLTHROUGH;
case rendering::TextDirection::STRONG_RIGHT_TO_LEFT:
nLayoutMode |= TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG;
nLayoutMode |= TEXT_LAYOUT_TEXTORIGIN_RIGHT;
......
......@@ -563,7 +563,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs)
case CHINDICATE_NONE :
// no longer used, use both as default
m_eIndicate = CHINDICATE_BOTH;
// fall-through intended to BOTH
SAL_FALLTHROUGH; // to BOTH
case CHINDICATE_BOTH :
m_pRbBoth->Check(); break;
case CHINDICATE_UP :
......
......@@ -186,7 +186,7 @@ codemaker::UnoType::Sort TypeManager::decompose(
}
break;
}
// fall through
SAL_FALLTHROUGH;
case codemaker::UnoType::Sort::Void:
case codemaker::UnoType::Sort::Boolean:
case codemaker::UnoType::Sort::Byte:
......
......@@ -271,7 +271,7 @@ void Dependencies::insert(OUString const & name, bool base) {
{
insert(b2u(arg));
}
// fall through
SAL_FALLTHROUGH;
case UnoType::Sort::Sequence:
case UnoType::Sort::Enum:
case UnoType::Sort::PlainStruct:
......
......@@ -104,7 +104,7 @@ void Includes::add(OString const & entityName) {
{
add(arg);
}
// fall through
SAL_FALLTHROUGH;
case codemaker::UnoType::Sort::Sequence:
case codemaker::UnoType::Sort::Enum:
case codemaker::UnoType::Sort::PlainStruct:
......
......@@ -235,7 +235,7 @@ SpecialType translateUnoTypeToDescriptor(
}
return SPECIAL_TYPE_INTERFACE;
}
// fall through
SAL_FALLTHROUGH;
case codemaker::UnoType::Sort::Sequence:
case codemaker::UnoType::Sort::Enum:
case codemaker::UnoType::Sort::PlainStruct:
......
......@@ -695,7 +695,7 @@ void Access::setName(OUString const & aName)
}
}
}
// fall through
SAL_FALLTHROUGH;
case Node::KIND_LOCALIZED_PROPERTY:
// renaming a property could only work for an extension property,
// but a localized property is never an extension property
......
......@@ -650,7 +650,7 @@ void Components::parseFiles(
if (!recursive) {
return;
}
// fall through
SAL_FALLTHROUGH;
default:
throw css::uno::RuntimeException(
"cannot open directory " + url);
......@@ -808,7 +808,7 @@ void Components::parseXcsXcuIniLayer(
case ':':
case '\\':
prefix.append('\\');
// fall through
SAL_FALLTHROUGH;
default:
prefix.append(c);
}
......
......@@ -517,7 +517,7 @@ css::registry::RegistryValueType RegistryKey::getValueType()
{
return css::registry::RegistryValueType_STRINGLIST;
}
// fall through
SAL_FALLTHROUGH;
default:
return css::registry::RegistryValueType_NOT_DEFINED;
}
......
......@@ -155,7 +155,7 @@ Type getDynamicType(css::uno::Any const & value) {
return TYPE_HEXBINARY_LIST;
}
}
// fall through
SAL_FALLTHROUGH;
default:
return TYPE_ERROR;
}
......
......@@ -260,7 +260,7 @@ xmlreader::XmlReader::Text ValueParser::getTextMode() const {
if (!items_.empty()) {
break;
}
// fall through
SAL_FALLTHROUGH;
case STATE_IT:
return
(type_ == TYPE_STRING || type_ == TYPE_STRING_LIST ||
......@@ -292,7 +292,7 @@ bool ValueParser::startElement(
state_ = STATE_IT;
return true;
}
// fall through
SAL_FALLTHROUGH;
case STATE_IT:
if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals("unicode") &&
......
......@@ -116,7 +116,7 @@ bool XcdParser::startElement(
return true;
}
state_ = STATE_COMPONENTS;
// fall through
SAL_FALLTHROUGH;
case STATE_COMPONENTS:
if (nsId == ParseManager::NAMESPACE_OOR &&
name.equals("component-schema"))
......
......@@ -160,7 +160,7 @@ bool XcsParser::startElement(
state_ = STATE_TEMPLATES;
return true;
}
// fall through
SAL_FALLTHROUGH;
case STATE_TEMPLATES_DONE:
if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
name.equals("component"))
......@@ -190,7 +190,7 @@ bool XcsParser::startElement(
}
break;
}
// fall through
SAL_FALLTHROUGH;
case STATE_COMPONENT:
assert(!elements_.empty());
switch (elements_.top().node->kind()) {
......
......@@ -645,7 +645,7 @@ void XcuParser::handleUnknownGroupProp(
recordModification(false);
break;
}
// fall through
SAL_FALLTHROUGH;
default:
SAL_WARN(
"configmgr",
......
......@@ -75,8 +75,10 @@ namespace connectivity
else
pWild += pos;
else
break; // WARNING in certain circumstances
// it will run into the next 'case'!!
break;
// WARNING/TODO: in certain circumstances it will run into
// the next 'case'!
SAL_FALLTHROUGH;
case CHAR_WILD:
while ( *pWild == CHAR_WILD )
pWild++;
......
......@@ -1032,7 +1032,7 @@ bool ORowSetValue::getBool() const
break;
}
}
// run through
SAL_FALLTHROUGH;
case DataType::DECIMAL:
case DataType::NUMERIC:
......@@ -1930,7 +1930,7 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
case DataType::OBJECT:
default:
OSL_ENSURE( false, "ORowSetValue::getDate: cannot retrieve the data!" );
// NO break!
SAL_FALLTHROUGH;
case DataType::BINARY:
case DataType::VARBINARY:
......
......@@ -1515,7 +1515,7 @@ bool implUpdateObject(const Reference< XRowUpdate >& _rxUpdatedObject,
_rxUpdatedObject->updateBinaryStream(_nColumnIndex, xStream, xStream->available());
break;
}
// run through
SAL_FALLTHROUGH;
default:
bSuccessfullyReRouted = false;
}
......@@ -1622,7 +1622,7 @@ bool implSetObject( const Reference< XParameters >& _rxParameters,
_rxParameters->setBinaryStream(_nColumnIndex, xStream, xStream->available());
break;
}
// run through
SAL_FALLTHROUGH;
default:
bSuccessfullyReRouted = false;
......
......@@ -1289,7 +1289,7 @@ bool ODbaseTable::CreateFile(const INetURLObject& aFile, bool& bCreateMemo)
break;
case DataType::LONGVARBINARY:
bBinary = true;
// run through
SAL_FALLTHROUGH;
case DataType::LONGVARCHAR:
cTyp = 'M';
break;
......@@ -1770,7 +1770,7 @@ bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, const OValueRefRow& pOrgRo
case DataType::DOUBLE:
case DataType::TIMESTAMP:
bSetZero = true;
//fall-through
SAL_FALLTHROUGH;
case DataType::LONGVARBINARY:
case DataType::DATE:
case DataType::BIT:
......
......@@ -240,7 +240,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
break;
case -1:
bKnowCaseSensivity = false;
/** run through */
SAL_FALLTHROUGH;
case 0:
bCaseSensitiveDir = false;
}
......
......@@ -734,7 +734,7 @@ bool OFlatTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 n
{
case IResultSetHelper::FIRST:
m_nRowPos = 0;
// run through
SAL_FALLTHROUGH;
case IResultSetHelper::NEXT:
{
assert(m_nRowPos >= 0);
......
......@@ -1224,8 +1224,8 @@ bool implSetObject( const Reference< XParameters >& _rxParameters,
_rxParameters->setBinaryStream(_nColumnIndex, xStream, xStream->available());
break;
}
SAL_FALLTHROUGH;
}
// run through
default:
bSuccessfullyReRouted = false;
......
......@@ -2493,7 +2493,7 @@ void OSQLParseNode::parseLeaf(OUStringBuffer& rString, const SQLParseNodeParamet
rString.append(m_aNodeValue);
break;
}
// fall through
SAL_FALLTHROUGH;
default:
if (!rString.isEmpty() && m_aNodeValue.toChar() != '.' && m_aNodeValue.toChar() != ':' )
{
......
......@@ -1294,7 +1294,7 @@ static inline void typelib_typedescription_destructExtendedMembers(
case typelib_TypeClass_STRUCT:
delete[] reinterpret_cast< typelib_StructTypeDescription * >(pTD)->
pParameterizedTypes;
// Fall-through intentional
SAL_FALLTHROUGH;
case typelib_TypeClass_EXCEPTION:
{
typelib_CompoundTypeDescription * pCTD = reinterpret_cast<typelib_CompoundTypeDescription*>(pTD);
......
......@@ -189,7 +189,7 @@ Parser::Parser(
state = STATE_COMPONENTS;
break;
}
// fall through
SAL_FALLTHROUGH;
case STATE_COMPONENT_INITIAL:
if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId
&& name.equals(RTL_CONSTASCII_STRINGPARAM("implementation")))
......@@ -1433,7 +1433,7 @@ void cppuhelper::ServiceManager::readRdbDirectory(
SAL_INFO("cppuhelper", "Ignored optional " << uri);
return;
}
// fall through
SAL_FALLTHROUGH;
default:
throw css::uno::DeploymentException(
"Cannot open directory " + uri,
......@@ -1495,7 +1495,7 @@ bool cppuhelper::ServiceManager::readLegacyRdbFile(rtl::OUString const & uri) {
}
}
}
// fall through
SAL_FALLTHROUGH;
default:
return false;
}
......
......@@ -2125,7 +2125,7 @@ void cppuhelper::TypeManager::readRdbDirectory(
SAL_INFO("cppuhelper", "Ignored optional " << uri);
return;
}
// fall through
SAL_FALLTHROUGH;
default:
throw css::uno::DeploymentException(
"Cannot open directory " + uri,
......
......@@ -737,8 +737,8 @@ IMPL_LINK_TYPED(FmSearchDialog, OnSearchProgress, const FmSearchProgress*, pProg
? RID_STR_SEARCH_GENERAL_ERROR
: RID_STR_SEARCH_NORECORD;
ScopedVclPtrInstance<MessageDialog>::Create(this, CUI_RES(nErrorId))->Execute();
SAL_FALLTHROUGH;
}
// NO break !
case FmSearchProgress::STATE_CANCELED:
EnableSearchUI(true);
if (m_lnkCanceledNotFoundHdl.IsSet())
......
......@@ -572,7 +572,7 @@ Graphic GraphicFilterEmboss::GetFilteredGraphic( const Graphic& rGraphic, double
switch( mpCtlLight->GetActualRP() )
{
default: OSL_FAIL("svx::GraphicFilterEmboss::GetFilteredGraphic(), unknown Reference Point!" );
/* Fall through */
SAL_FALLTHROUGH;
case RP_LT: nAzim = 4500; nElev = 4500; break;
case RP_MT: nAzim = 9000; nElev = 4500; break;
case RP_RT: nAzim = 13500; nElev = 4500; break;
......
......@@ -974,7 +974,7 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa
m_pBtnEngineering->Enable();
m_pBtnEngineering->Check( bThousand );
}
// fallthru
SAL_FALLTHROUGH;
case CAT_NUMBER:
case CAT_PERCENT:
case CAT_CURRENCY:
......
......@@ -2053,7 +2053,7 @@ IMPL_LINK_NOARG_TYPED(SvxExtParagraphTabPage, WidowHdl_Impl, Button*, void)
if ( m_pOrphanBox->GetState() == TRISTATE_FALSE )
m_pKeepTogetherBox->Enable();
// no break
SAL_FALLTHROUGH;
case TRISTATE_INDET:
m_pWidowRowNo->Enable(false);
m_pWidowRowLabel->Enable(false);
......@@ -2075,7 +2075,7 @@ IMPL_LINK_NOARG_TYPED(SvxExtParagraphTabPage, OrphanHdl_Impl, Button*, void)
if ( m_pWidowBox->GetState() == TRISTATE_FALSE )
m_pKeepTogetherBox->Enable();
// no break
SAL_FALLTHROUGH;
case TRISTATE_INDET:
m_pOrphanRowNo->Enable(false);
m_pOrphanRowLabel->Enable(false);
......
......@@ -407,7 +407,7 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
{
default: ; //prevent warning
OSL_FAIL( "svx::SvxTextAttrPage::FillItemSet(), unhandled state!" );
/* Fall through */
SAL_FALLTHROUGH;
case TRISTATE_FALSE: eFTS = SDRTEXTFIT_NONE; break;
case TRISTATE_TRUE: eFTS = SDRTEXTFIT_AUTOFIT; break;
}
......
......@@ -155,7 +155,7 @@ SvxLineTabPage::SvxLineTabPage
case FUNIT_M:
case FUNIT_KM:
eFUnit = FUNIT_MM;
// no break -> we now have mm
SAL_FALLTHROUGH; // we now have mm
case FUNIT_MM:
m_pMtrLineWidth->SetSpinSize( 50 );
m_pMtrStartWidth->SetSpinSize( 50 );
......