Skip to content

Commit 6988dd3

Browse files
committed
Fix clang warnings. Exclude CMakeLists.txt from list or source files for CMake 3.11.
1 parent 05be812 commit 6988dd3

19 files changed

Lines changed: 69 additions & 47 deletions

CMakeLists.txt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,20 @@ find_package(FLEX)
7676
################################################################################
7777

7878
if (CPPAN_TEST)
79-
add_definitions(-DCPPAN_TEST)
79+
add_definitions(/DCPPAN_TEST)
8080
endif()
8181

8282
if (WIN32)
83-
add_definitions(-DUNICODE)
83+
add_definitions(/DUNICODE)
8484
if (MSVC)
85-
set(disable_msvc_warnings "/W3 /wd4458 /wd4714 /wd4127 /wd4275 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS")
86-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP ${disable_msvc_warnings}")
87-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP ${disable_msvc_warnings}")
85+
set(disable_msvc_warnings "/W3 /wd4458 /wd4714 /wd4127 /wd4275 /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS")
86+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${disable_msvc_warnings}")
87+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${disable_msvc_warnings}")
88+
89+
if (NOT CLANG)
90+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
91+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
92+
endif()
8893

8994
if (MSVC_STATIC_RUNTIME)
9095
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
@@ -103,6 +108,12 @@ if(MSVC)
103108
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++17")
104109
endif()
105110

111+
if (CLANG)
112+
set(flags "-Wno-assume -Wno-potentially-evaluated-expression -Wno-delete-non-virtual-dtor")
113+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flags}")
114+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flags}")
115+
endif()
116+
106117
################################################################################
107118
#
108119
# build

src/client/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# cppan
77
########################################
88

9-
file(GLOB cppan_src "*")
9+
file(GLOB cppan_src "*.cpp" "*.h" "*.rc")
1010

1111
add_executable(client ${cppan_src})
1212
target_link_libraries(client common

src/client/autotools.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ void ac_processor::try_add(command &c)
602602
if (var.empty() || input.empty())
603603
return;
604604

605-
auto p = checks.addCheck<T>(var, input);
605+
/*auto p = */checks.addCheck<T>(var, input);
606606
}
607607

608608
void ac_processor::process_AC_LANG(command &c)

src/client/build.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include <iostream>
3232

3333
#include <primitives/log.h>
34-
DECLARE_STATIC_LOGGER(logger, "build");
34+
//DECLARE_STATIC_LOGGER(logger, "build");
3535

3636
int build_packages(const String &name, const PackagesSet &pkgs, const path &settings_fn, const String &config);
3737
int build_packages(const String &name, const PackagesSet &pkgs);

src/client/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <thread>
4646

4747
#include <primitives/log.h>
48-
DECLARE_STATIC_LOGGER(logger, "main");
48+
//DECLARE_STATIC_LOGGER(logger, "main");
4949

5050
enum class ApiResult
5151
{
@@ -188,6 +188,8 @@ try
188188
return 0;
189189
case ApiResult::Error:
190190
return 1;
191+
default:
192+
break;
191193
}
192194

193195
// file/url arg
@@ -1001,11 +1003,11 @@ ApiResult api_call(const String &cmd, const Strings &args)
10011003

10021004
if (cmd == "notifications")
10031005
{
1004-
auto proj_usage = []
1006+
/*auto proj_usage = []
10051007
{
10061008
std::cout << "invalid number of arguments\n";
10071009
std::cout << "usage: cppan notifications [origin] [clear] [N]\n";
1008-
};
1010+
};*/
10091011

10101012
size_t arg = 2;
10111013

src/common/api.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "settings.h"
2222

2323
#include <primitives/log.h>
24-
DECLARE_STATIC_LOGGER(logger, "api");
24+
//DECLARE_STATIC_LOGGER(logger, "api");
2525

2626
ptree api_call(const Remote &r, const String &api, ptree request)
2727
{
@@ -148,6 +148,8 @@ void Api::get_notifications(const Remote &r, int n)
148148
case NotificationType::Success:
149149
ss << "OK";
150150
break;
151+
default:
152+
break;
151153
}
152154
LOG_INFO(logger, ss.str() << " " << ts << " " << t);
153155
}

src/common/checks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <memory>
2727

2828
#include <primitives/log.h>
29-
DECLARE_STATIC_LOGGER(logger, "checks");
29+
//DECLARE_STATIC_LOGGER(logger, "checks");
3030

3131
const std::map<int, Check::Information> check_information{
3232
{ Check::Function,
@@ -314,7 +314,7 @@ void Checks::load(const yaml &root)
314314
s = n["decl"].template as<String>();
315315
CheckParameters p;
316316
p.load(n);
317-
auto ptr = this->addCheck<CheckDecl>(s, p);
317+
/*auto ptr = */this->addCheck<CheckDecl>(s, p);
318318
return;
319319
}
320320
else if (n.IsScalar())
@@ -351,7 +351,7 @@ void Checks::load(const yaml &root)
351351
{
352352
auto f = v["function"].template as<String>();
353353
auto lib = v["library"].template as<String>();
354-
auto p = this->addCheck<CheckLibraryFunction>(f, lib);
354+
/*auto p = */this->addCheck<CheckLibraryFunction>(f, lib);
355355
}
356356
});
357357

src/common/checks_detail.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ struct CheckSource : public Check
442442

443443
bool isOk() const override
444444
{
445-
return !invert && getValue() || invert && !getValue();
445+
return (!invert && getValue()) || (invert && !getValue());
446446
}
447447
};
448448

src/common/config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <iostream>
3434

3535
#include <primitives/log.h>
36-
DECLARE_STATIC_LOGGER(logger, "config");
36+
//DECLARE_STATIC_LOGGER(logger, "config");
3737

3838
Config::Config()
3939
{

src/common/database.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <shared_mutex>
4141

4242
#include <primitives/log.h>
43-
DECLARE_STATIC_LOGGER(logger, "db");
43+
//DECLARE_STATIC_LOGGER(logger, "db");
4444

4545
#define PACKAGES_DB_REFRESH_TIME_MINUTES 15
4646

@@ -410,10 +410,9 @@ void ServiceDatabase::recreateTable(const TableDescriptor &td) const
410410

411411
void ServiceDatabase::checkStamp() const
412412
{
413-
bool assigned = false;
414413
String s;
415414
db->execute("select * from ClientStamp",
416-
[&s, &assigned](SQLITE_CALLBACK_ARGS)
415+
[&s](SQLITE_CALLBACK_ARGS)
417416
{
418417
s = cols[0];
419418
return 0;
@@ -1108,7 +1107,7 @@ IdDependencies PackagesDatabase::findDependencies(const Packages &deps) const
11081107
// TODO: replace later with typed exception, so client will try to fetch same package from server
11091108
throw std::runtime_error("Package '" + project.ppath.toString() + "' not found.");
11101109

1111-
auto find_deps = [&dep, &all_deps, this](auto &dependency)
1110+
auto find_deps = [&all_deps, this](auto &dependency)
11121111
{
11131112
dependency.flags.set(pfDirectDependency);
11141113
dependency.id = getExactProjectVersionId(dependency, dependency.version, dependency.flags, dependency.hash);

0 commit comments

Comments
 (0)