forked from qt-creator/qt-creator
Add Q_FALLTHROUGH for Qt < 5.8
... and make use of it. With gcc 7, the new option -Wimplicit-fallthrough is introduced and added to the -Wextra set, triggering dozens of warnings in our sources. Therefore, we annotate all obviously intended fall-throughs. The ones that are still left are unclear and need to be checked by the respective maintainer. Change-Id: I44ead33cd42a4b41c28ee5fcb5a31db272710bbc Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
4
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
4
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -27,6 +27,8 @@
|
|||||||
#include "ObjectiveCTypeQualifiers.h"
|
#include "ObjectiveCTypeQualifiers.h"
|
||||||
#include "QtContextKeywords.h"
|
#include "QtContextKeywords.h"
|
||||||
|
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@@ -442,7 +444,7 @@ bool Parser::skipUntilStatement()
|
|||||||
case T_AT_THROW:
|
case T_AT_THROW:
|
||||||
if (_languageFeatures.objCEnabled)
|
if (_languageFeatures.objCEnabled)
|
||||||
return true;
|
return true;
|
||||||
|
Q_FALLTHROUGH();
|
||||||
default:
|
default:
|
||||||
consumeToken();
|
consumeToken();
|
||||||
}
|
}
|
||||||
|
54
src/libs/utils/qtcfallthrough.h
Normal file
54
src/libs/utils/qtcfallthrough.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2017 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#ifndef Q_FALLTHROUGH
|
||||||
|
#ifndef QT_HAS_CPP_ATTRIBUTE
|
||||||
|
#ifdef __has_cpp_attribute
|
||||||
|
# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
||||||
|
#else
|
||||||
|
# define QT_HAS_CPP_ATTRIBUTE(x) 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#if QT_HAS_CPP_ATTRIBUTE(fallthrough)
|
||||||
|
# define Q_FALLTHROUGH() [[fallthrough]]
|
||||||
|
#elif QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
|
||||||
|
# define Q_FALLTHROUGH() [[clang::fallthrough]]
|
||||||
|
#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
|
||||||
|
# define Q_FALLTHROUGH() [[gnu::fallthrough]]
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef Q_FALLTHROUGH
|
||||||
|
# if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL)
|
||||||
|
# define Q_FALLTHROUGH() __attribute__((fallthrough))
|
||||||
|
# else
|
||||||
|
# define Q_FALLTHROUGH() (void)0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
@@ -239,6 +239,7 @@ HEADERS += \
|
|||||||
$$PWD/asconst.h \
|
$$PWD/asconst.h \
|
||||||
$$PWD/smallstringfwd.h \
|
$$PWD/smallstringfwd.h \
|
||||||
$$PWD/optional.h \
|
$$PWD/optional.h \
|
||||||
|
$$PWD/qtcfallthrough.h \
|
||||||
$$PWD/../3rdparty/optional/optional.hpp
|
$$PWD/../3rdparty/optional/optional.hpp
|
||||||
|
|
||||||
FORMS += $$PWD/filewizardpage.ui \
|
FORMS += $$PWD/filewizardpage.ui \
|
||||||
|
@@ -175,6 +175,7 @@ Project {
|
|||||||
"proxycredentialsdialog.cpp",
|
"proxycredentialsdialog.cpp",
|
||||||
"proxycredentialsdialog.h",
|
"proxycredentialsdialog.h",
|
||||||
"proxycredentialsdialog.ui",
|
"proxycredentialsdialog.ui",
|
||||||
|
"qtcfallthrough.h",
|
||||||
"qtcassert.cpp",
|
"qtcassert.cpp",
|
||||||
"qtcassert.h",
|
"qtcassert.h",
|
||||||
"qtcolorbutton.cpp",
|
"qtcolorbutton.cpp",
|
||||||
|
@@ -56,6 +56,7 @@
|
|||||||
|
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
@@ -4119,7 +4120,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
case FromReference:
|
case FromReference:
|
||||||
removeReferenceOperator(changes);
|
removeReferenceOperator(changes);
|
||||||
// fallthrough intended
|
Q_FALLTHROUGH();
|
||||||
case FromVariable:
|
case FromVariable:
|
||||||
convertToPointer(changes);
|
convertToPointer(changes);
|
||||||
break;
|
break;
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "compileroptionsbuilder.h"
|
#include "compileroptionsbuilder.h"
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@@ -201,7 +202,8 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc
|
|||||||
if (!objcExt) {
|
if (!objcExt) {
|
||||||
opts += QLatin1String("c++-header");
|
opts += QLatin1String("c++-header");
|
||||||
break;
|
break;
|
||||||
} // else: fall-through!
|
}
|
||||||
|
Q_FALLTHROUGH();
|
||||||
case ProjectFile::ObjCHeader:
|
case ProjectFile::ObjCHeader:
|
||||||
case ProjectFile::ObjCXXHeader:
|
case ProjectFile::ObjCXXHeader:
|
||||||
opts += QLatin1String("objective-c++-header");
|
opts += QLatin1String("objective-c++-header");
|
||||||
@@ -211,7 +213,8 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc
|
|||||||
if (!objcExt) {
|
if (!objcExt) {
|
||||||
opts += QLatin1String("c");
|
opts += QLatin1String("c");
|
||||||
break;
|
break;
|
||||||
} // else: fall-through!
|
}
|
||||||
|
Q_FALLTHROUGH();
|
||||||
case ProjectFile::ObjCSource:
|
case ProjectFile::ObjCSource:
|
||||||
opts += QLatin1String("objective-c");
|
opts += QLatin1String("objective-c");
|
||||||
break;
|
break;
|
||||||
@@ -220,7 +223,8 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc
|
|||||||
if (!objcExt) {
|
if (!objcExt) {
|
||||||
opts += QLatin1String("c++");
|
opts += QLatin1String("c++");
|
||||||
break;
|
break;
|
||||||
} // else: fall-through!
|
}
|
||||||
|
Q_FALLTHROUGH();
|
||||||
case ProjectFile::ObjCXXSource:
|
case ProjectFile::ObjCXXSource:
|
||||||
opts += QLatin1String("objective-c++");
|
opts += QLatin1String("objective-c++");
|
||||||
break;
|
break;
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <debugger/debuggerstartparameters.h>
|
#include <debugger/debuggerstartparameters.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -102,7 +103,7 @@ void GdbAttachEngine::handleAttach(const DebuggerResponse &response)
|
|||||||
notifyEngineIll();
|
notifyEngineIll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if msg != "ptrace: ..." fall through
|
Q_FALLTHROUGH(); // if msg != "ptrace: ..."
|
||||||
default:
|
default:
|
||||||
showStatusMessage(tr("Failed to attach to application: %1")
|
showStatusMessage(tr("Failed to attach to application: %1")
|
||||||
.arg(QString(response.data["msg"].data())));
|
.arg(QString(response.data["msg"].data())));
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include <coreplugin/messagebox.h>
|
#include <coreplugin/messagebox.h>
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
@@ -367,7 +368,7 @@ void GdbRemoteServerEngine::handleAttach(const DebuggerResponse &response)
|
|||||||
notifyInferiorSetupFailed(msgPtraceError(runParameters().startMode));
|
notifyInferiorSetupFailed(msgPtraceError(runParameters().startMode));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if msg != "ptrace: ..." fall through
|
Q_FALLTHROUGH(); // if msg != "ptrace: ..."
|
||||||
default:
|
default:
|
||||||
notifyInferiorSetupFailed(response.data["msg"].data());
|
notifyInferiorSetupFailed(response.data["msg"].data());
|
||||||
}
|
}
|
||||||
|
@@ -60,6 +60,7 @@
|
|||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
#include <utils/basetreeview.h>
|
#include <utils/basetreeview.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -505,7 +506,7 @@ void QmlEngine::errorMessageBoxFinished(int result)
|
|||||||
}
|
}
|
||||||
case QMessageBox::Help: {
|
case QMessageBox::Help: {
|
||||||
HelpManager::handleHelpRequest("qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html");
|
HelpManager::handleHelpRequest("qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html");
|
||||||
// fall through
|
Q_FALLTHROUGH();
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if (state() == InferiorRunOk) {
|
if (state() == InferiorRunOk) {
|
||||||
|
@@ -29,6 +29,8 @@
|
|||||||
#include "watchutils.h"
|
#include "watchutils.h"
|
||||||
#include "watchdata.h"
|
#include "watchdata.h"
|
||||||
|
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -231,8 +233,10 @@ QString formatToolTipAddress(quint64 a)
|
|||||||
switch (rc.size()) {
|
switch (rc.size()) {
|
||||||
case 16:
|
case 16:
|
||||||
rc.insert(12, colon);
|
rc.insert(12, colon);
|
||||||
|
Q_FALLTHROUGH();
|
||||||
case 12:
|
case 12:
|
||||||
rc.insert(8, colon);
|
rc.insert(8, colon);
|
||||||
|
Q_FALLTHROUGH();
|
||||||
case 8:
|
case 8:
|
||||||
rc.insert(4, colon);
|
rc.insert(4, colon);
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
#include "utils/runextensions.h"
|
#include "utils/runextensions.h"
|
||||||
#include "utils/synchronousprocess.h"
|
#include "utils/synchronousprocess.h"
|
||||||
|
|
||||||
@@ -606,7 +607,7 @@ void IosDeviceToolHandlerPrivate::subprocessHasData()
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
case NonStarted:
|
case NonStarted:
|
||||||
qCWarning(toolHandlerLog) << "IosToolHandler unexpected state in subprocessHasData: NonStarted";
|
qCWarning(toolHandlerLog) << "IosToolHandler unexpected state in subprocessHasData: NonStarted";
|
||||||
// pass
|
Q_FALLTHROUGH();
|
||||||
case Starting:
|
case Starting:
|
||||||
case StartedInferior:
|
case StartedInferior:
|
||||||
// read some data
|
// read some data
|
||||||
@@ -771,7 +772,7 @@ void IosDeviceToolHandlerPrivate::stop(int errorCode)
|
|||||||
switch (oldState) {
|
switch (oldState) {
|
||||||
case NonStarted:
|
case NonStarted:
|
||||||
qCWarning(toolHandlerLog) << "IosToolHandler::stop() when state was NonStarted";
|
qCWarning(toolHandlerLog) << "IosToolHandler::stop() when state was NonStarted";
|
||||||
// pass
|
Q_FALLTHROUGH();
|
||||||
case Starting:
|
case Starting:
|
||||||
switch (op){
|
switch (op){
|
||||||
case OpNone:
|
case OpNone:
|
||||||
@@ -786,7 +787,7 @@ void IosDeviceToolHandlerPrivate::stop(int errorCode)
|
|||||||
case OpDeviceInfo:
|
case OpDeviceInfo:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// pass
|
Q_FALLTHROUGH();
|
||||||
case StartedInferior:
|
case StartedInferior:
|
||||||
case XmlEndProcessed:
|
case XmlEndProcessed:
|
||||||
toolExited(errorCode);
|
toolExited(errorCode);
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -358,6 +359,7 @@ bool FormEditorScene::event(QEvent * event)
|
|||||||
currentTool()->keyPressEvent(static_cast<QKeyEvent*>(event));
|
currentTool()->keyPressEvent(static_cast<QKeyEvent*>(event));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Q_FALLTHROUGH();
|
||||||
default: return QGraphicsScene::event(event);
|
default: return QGraphicsScene::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,6 +69,8 @@
|
|||||||
|
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@@ -387,6 +389,7 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker)
|
|||||||
case QMessageBox::Help:
|
case QMessageBox::Help:
|
||||||
HelpManager::handleHelpRequest(
|
HelpManager::handleHelpRequest(
|
||||||
"qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html");
|
"qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html");
|
||||||
|
Q_FALLTHROUGH();
|
||||||
case QMessageBox::Cancel:
|
case QMessageBox::Cancel:
|
||||||
// The actual error message has already been logged.
|
// The actual error message has already been logged.
|
||||||
logState(tr("Failed to connect."));
|
logState(tr("Failed to connect."));
|
||||||
|
@@ -53,6 +53,7 @@
|
|||||||
// Needed for the load&save actions in the context menu
|
// Needed for the load&save actions in the context menu
|
||||||
#include <debugger/analyzer/analyzermanager.h>
|
#include <debugger/analyzer/analyzermanager.h>
|
||||||
#include <coreplugin/findplaceholder.h>
|
#include <coreplugin/findplaceholder.h>
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
@@ -103,7 +104,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
|||||||
qint64 end = modelManager->traceTime()->endTime();
|
qint64 end = modelManager->traceTime()->endTime();
|
||||||
d->m_zoomControl->setTrace(start, end);
|
d->m_zoomControl->setTrace(start, end);
|
||||||
d->m_zoomControl->setRange(start, start + (end - start) / 10);
|
d->m_zoomControl->setRange(start, start + (end - start) / 10);
|
||||||
// Fall through
|
Q_FALLTHROUGH();
|
||||||
}
|
}
|
||||||
case QmlProfilerModelManager::Empty:
|
case QmlProfilerModelManager::Empty:
|
||||||
d->m_modelProxy->setModels(d->m_suspendedModels);
|
d->m_modelProxy->setModels(d->m_suspendedModels);
|
||||||
@@ -116,7 +117,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
|||||||
d->m_zoomControl->clear();
|
d->m_zoomControl->clear();
|
||||||
if (!d->m_suspendedModels.isEmpty())
|
if (!d->m_suspendedModels.isEmpty())
|
||||||
break; // Models are suspended already. AcquiringData was aborted.
|
break; // Models are suspended already. AcquiringData was aborted.
|
||||||
// Fall through
|
Q_FALLTHROUGH();
|
||||||
case QmlProfilerModelManager::AcquiringData:
|
case QmlProfilerModelManager::AcquiringData:
|
||||||
// Temporarily remove the models, while we're changing them
|
// Temporarily remove the models, while we're changing them
|
||||||
d->m_suspendedModels = d->m_modelProxy->models();
|
d->m_suspendedModels = d->m_modelProxy->models();
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
#include "scxmldocument.h"
|
#include "scxmldocument.h"
|
||||||
#include "scxmltag.h"
|
#include "scxmltag.h"
|
||||||
|
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
|
||||||
@@ -245,6 +247,7 @@ Qt::ItemFlags StructureModel::flags(const QModelIndex &index) const
|
|||||||
case Final:
|
case Final:
|
||||||
case History:
|
case History:
|
||||||
defaultFlags |= Qt::ItemIsDragEnabled;
|
defaultFlags |= Qt::ItemIsDragEnabled;
|
||||||
|
Q_FALLTHROUGH();
|
||||||
case Scxml:
|
case Scxml:
|
||||||
defaultFlags |= Qt::ItemIsDropEnabled;
|
defaultFlags |= Qt::ItemIsDropEnabled;
|
||||||
break;
|
break;
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/qtcfallthrough.h>
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@@ -56,6 +57,7 @@ public:
|
|||||||
switch (v.type()) {
|
switch (v.type()) {
|
||||||
case QVariant::UInt:
|
case QVariant::UInt:
|
||||||
m_type = QVariant::Int;
|
m_type = QVariant::Int;
|
||||||
|
Q_FALLTHROUGH();
|
||||||
case QVariant::Int:
|
case QVariant::Int:
|
||||||
m_comp.intValue = v.toInt();
|
m_comp.intValue = v.toInt();
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user