forked from qt-creator/qt-creator
Make share/qtcreator/cplusplus/examples compilable
Builds now, but does not link (which is fine). And unrelated, unintentional warnings were removed. Change-Id: I6ece33933bc20e6e36fb3859de7c2b774b0e67d5 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -11,7 +11,10 @@ set(CMAKE_AUTORCC ON)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Widgets REQUIRED)
|
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||||
|
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets REQUIRED)
|
||||||
|
|
||||||
|
set_property(SOURCE clazy_example.cpp icontest.cpp PROPERTY SKIP_AUTOMOC ON)
|
||||||
|
|
||||||
add_executable(examples
|
add_executable(examples
|
||||||
clazy_example.cpp
|
clazy_example.cpp
|
||||||
@@ -20,4 +23,4 @@ add_executable(examples
|
|||||||
tidy_example.h
|
tidy_example.h
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(examples PRIVATE Qt5::Widgets)
|
target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||||
|
@@ -113,9 +113,6 @@ TestObject::TestObject()
|
|||||||
for (auto obj : list) {
|
for (auto obj : list) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -Wclazy-qdatetime-utc
|
|
||||||
QDateTime::currentDateTime().toTime_t();
|
|
||||||
|
|
||||||
// -Wclazy-qfileinfo-exists
|
// -Wclazy-qfileinfo-exists
|
||||||
// -Wclazy-qstring-allocations
|
// -Wclazy-qstring-allocations
|
||||||
QFileInfo("filename").exists();
|
QFileInfo("filename").exists();
|
||||||
@@ -134,8 +131,5 @@ TestObject::TestObject()
|
|||||||
str.mid(5).toInt(&ok);
|
str.mid(5).toInt(&ok);
|
||||||
|
|
||||||
// -Wclazy-qstring-arg
|
// -Wclazy-qstring-arg
|
||||||
QString("%1 %2").arg("1").arg("2");
|
(void) QString("%1 %2").arg("1").arg("2");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: A fatal error like an unresolved include will make clazy stop emitting any diagnostics.
|
|
||||||
// #include "clazy_example.moc"
|
|
||||||
|
@@ -27,12 +27,13 @@
|
|||||||
|
|
||||||
#define Macro
|
#define Macro
|
||||||
|
|
||||||
class Class {
|
class Class : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_PROPERTY(bool property READ readProperty CONSTANT);
|
Q_PROPERTY(int property READ publicStaticFunction CONSTANT)
|
||||||
void publicFunction();
|
int publicFunction() { return 0; }
|
||||||
void static publicStaticFunction();
|
int static publicStaticFunction() { return 0; }
|
||||||
template<int> void publicTemplateFunction();
|
template<int> void publicTemplateFunction();
|
||||||
template<int> void static publicStaticTemplateFunction();
|
template<int> void static publicStaticTemplateFunction();
|
||||||
|
|
||||||
@@ -43,8 +44,8 @@ signals:
|
|||||||
void signal();
|
void signal();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void publicSlot();
|
void publicSlot() {}
|
||||||
template<int> void publicTemplateSlot();
|
// template<int> void publicTemplateSlot() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void protectedFunction();
|
void protectedFunction();
|
||||||
@@ -56,8 +57,8 @@ protected:
|
|||||||
int static protectedStaticVariable;
|
int static protectedStaticVariable;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void protectedSlot();
|
void protectedSlot() {}
|
||||||
template<int> void protectedTemplateSlot();
|
// template<int> void protectedTemplateSlot() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void privateFunction();
|
void privateFunction();
|
||||||
@@ -67,9 +68,10 @@ private:
|
|||||||
template<int> void static privateStaticTemplateFunction();
|
template<int> void static privateStaticTemplateFunction();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void privateSlot();
|
void privateSlot() {}
|
||||||
template<int> void privateTemplateSlot();
|
// template<int> void privateTemplateSlot() {}
|
||||||
|
|
||||||
|
private:
|
||||||
int privateVariable;
|
int privateVariable;
|
||||||
int static privateStaticVariable;
|
int static privateStaticVariable;
|
||||||
};
|
};
|
||||||
|
@@ -71,7 +71,7 @@ public:
|
|||||||
// misc-noexcept-move-constructor
|
// misc-noexcept-move-constructor
|
||||||
// misc-unconventional-assign-operator
|
// misc-unconventional-assign-operator
|
||||||
// misc-unused-parameters
|
// misc-unused-parameters
|
||||||
Base operator=(Base &¶m) {}
|
Base operator=(Base &¶m) { return {}; }
|
||||||
virtual int function()
|
virtual int function()
|
||||||
{
|
{
|
||||||
// modernize-use-nullptr
|
// modernize-use-nullptr
|
||||||
@@ -116,7 +116,7 @@ void afterMove(Base &&base)
|
|||||||
Base moved(std::move(base));
|
Base moved(std::move(base));
|
||||||
|
|
||||||
// misc-use-after-move
|
// misc-use-after-move
|
||||||
base.value;
|
(void) base.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// google-runtime-references
|
// google-runtime-references
|
||||||
@@ -144,7 +144,7 @@ public:
|
|||||||
auto b = {0.5f, 0.5f, 0.5f, 0.5f};
|
auto b = {0.5f, 0.5f, 0.5f, 0.5f};
|
||||||
|
|
||||||
// misc-fold-init-type
|
// misc-fold-init-type
|
||||||
std::accumulate(std::begin(b), std::end(b), 0);
|
(void) std::accumulate(std::begin(b), std::end(b), 0);
|
||||||
|
|
||||||
// google-readability-casting, misc-incorrect-roundings
|
// google-readability-casting, misc-incorrect-roundings
|
||||||
auto c = (int)(getDouble() + 0.5);
|
auto c = (int)(getDouble() + 0.5);
|
||||||
@@ -197,6 +197,7 @@ public:
|
|||||||
std::system("echo ");
|
std::system("echo ");
|
||||||
// cert-err52-cpp
|
// cert-err52-cpp
|
||||||
setjmp(nullptr);
|
setjmp(nullptr);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// google-default-arguments
|
// google-default-arguments
|
||||||
@@ -251,7 +252,7 @@ int main()
|
|||||||
// modernize-loop-convert
|
// modernize-loop-convert
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
// cppcoreguidelines-pro-bounds-constant-array-index
|
// cppcoreguidelines-pro-bounds-constant-array-index
|
||||||
arr[i];
|
(void) arr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<int, int>> w;
|
std::vector<std::pair<int, int>> w;
|
||||||
|
Reference in New Issue
Block a user