From 7555c67c3e656407da36e0d0475fba350d4dd4f0 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 16 Mar 2015 14:23:02 +0200 Subject: [PATCH] Clang warnings. --HG-- branch : release --- src/app/app.pro | 6 +++ src/app/dialogs/app/dialoglayoutsettings.cpp | 6 ++- src/app/dialogs/tools/dialogarc.cpp | 2 +- src/app/dialogs/tools/dialoglineintersect.cpp | 1 - src/app/widgets/doubledelegate.h | 1 - src/app/xml/vpattern.cpp | 1 + src/libs/ifc/ifc.pro | 5 +++ src/libs/ifc/xml/vabstractconverter.cpp | 1 + src/libs/ifc/xml/vdomdocument.h | 4 +- src/libs/ifc/xml/vpatternconverter.cpp | 9 +++++ src/libs/vlayout/vlayout.pro | 5 +++ src/libs/vlayout/vlayoutgenerator.cpp | 2 +- src/libs/vlayout/vlayoutpaper.cpp | 2 +- src/libs/vlayout/vposition.cpp | 8 ++++ src/libs/vobj/delaunay.h | 8 +--- src/libs/vobj/vobjengine.cpp | 15 +++++-- src/libs/vobj/vobjpaintdevice.cpp | 2 +- .../vpropertyexplorer/checkablemessagebox.cpp | 39 ++++++++----------- .../vpropertyexplorer/checkablemessagebox.h | 8 ++++ .../vpropertyexplorer/vpropertyexplorer.pro | 6 +++ src/test/ParserTest/ParserTest.pro | 5 +++ 21 files changed, 93 insertions(+), 43 deletions(-) diff --git a/src/app/app.pro b/src/app/app.pro index 0d23a1ae2..98ad636e1 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -99,6 +99,12 @@ CONFIG(debug, debug|release){ -isystem "$${OUT_PWD}/$${MOC_DIR}" \ -isystem "$${OUT_PWD}/$${RCC_DIR}" \ $$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. + + # -isystem key works only for headers. In some cases it's not enough. But we can't delete this warnings and + # want them in global list. Compromise decision delete them from local list. + QMAKE_CXXFLAGS -= \ + -Wmissing-prototypes \ + -Wundefined-reinterpret-cast } } else { *-g++{ diff --git a/src/app/dialogs/app/dialoglayoutsettings.cpp b/src/app/dialogs/app/dialoglayoutsettings.cpp index 9d0ffa32e..82fa04256 100644 --- a/src/app/dialogs/app/dialoglayoutsettings.cpp +++ b/src/app/dialogs/app/dialoglayoutsettings.cpp @@ -98,7 +98,8 @@ void DialogLayoutSettings::SetPaperWidth(int value) //--------------------------------------------------------------------------------------------------------------------- unsigned int DialogLayoutSettings::GetShift() const { - return qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxShift->value(), oldLayoutUnit, Unit::Px)); + return static_cast(qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxShift->value(), + oldLayoutUnit, Unit::Px))); } //--------------------------------------------------------------------------------------------------------------------- @@ -110,7 +111,8 @@ void DialogLayoutSettings::SetShift(unsigned int value) //--------------------------------------------------------------------------------------------------------------------- unsigned int DialogLayoutSettings::GetLayoutWidth() const { - return qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxLayoutWidth->value(), oldLayoutUnit, Unit::Px)); + return static_cast(qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxLayoutWidth->value(), + oldLayoutUnit, Unit::Px))); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index 9c5873356..f6deed1fa 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -401,7 +401,7 @@ void DialogArc::ShowLineAngles() //--------------------------------------------------------------------------------------------------------------------- void DialogArc::CheckAngles() { - if (angleF1 == INT_MIN || angleF2 == INT_MIN) + if (static_cast(angleF1) == INT_MIN || static_cast(angleF2) == INT_MIN) { return; } diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index 403342115..4662085cd 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -175,7 +175,6 @@ void DialogLineIntersect::SaveData() //--------------------------------------------------------------------------------------------------------------------- /** * @brief P1Line1Changed changed first point of first line - * @param index index in list */ void DialogLineIntersect::PointChanged() { diff --git a/src/app/widgets/doubledelegate.h b/src/app/widgets/doubledelegate.h index 790be3ae5..40fb65f30 100644 --- a/src/app/widgets/doubledelegate.h +++ b/src/app/widgets/doubledelegate.h @@ -51,7 +51,6 @@ public: signals: /** * @brief NewLastValue help reset last value in const method (hack). - * @param text text. */ void NewLastValue(const qreal &newLastValue) const; public slots: diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index a09250938..632f6bb69 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -473,6 +473,7 @@ void VPattern::setCurrentData() } catch (VExceptionBadId &e) { + Q_UNUSED(e) qCDebug(vXML)<<"List of tools doesn't containe id="<GetLayoutWidth()); - paper.SetPaperIndex(papers.count()); + paper.SetPaperIndex(static_cast(papers.count())); paper.SetRotate(rotate); paper.SetRotationIncrease(rotationIncrease); do diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index dbdcbe15f..45a7f2f59 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -203,7 +203,7 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop) threads.append(thread); thread_pool->start(thread); - d->frame = d->frame + 3 + 360/d->rotationIncrease*2; + d->frame = d->frame + 3 + static_cast(360/d->rotationIncrease*2); } } diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 47748944b..699f65cfb 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -170,6 +170,9 @@ void VPosition::DrawDebug(const VContour &contour, const VLayoutDetail &detail, p = DrawContour(detail.GetLayoutAllowencePoints()); p.translate(contour.GetWidth()/2, contour.GetHeight()/2); paint.drawPath(p); +#else + Q_UNUSED(detail) + Q_UNUSED(details) #endif #ifdef ARRANGED_DETAILS @@ -177,6 +180,8 @@ void VPosition::DrawDebug(const VContour &contour, const VLayoutDetail &detail, p = DrawDetails(details); p.translate(contour.GetWidth()/2, contour.GetHeight()/2); paint.drawPath(p); +#else + Q_UNUSED(details) #endif paint.end(); @@ -241,6 +246,7 @@ bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) cons default: break; } + break; } default: break; @@ -288,6 +294,7 @@ bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) cons default: break; } + break; } default: break; @@ -338,6 +345,7 @@ bool VPosition::CheckRotationEdges(VLayoutDetail &detail, int j, int dEdge, int default: break; } + break; } default: break; diff --git a/src/libs/vobj/delaunay.h b/src/libs/vobj/delaunay.h index f7e10184d..d6fcf66ea 100644 --- a/src/libs/vobj/delaunay.h +++ b/src/libs/vobj/delaunay.h @@ -70,12 +70,8 @@ typedef int (*incircle_predicate_t)(del_point2d_t* p0, del_point2d_t* p1, del_p /* * build the 2D Delaunay triangulation given a set of points of at least 3 points * - * @points: point set given as a sequence of tuple x0, y0, x1, y1, .... - * @num_points: number of given point - * @preds: the incircle predicate - * @faces: the triangles given as a sequence: num verts, verts indices, num verts, verts indices - * first face is the external face - * @pred: incircle predicate + * @param points point set given as a sequence of tuple x0, y0, x1, y1, .... + * @param num_points number of given point * @return: the number of created faces */ delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points); diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp index a2912ba34..0545aadbd 100644 --- a/src/libs/vobj/vobjengine.cpp +++ b/src/libs/vobj/vobjengine.cpp @@ -35,12 +35,21 @@ //--------------------------------------------------------------------------------------------------------------------- static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() { +#ifdef Q_CC_CLANG +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wsign-conversion" +#endif + return QPaintEngine::PaintEngineFeatures( QPaintEngine::AllFeatures & ~QPaintEngine::PatternBrush & ~QPaintEngine::PerspectiveTransform & ~QPaintEngine::ConicalGradientFill & ~QPaintEngine::PorterDuff); + +#ifdef Q_CC_CLANG +#pragma clang diagnostic pop +#endif } //--------------------------------------------------------------------------------------------------------------------- @@ -163,11 +172,11 @@ void VObjEngine::drawPath(const QPainterPath &path) { skipFace=false; } - int num_verts = res->faces[offset]; + int num_verts = static_cast(res->faces[offset]); offset++; for ( int j = 0; j < num_verts; j++ ) { - int p0 = res->faces[offset + j]; + int p0 = static_cast(res->faces[offset + j]); pf[j] = QPointF(points[p0].x, points[p0].y); } if (skipFace == false ) @@ -201,7 +210,7 @@ void VObjEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM for (int i = 0; i < pointCount; ++i) { - *stream << QString(" %1").arg(globalPointsCount - pointCount + i + 1); + *stream << QString(" %1").arg(globalPointsCount - static_cast(pointCount + i + 1)); } *stream << endl; } diff --git a/src/libs/vobj/vobjpaintdevice.cpp b/src/libs/vobj/vobjpaintdevice.cpp index 597fe305e..5173e01b0 100644 --- a/src/libs/vobj/vobjpaintdevice.cpp +++ b/src/libs/vobj/vobjpaintdevice.cpp @@ -149,7 +149,7 @@ int VObjPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const case QPaintDevice::PdmWidthMM: return qRound(engine->getSize().width() * 25.4 / engine->getResolution()); case QPaintDevice::PdmNumColors: - return 0xffffffff; + return static_cast(0xffffffff); case QPaintDevice::PdmPhysicalDpiX: return engine->getResolution(); case QPaintDevice::PdmPhysicalDpiY: diff --git a/src/libs/vpropertyexplorer/checkablemessagebox.cpp b/src/libs/vpropertyexplorer/checkablemessagebox.cpp index 16c80218b..273a5c46c 100644 --- a/src/libs/vpropertyexplorer/checkablemessagebox.cpp +++ b/src/libs/vpropertyexplorer/checkablemessagebox.cpp @@ -24,8 +24,13 @@ #include #include +static const char kDoNotAskAgainKey[] = "DoNotAskAgain"; + +namespace Utils +{ + /*! - \class Utils::CheckableMessageBox + \class CheckableMessageBox \brief The CheckableMessageBox class implements a message box suitable for questions with a @@ -34,12 +39,6 @@ Emulates the QMessageBox API with static conveniences. The message label can open external URLs. */ - -static const char kDoNotAskAgainKey[] = "DoNotAskAgain"; - -namespace Utils -{ - class CheckableMessageBoxPrivate { public: @@ -55,8 +54,7 @@ public: pixmapLabel->setSizePolicy(sizePolicy); pixmapLabel->setVisible(false); - QSpacerItem *pixmapSpacer = - new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); + QSpacerItem *pixmapSpacer = new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); messageLabel = new QLabel(q); messageLabel->setMinimumSize(QSize(300, 0)); @@ -64,10 +62,8 @@ public: messageLabel->setOpenExternalLinks(true); messageLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse); - QSpacerItem *checkBoxRightSpacer = - new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); - QSpacerItem *buttonSpacer = - new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum); + QSpacerItem *checkBoxRightSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); + QSpacerItem *buttonSpacer = new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum); checkBox = new QCheckBox(q); checkBox->setText(CheckableMessageBox::tr("Do not ask again")); @@ -112,8 +108,7 @@ CheckableMessageBox::CheckableMessageBox(QWidget *parent) : setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept())); connect(d->buttonBox, SIGNAL(rejected()), SLOT(reject())); - connect(d->buttonBox, SIGNAL(clicked(QAbstractButton*)), - SLOT(slotClicked(QAbstractButton*))); + connect(d->buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(slotClicked(QAbstractButton*))); } CheckableMessageBox::~CheckableMessageBox() @@ -286,7 +281,7 @@ QMessageBox::StandardButton CheckableMessageBox::dialogButtonBoxToMessageBoxButt return static_cast(int(db)); } -bool askAgain(QSettings *settings, const QString &settingsSubKey) +bool CheckableMessageBox::askAgain(QSettings *settings, const QString &settingsSubKey) { //QTC_CHECK(settings); if (settings) @@ -302,12 +297,10 @@ bool askAgain(QSettings *settings, const QString &settingsSubKey) return true; } -enum DoNotAskAgainType{Question, Information}; - -void initDoNotAskAgainMessageBox(CheckableMessageBox &messageBox, const QString &title, - const QString &text, QDialogButtonBox::StandardButtons buttons, - QDialogButtonBox::StandardButton defaultButton, - DoNotAskAgainType type) +void CheckableMessageBox::initDoNotAskAgainMessageBox(CheckableMessageBox &messageBox, const QString &title, + const QString &text, QDialogButtonBox::StandardButtons buttons, + QDialogButtonBox::StandardButton defaultButton, + DoNotAskAgainType type) { messageBox.setWindowTitle(title); messageBox.setIconPixmap(QMessageBox::standardIcon(type == Information @@ -322,7 +315,7 @@ void initDoNotAskAgainMessageBox(CheckableMessageBox &messageBox, const QString messageBox.setDefaultButton(defaultButton); } -void doNotAskAgain(QSettings *settings, const QString &settingsSubKey) +void CheckableMessageBox::doNotAskAgain(QSettings *settings, const QString &settingsSubKey) { if (!settings) { diff --git a/src/libs/vpropertyexplorer/checkablemessagebox.h b/src/libs/vpropertyexplorer/checkablemessagebox.h index 467934d5d..a66c0e4ce 100644 --- a/src/libs/vpropertyexplorer/checkablemessagebox.h +++ b/src/libs/vpropertyexplorer/checkablemessagebox.h @@ -122,6 +122,14 @@ private slots: private: Q_DISABLE_COPY(CheckableMessageBox) CheckableMessageBoxPrivate *d; + enum DoNotAskAgainType{Question, Information}; + + static bool askAgain(QSettings *settings, const QString &settingsSubKey); + static void initDoNotAskAgainMessageBox(CheckableMessageBox &messageBox, const QString &title, + const QString &text, QDialogButtonBox::StandardButtons buttons, + QDialogButtonBox::StandardButton defaultButton, + DoNotAskAgainType type); + static void doNotAskAgain(QSettings *settings, const QString &settingsSubKey); }; } // namespace Utils diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.pro b/src/libs/vpropertyexplorer/vpropertyexplorer.pro index 8cbb9352b..131e906d6 100644 --- a/src/libs/vpropertyexplorer/vpropertyexplorer.pro +++ b/src/libs/vpropertyexplorer/vpropertyexplorer.pro @@ -83,11 +83,17 @@ CONFIG(debug, debug|release){ QMAKE_CFLAGS+=-fsanitize=address -fno-omit-frame-pointer QMAKE_LFLAGS+=-fsanitize=address } + clang*{ QMAKE_CXXFLAGS += \ # Key -isystem disable checking errors in system headers. -isystem "$${OUT_PWD}/$${MOC_DIR}" \ $$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. + + # -isystem key works only for headers. In some cases it's not enough. But we can't delete this warnings and + # want them in global list. Compromise decision delete them from local list. + QMAKE_CXXFLAGS -= \ + -Wundefined-reinterpret-cast } } else { *-g++{ diff --git a/src/test/ParserTest/ParserTest.pro b/src/test/ParserTest/ParserTest.pro index 7a6b30b4e..76b3126f7 100644 --- a/src/test/ParserTest/ParserTest.pro +++ b/src/test/ParserTest/ParserTest.pro @@ -62,6 +62,11 @@ CONFIG(debug, debug|release){ clang*{ QMAKE_CXXFLAGS += \ $$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. + + # -isystem key works only for headers. In some cases it's not enough. But we can't delete this warnings and + # want them in global list. Compromise decision delete them from local list. + QMAKE_CXXFLAGS -= \ + -Wmissing-prototypes } } else { *-g++{