Clang warnings.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2015-03-16 14:23:02 +02:00
parent cabac6f3d0
commit 7555c67c3e
21 changed files with 93 additions and 43 deletions

View file

@ -99,6 +99,12 @@ CONFIG(debug, debug|release){
-isystem "$${OUT_PWD}/$${MOC_DIR}" \ -isystem "$${OUT_PWD}/$${MOC_DIR}" \
-isystem "$${OUT_PWD}/$${RCC_DIR}" \ -isystem "$${OUT_PWD}/$${RCC_DIR}" \
$$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. $$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 { } else {
*-g++{ *-g++{

View file

@ -98,7 +98,8 @@ void DialogLayoutSettings::SetPaperWidth(int value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
unsigned int DialogLayoutSettings::GetShift() const unsigned int DialogLayoutSettings::GetShift() const
{ {
return qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxShift->value(), oldLayoutUnit, Unit::Px)); return static_cast<quint32>(qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxShift->value(),
oldLayoutUnit, Unit::Px)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -110,7 +111,8 @@ void DialogLayoutSettings::SetShift(unsigned int value)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
unsigned int DialogLayoutSettings::GetLayoutWidth() const unsigned int DialogLayoutSettings::GetLayoutWidth() const
{ {
return qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxLayoutWidth->value(), oldLayoutUnit, Unit::Px)); return static_cast<quint32>(qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxLayoutWidth->value(),
oldLayoutUnit, Unit::Px)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -401,7 +401,7 @@ void DialogArc::ShowLineAngles()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogArc::CheckAngles() void DialogArc::CheckAngles()
{ {
if (angleF1 == INT_MIN || angleF2 == INT_MIN) if (static_cast<int>(angleF1) == INT_MIN || static_cast<int>(angleF2) == INT_MIN)
{ {
return; return;
} }

View file

@ -175,7 +175,6 @@ void DialogLineIntersect::SaveData()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief P1Line1Changed changed first point of first line * @brief P1Line1Changed changed first point of first line
* @param index index in list
*/ */
void DialogLineIntersect::PointChanged() void DialogLineIntersect::PointChanged()
{ {

View file

@ -51,7 +51,6 @@ public:
signals: signals:
/** /**
* @brief NewLastValue help reset last value in const method (hack). * @brief NewLastValue help reset last value in const method (hack).
* @param text text.
*/ */
void NewLastValue(const qreal &newLastValue) const; void NewLastValue(const qreal &newLastValue) const;
public slots: public slots:

View file

@ -473,6 +473,7 @@ void VPattern::setCurrentData()
} }
catch (VExceptionBadId &e) catch (VExceptionBadId &e)
{ {
Q_UNUSED(e)
qCDebug(vXML)<<"List of tools doesn't containe id="<<id; qCDebug(vXML)<<"List of tools doesn't containe id="<<id;
return; return;
} }

View file

@ -73,6 +73,11 @@ CONFIG(debug, debug|release){
# Key -isystem disable checking errors in system headers. # Key -isystem disable checking errors in system headers.
-isystem "$${OUT_PWD}/$${MOC_DIR}" \ -isystem "$${OUT_PWD}/$${MOC_DIR}" \
$$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. $$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 { } else {
*-g++{ *-g++{

View file

@ -169,6 +169,7 @@ bool VAbstractConverter::SaveDocument(const QString &fileName, QString &error) c
} }
catch (const VExceptionWrongId &e) catch (const VExceptionWrongId &e)
{ {
Q_UNUSED(e)
error = tr("Error no unique id."); error = tr("Error no unique id.");
return false; return false;
} }

View file

@ -75,9 +75,7 @@ public:
static const QString UnitINCH; static const QString UnitINCH;
static const QString UnitPX; static const QString UnitPX;
static const QString TagVersion; static const QString TagVersion;
/**
* @param data container with variables
*/
VDomDocument(); VDomDocument();
virtual ~VDomDocument(); virtual ~VDomDocument();
QDomElement elementById(const QString& id); QDomElement elementById(const QString& id);

View file

@ -115,6 +115,9 @@ void VPatternConverter::ApplyPatches()
const QString schema = XSDSchema(0x000101); const QString schema = XSDSchema(0x000101);
ValidateXML(schema, fileName); ValidateXML(schema, fileName);
// continue conversion // continue conversion
#ifdef Q_CC_CLANG
[[clang::fallthrough]];
#endif
} }
case (0x000101): case (0x000101):
{ {
@ -122,6 +125,9 @@ void VPatternConverter::ApplyPatches()
const QString schema = XSDSchema(0x000102); const QString schema = XSDSchema(0x000102);
ValidateXML(schema, fileName); ValidateXML(schema, fileName);
// continue conversion // continue conversion
#ifdef Q_CC_CLANG
[[clang::fallthrough]];
#endif
} }
case (0x000102): case (0x000102):
{ {
@ -129,6 +135,9 @@ void VPatternConverter::ApplyPatches()
const QString schema = XSDSchema(0x000103); const QString schema = XSDSchema(0x000103);
ValidateXML(schema, fileName); ValidateXML(schema, fileName);
// continue conversion // continue conversion
#ifdef Q_CC_CLANG
[[clang::fallthrough]];
#endif
} }
case (0x000103): case (0x000103):
break; break;

View file

@ -65,6 +65,11 @@ CONFIG(debug, debug|release){
# Key -isystem disable checking errors in system headers. # Key -isystem disable checking errors in system headers.
-isystem "$${OUT_PWD}/$${MOC_DIR}" \ -isystem "$${OUT_PWD}/$${MOC_DIR}" \
$$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. $$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 { } else {
*-g++{ *-g++{

View file

@ -100,7 +100,7 @@ void VLayoutGenerator::Generate()
VLayoutPaper paper(paperHeight, paperWidth); VLayoutPaper paper(paperHeight, paperWidth);
paper.SetShift(shift); paper.SetShift(shift);
paper.SetLayoutWidth(bank->GetLayoutWidth()); paper.SetLayoutWidth(bank->GetLayoutWidth());
paper.SetPaperIndex(papers.count()); paper.SetPaperIndex(static_cast<quint32>(papers.count()));
paper.SetRotate(rotate); paper.SetRotate(rotate);
paper.SetRotationIncrease(rotationIncrease); paper.SetRotationIncrease(rotationIncrease);
do do

View file

@ -203,7 +203,7 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop)
threads.append(thread); threads.append(thread);
thread_pool->start(thread); thread_pool->start(thread);
d->frame = d->frame + 3 + 360/d->rotationIncrease*2; d->frame = d->frame + 3 + static_cast<unsigned int>(360/d->rotationIncrease*2);
} }
} }

View file

@ -170,6 +170,9 @@ void VPosition::DrawDebug(const VContour &contour, const VLayoutDetail &detail,
p = DrawContour(detail.GetLayoutAllowencePoints()); p = DrawContour(detail.GetLayoutAllowencePoints());
p.translate(contour.GetWidth()/2, contour.GetHeight()/2); p.translate(contour.GetWidth()/2, contour.GetHeight()/2);
paint.drawPath(p); paint.drawPath(p);
#else
Q_UNUSED(detail)
Q_UNUSED(details)
#endif #endif
#ifdef ARRANGED_DETAILS #ifdef ARRANGED_DETAILS
@ -177,6 +180,8 @@ void VPosition::DrawDebug(const VContour &contour, const VLayoutDetail &detail,
p = DrawDetails(details); p = DrawDetails(details);
p.translate(contour.GetWidth()/2, contour.GetHeight()/2); p.translate(contour.GetWidth()/2, contour.GetHeight()/2);
paint.drawPath(p); paint.drawPath(p);
#else
Q_UNUSED(details)
#endif #endif
paint.end(); paint.end();
@ -241,6 +246,7 @@ bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) cons
default: default:
break; break;
} }
break;
} }
default: default:
break; break;
@ -288,6 +294,7 @@ bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) cons
default: default:
break; break;
} }
break;
} }
default: default:
break; break;
@ -338,6 +345,7 @@ bool VPosition::CheckRotationEdges(VLayoutDetail &detail, int j, int dEdge, int
default: default:
break; break;
} }
break;
} }
default: default:
break; break;

View file

@ -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 * 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, .... * @param points point set given as a sequence of tuple x0, y0, x1, y1, ....
* @num_points: number of given point * @param 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
* @return: the number of created faces * @return: the number of created faces
*/ */
delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points); delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points);

View file

@ -35,12 +35,21 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures()
{ {
#ifdef Q_CC_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion"
#endif
return QPaintEngine::PaintEngineFeatures( return QPaintEngine::PaintEngineFeatures(
QPaintEngine::AllFeatures QPaintEngine::AllFeatures
& ~QPaintEngine::PatternBrush & ~QPaintEngine::PatternBrush
& ~QPaintEngine::PerspectiveTransform & ~QPaintEngine::PerspectiveTransform
& ~QPaintEngine::ConicalGradientFill & ~QPaintEngine::ConicalGradientFill
& ~QPaintEngine::PorterDuff); & ~QPaintEngine::PorterDuff);
#ifdef Q_CC_CLANG
#pragma clang diagnostic pop
#endif
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -163,11 +172,11 @@ void VObjEngine::drawPath(const QPainterPath &path)
{ {
skipFace=false; skipFace=false;
} }
int num_verts = res->faces[offset]; int num_verts = static_cast<int>(res->faces[offset]);
offset++; offset++;
for ( int j = 0; j < num_verts; j++ ) for ( int j = 0; j < num_verts; j++ )
{ {
int p0 = res->faces[offset + j]; int p0 = static_cast<int>(res->faces[offset + j]);
pf[j] = QPointF(points[p0].x, points[p0].y); pf[j] = QPointF(points[p0].x, points[p0].y);
} }
if (skipFace == false ) if (skipFace == false )
@ -201,7 +210,7 @@ void VObjEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM
for (int i = 0; i < pointCount; ++i) for (int i = 0; i < pointCount; ++i)
{ {
*stream << QString(" %1").arg(globalPointsCount - pointCount + i + 1); *stream << QString(" %1").arg(globalPointsCount - static_cast<unsigned int>(pointCount + i + 1));
} }
*stream << endl; *stream << endl;
} }

View file

@ -149,7 +149,7 @@ int VObjPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
case QPaintDevice::PdmWidthMM: case QPaintDevice::PdmWidthMM:
return qRound(engine->getSize().width() * 25.4 / engine->getResolution()); return qRound(engine->getSize().width() * 25.4 / engine->getResolution());
case QPaintDevice::PdmNumColors: case QPaintDevice::PdmNumColors:
return 0xffffffff; return static_cast<int>(0xffffffff);
case QPaintDevice::PdmPhysicalDpiX: case QPaintDevice::PdmPhysicalDpiX:
return engine->getResolution(); return engine->getResolution();
case QPaintDevice::PdmPhysicalDpiY: case QPaintDevice::PdmPhysicalDpiY:

View file

@ -24,8 +24,13 @@
#include <QPushButton> #include <QPushButton>
#include <QSettings> #include <QSettings>
static const char kDoNotAskAgainKey[] = "DoNotAskAgain";
namespace Utils
{
/*! /*!
\class Utils::CheckableMessageBox \class CheckableMessageBox
\brief The CheckableMessageBox class implements a message box suitable for \brief The CheckableMessageBox class implements a message box suitable for
questions with a questions with a
@ -34,12 +39,6 @@
Emulates the QMessageBox API with Emulates the QMessageBox API with
static conveniences. The message label can open external URLs. static conveniences. The message label can open external URLs.
*/ */
static const char kDoNotAskAgainKey[] = "DoNotAskAgain";
namespace Utils
{
class CheckableMessageBoxPrivate class CheckableMessageBoxPrivate
{ {
public: public:
@ -55,8 +54,7 @@ public:
pixmapLabel->setSizePolicy(sizePolicy); pixmapLabel->setSizePolicy(sizePolicy);
pixmapLabel->setVisible(false); pixmapLabel->setVisible(false);
QSpacerItem *pixmapSpacer = QSpacerItem *pixmapSpacer = new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
messageLabel = new QLabel(q); messageLabel = new QLabel(q);
messageLabel->setMinimumSize(QSize(300, 0)); messageLabel->setMinimumSize(QSize(300, 0));
@ -64,10 +62,8 @@ public:
messageLabel->setOpenExternalLinks(true); messageLabel->setOpenExternalLinks(true);
messageLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse); messageLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse);
QSpacerItem *checkBoxRightSpacer = QSpacerItem *checkBoxRightSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); QSpacerItem *buttonSpacer = new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum);
QSpacerItem *buttonSpacer =
new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum);
checkBox = new QCheckBox(q); checkBox = new QCheckBox(q);
checkBox->setText(CheckableMessageBox::tr("Do not ask again")); checkBox->setText(CheckableMessageBox::tr("Do not ask again"));
@ -112,8 +108,7 @@ CheckableMessageBox::CheckableMessageBox(QWidget *parent) :
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept())); connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept()));
connect(d->buttonBox, SIGNAL(rejected()), SLOT(reject())); connect(d->buttonBox, SIGNAL(rejected()), SLOT(reject()));
connect(d->buttonBox, SIGNAL(clicked(QAbstractButton*)), connect(d->buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(slotClicked(QAbstractButton*)));
SLOT(slotClicked(QAbstractButton*)));
} }
CheckableMessageBox::~CheckableMessageBox() CheckableMessageBox::~CheckableMessageBox()
@ -286,7 +281,7 @@ QMessageBox::StandardButton CheckableMessageBox::dialogButtonBoxToMessageBoxButt
return static_cast<QMessageBox::StandardButton>(int(db)); return static_cast<QMessageBox::StandardButton>(int(db));
} }
bool askAgain(QSettings *settings, const QString &settingsSubKey) bool CheckableMessageBox::askAgain(QSettings *settings, const QString &settingsSubKey)
{ {
//QTC_CHECK(settings); //QTC_CHECK(settings);
if (settings) if (settings)
@ -302,12 +297,10 @@ bool askAgain(QSettings *settings, const QString &settingsSubKey)
return true; return true;
} }
enum DoNotAskAgainType{Question, Information}; void CheckableMessageBox::initDoNotAskAgainMessageBox(CheckableMessageBox &messageBox, const QString &title,
const QString &text, QDialogButtonBox::StandardButtons buttons,
void initDoNotAskAgainMessageBox(CheckableMessageBox &messageBox, const QString &title, QDialogButtonBox::StandardButton defaultButton,
const QString &text, QDialogButtonBox::StandardButtons buttons, DoNotAskAgainType type)
QDialogButtonBox::StandardButton defaultButton,
DoNotAskAgainType type)
{ {
messageBox.setWindowTitle(title); messageBox.setWindowTitle(title);
messageBox.setIconPixmap(QMessageBox::standardIcon(type == Information messageBox.setIconPixmap(QMessageBox::standardIcon(type == Information
@ -322,7 +315,7 @@ void initDoNotAskAgainMessageBox(CheckableMessageBox &messageBox, const QString
messageBox.setDefaultButton(defaultButton); messageBox.setDefaultButton(defaultButton);
} }
void doNotAskAgain(QSettings *settings, const QString &settingsSubKey) void CheckableMessageBox::doNotAskAgain(QSettings *settings, const QString &settingsSubKey)
{ {
if (!settings) if (!settings)
{ {

View file

@ -122,6 +122,14 @@ private slots:
private: private:
Q_DISABLE_COPY(CheckableMessageBox) Q_DISABLE_COPY(CheckableMessageBox)
CheckableMessageBoxPrivate *d; 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 } // namespace Utils

View file

@ -83,11 +83,17 @@ CONFIG(debug, debug|release){
QMAKE_CFLAGS+=-fsanitize=address -fno-omit-frame-pointer QMAKE_CFLAGS+=-fsanitize=address -fno-omit-frame-pointer
QMAKE_LFLAGS+=-fsanitize=address QMAKE_LFLAGS+=-fsanitize=address
} }
clang*{ clang*{
QMAKE_CXXFLAGS += \ QMAKE_CXXFLAGS += \
# Key -isystem disable checking errors in system headers. # Key -isystem disable checking errors in system headers.
-isystem "$${OUT_PWD}/$${MOC_DIR}" \ -isystem "$${OUT_PWD}/$${MOC_DIR}" \
$$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. $$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 { } else {
*-g++{ *-g++{

View file

@ -62,6 +62,11 @@ CONFIG(debug, debug|release){
clang*{ clang*{
QMAKE_CXXFLAGS += \ QMAKE_CXXFLAGS += \
$$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details. $$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 { } else {
*-g++{ *-g++{