mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Enable extra warnings for base, utils, programs
This commit is contained in:
parent
fb32dbe6ee
commit
a576a4fbcd
@ -103,7 +103,7 @@ endif ()
|
||||
include (cmake/add_warning.cmake)
|
||||
|
||||
if (NOT MSVC)
|
||||
set (COMMON_WARNING_FLAGS "${COMMON_WARNING_FLAGS} -Wall") # -Werror is also added inside directories with our own code.
|
||||
set (COMMON_WARNING_FLAGS "${COMMON_WARNING_FLAGS} -Wall") # -Werror and many more is also added inside cmake/warnings.cmake
|
||||
endif ()
|
||||
|
||||
if (COMPILER_CLANG)
|
||||
@ -403,6 +403,9 @@ endmacro()
|
||||
set(ConfigIncludePath ${CMAKE_CURRENT_BINARY_DIR}/includes/configs CACHE INTERNAL "Path to generated configuration files.")
|
||||
include_directories(${ConfigIncludePath})
|
||||
|
||||
# Add as many warnings as possible for our own code.
|
||||
include (cmake/warnings.cmake)
|
||||
|
||||
add_subdirectory (base)
|
||||
add_subdirectory (programs)
|
||||
add_subdirectory (src)
|
||||
|
@ -31,9 +31,8 @@ UInt8 getDayOfWeek(const cctz::civil_day & date)
|
||||
case cctz::weekday::friday: return 5;
|
||||
case cctz::weekday::saturday: return 6;
|
||||
case cctz::weekday::sunday: return 7;
|
||||
default:
|
||||
throw Poco::Exception("Logical error: incorrect week day.");
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -451,7 +451,10 @@ JSON JSON::operator[] (size_t n) const
|
||||
size_t i = 0;
|
||||
const_iterator it = begin();
|
||||
while (i < n && it != end())
|
||||
++it, ++i;
|
||||
{
|
||||
++it;
|
||||
++i;
|
||||
}
|
||||
|
||||
if (i != n)
|
||||
throw JSONException("JSON: array index " + std::to_string(n) + " out of bounds.");
|
||||
@ -626,7 +629,7 @@ std::string JSON::getString() const
|
||||
{
|
||||
unicode = Poco::NumberParser::parseHex(hex);
|
||||
}
|
||||
catch (const Poco::SyntaxException & e)
|
||||
catch (const Poco::SyntaxException &)
|
||||
{
|
||||
throw JSONException("JSON: incorrect syntax: incorrect HEX code.");
|
||||
}
|
||||
|
@ -3,12 +3,16 @@
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
#define MEMORY_SANITIZER 1
|
||||
#else
|
||||
#define MEMORY_SANITIZER 0
|
||||
#endif
|
||||
#elif defined(__MEMORY_SANITIZER__)
|
||||
#define MEMORY_SANITIZER 1
|
||||
#else
|
||||
#define MEMORY_SANITIZER 0
|
||||
#endif
|
||||
|
||||
#if _MSC_VER || MEMORY_SANITIZER
|
||||
#if defined(_MSC_VER) || MEMORY_SANITIZER
|
||||
|
||||
DemangleResult tryDemangle(const char * name)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ void * mremap_fallback(
|
||||
return MAP_FAILED;
|
||||
}
|
||||
|
||||
#if _MSC_VER
|
||||
#if defined(_MSC_VER)
|
||||
void * new_address = ::operator new(new_size);
|
||||
#else
|
||||
void * new_address = mmap(nullptr, new_size, mmap_prot, mmap_flags, mmap_fd, mmap_offset);
|
||||
@ -29,7 +29,7 @@ void * mremap_fallback(
|
||||
|
||||
memcpy(new_address, old_address, old_size);
|
||||
|
||||
#if _MSC_VER
|
||||
#if defined(_MSC_VER)
|
||||
delete old_address;
|
||||
#else
|
||||
if (munmap(old_address, old_size))
|
||||
|
@ -20,6 +20,8 @@
|
||||
#define USE_PHDR_CACHE 1
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
|
||||
|
||||
#define __msan_unpoison(X, Y)
|
||||
#if defined(__has_feature)
|
||||
# if __has_feature(memory_sanitizer)
|
||||
|
@ -1,5 +1,3 @@
|
||||
#define BOOST_TEST_MODULE StrongTypedef
|
||||
|
||||
#include <common/strong_typedef.h>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
@ -12,15 +10,15 @@
|
||||
TEST(StrongTypedefSuite, TypedefsOfTheSameType)
|
||||
{
|
||||
/// check that strong typedefs of same type differ
|
||||
STRONG_TYPEDEF(int, Int);
|
||||
STRONG_TYPEDEF(int, AnotherInt);
|
||||
STRONG_TYPEDEF(int, Int)
|
||||
STRONG_TYPEDEF(int, AnotherInt)
|
||||
|
||||
EXPECT_TRUE(!(std::is_same<Int, AnotherInt>::value));
|
||||
}
|
||||
|
||||
TEST(StrongTypedefSuite, Map)
|
||||
{
|
||||
STRONG_TYPEDEF(int, Int);
|
||||
STRONG_TYPEDEF(int, Int)
|
||||
|
||||
/// check that this code compiles
|
||||
std::set<Int> int_set;
|
||||
@ -31,13 +29,13 @@ TEST(StrongTypedefSuite, Map)
|
||||
|
||||
TEST(StrongTypedefSuite, CopyAndMoveCtor)
|
||||
{
|
||||
STRONG_TYPEDEF(int, Int);
|
||||
STRONG_TYPEDEF(int, Int)
|
||||
Int a(1);
|
||||
Int b(2);
|
||||
a = b;
|
||||
EXPECT_EQ(a.toUnderType(), 2);
|
||||
|
||||
STRONG_TYPEDEF(std::unique_ptr<int>, IntPtr);
|
||||
STRONG_TYPEDEF(std::unique_ptr<int>, IntPtr)
|
||||
{
|
||||
IntPtr ptr;
|
||||
ptr = IntPtr(std::make_unique<int>(3));
|
||||
@ -57,6 +55,6 @@ TEST(StrongTypedefSuite, NoDefaultCtor)
|
||||
NoDefaultCtor(int) {} // NOLINT
|
||||
};
|
||||
|
||||
STRONG_TYPEDEF(NoDefaultCtor, MyStruct);
|
||||
STRONG_TYPEDEF(NoDefaultCtor, MyStruct)
|
||||
MyStruct m(1);
|
||||
}
|
||||
|
@ -287,14 +287,11 @@ private:
|
||||
* and send it to pipe. Other thread will read this info from pipe and asynchronously write it to log.
|
||||
* Look at libstdc++-v3/libsupc++/vterminate.cc for example.
|
||||
*/
|
||||
static void terminate_handler()
|
||||
[[noreturn]] static void terminate_handler()
|
||||
{
|
||||
static thread_local bool terminating = false;
|
||||
if (terminating)
|
||||
{
|
||||
abort();
|
||||
return; /// Just for convenience.
|
||||
}
|
||||
|
||||
terminating = true;
|
||||
|
||||
@ -524,12 +521,12 @@ void BaseDaemon::initialize(Application & self)
|
||||
/// This must be done before any usage of DateLUT. In particular, before any logging.
|
||||
if (config().has("timezone"))
|
||||
{
|
||||
const std::string timezone = config().getString("timezone");
|
||||
if (0 != setenv("TZ", timezone.data(), 1))
|
||||
const std::string config_timezone = config().getString("timezone");
|
||||
if (0 != setenv("TZ", config_timezone.data(), 1))
|
||||
throw Poco::Exception("Cannot setenv TZ variable");
|
||||
|
||||
tzset();
|
||||
DateLUT::setDefaultTimezone(timezone);
|
||||
DateLUT::setDefaultTimezone(config_timezone);
|
||||
}
|
||||
|
||||
std::string log_path = config().getString("logger.log", "");
|
||||
|
@ -18,8 +18,6 @@ std::string errorMessage(MYSQL * driver)
|
||||
return res.str();
|
||||
}
|
||||
|
||||
|
||||
/// Для внутренних нужд библиотеки.
|
||||
void checkError(MYSQL * driver)
|
||||
{
|
||||
unsigned num = mysql_errno(driver);
|
||||
@ -28,8 +26,6 @@ void checkError(MYSQL * driver)
|
||||
throw Exception(errorMessage(driver), num);
|
||||
}
|
||||
|
||||
|
||||
/// Для внутренних нужд библиотеки.
|
||||
void onError(MYSQL * driver)
|
||||
{
|
||||
throw Exception(errorMessage(driver), mysql_errno(driver));
|
||||
|
@ -48,6 +48,6 @@ std::string errorMessage(MYSQL * driver);
|
||||
|
||||
/// For internal need of library.
|
||||
void checkError(MYSQL * driver);
|
||||
void onError(MYSQL * driver);
|
||||
[[noreturn]] void onError(MYSQL * driver);
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
Null() : is_null(true) {}
|
||||
Null(const Null<T> &) = default;
|
||||
Null(Null<T> &&) noexcept = default;
|
||||
Null(NullType data) : is_null(true) {}
|
||||
Null(NullType) : is_null(true) {}
|
||||
explicit Null(const T & data_) : data(data_), is_null(false) {}
|
||||
|
||||
operator T & ()
|
||||
@ -47,7 +47,7 @@ public:
|
||||
Null<T> & operator= (Null<T> &&) noexcept = default;
|
||||
Null<T> & operator= (const Null<T> &) = default;
|
||||
Null<T> & operator= (const T & data_) { is_null = false; data = data_; return *this; }
|
||||
Null<T> & operator= (const NullType other) { is_null = true; data = T(); return *this; }
|
||||
Null<T> & operator= (const NullType) { is_null = true; data = T(); return *this; }
|
||||
|
||||
bool isNull() const { return is_null; }
|
||||
|
||||
@ -57,7 +57,7 @@ public:
|
||||
|| (is_null == other.is_null && data < other.data);
|
||||
}
|
||||
|
||||
bool operator< (const NullType other) const { return false; }
|
||||
bool operator< (const NullType) const { return false; }
|
||||
|
||||
bool operator== (const Null<T> & other) const
|
||||
{
|
||||
@ -69,14 +69,14 @@ public:
|
||||
return !is_null && data == other;
|
||||
}
|
||||
|
||||
bool operator== (const NullType other) const { return is_null; }
|
||||
bool operator== (const NullType) const { return is_null; }
|
||||
|
||||
bool operator!= (const Null<T> & other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
bool operator!= (const NullType other) const { return !is_null; }
|
||||
bool operator!= (const NullType) const { return !is_null; }
|
||||
|
||||
bool operator!= (const T & other) const
|
||||
{
|
||||
|
@ -10,46 +10,47 @@ static bool startsWith(const std::string & s, const char * prefix)
|
||||
|
||||
using namespace mysqlxx;
|
||||
|
||||
PoolWithFailover::PoolWithFailover(const Poco::Util::AbstractConfiguration & config,
|
||||
const std::string & config_name, const unsigned default_connections,
|
||||
const unsigned max_connections, const size_t max_tries)
|
||||
: max_tries(max_tries)
|
||||
PoolWithFailover::PoolWithFailover(const Poco::Util::AbstractConfiguration & config_,
|
||||
const std::string & config_name_, const unsigned default_connections_,
|
||||
const unsigned max_connections_, const size_t max_tries_)
|
||||
: max_tries(max_tries_)
|
||||
{
|
||||
shareable = config.getBool(config_name + ".share_connection", false);
|
||||
if (config.has(config_name + ".replica"))
|
||||
shareable = config_.getBool(config_name_ + ".share_connection", false);
|
||||
if (config_.has(config_name_ + ".replica"))
|
||||
{
|
||||
Poco::Util::AbstractConfiguration::Keys replica_keys;
|
||||
config.keys(config_name, replica_keys);
|
||||
config_.keys(config_name_, replica_keys);
|
||||
for (const auto & replica_config_key : replica_keys)
|
||||
{
|
||||
/// There could be another elements in the same level in configuration file, like "password", "port"...
|
||||
if (startsWith(replica_config_key, "replica"))
|
||||
{
|
||||
std::string replica_name = config_name + "." + replica_config_key;
|
||||
std::string replica_name = config_name_ + "." + replica_config_key;
|
||||
|
||||
int priority = config.getInt(replica_name + ".priority", 0);
|
||||
int priority = config_.getInt(replica_name + ".priority", 0);
|
||||
|
||||
replicas_by_priority[priority].emplace_back(
|
||||
std::make_shared<Pool>(config, replica_name, default_connections, max_connections, config_name.c_str()));
|
||||
std::make_shared<Pool>(config_, replica_name, default_connections_, max_connections_, config_name_.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
replicas_by_priority[0].emplace_back(
|
||||
std::make_shared<Pool>(config, config_name, default_connections, max_connections));
|
||||
std::make_shared<Pool>(config_, config_name_, default_connections_, max_connections_));
|
||||
}
|
||||
}
|
||||
|
||||
PoolWithFailover::PoolWithFailover(const std::string & config_name, const unsigned default_connections,
|
||||
const unsigned max_connections, const size_t max_tries)
|
||||
PoolWithFailover::PoolWithFailover(const std::string & config_name_, const unsigned default_connections_,
|
||||
const unsigned max_connections_, const size_t max_tries_)
|
||||
: PoolWithFailover{
|
||||
Poco::Util::Application::instance().config(), config_name,
|
||||
default_connections, max_connections, max_tries}
|
||||
{}
|
||||
Poco::Util::Application::instance().config(), config_name_,
|
||||
default_connections_, max_connections_, max_tries_}
|
||||
{
|
||||
}
|
||||
|
||||
PoolWithFailover::PoolWithFailover(const PoolWithFailover & other)
|
||||
: max_tries{other.max_tries}, config_name{other.config_name}, shareable{other.shareable}
|
||||
: max_tries{other.max_tries}, shareable{other.shareable}
|
||||
{
|
||||
if (shareable)
|
||||
{
|
||||
|
@ -77,7 +77,6 @@ namespace mysqlxx
|
||||
size_t max_tries;
|
||||
/// Mutex for set of replicas.
|
||||
std::mutex mutex;
|
||||
std::string config_name;
|
||||
|
||||
/// Can the Pool be shared
|
||||
bool shareable;
|
||||
@ -91,16 +90,16 @@ namespace mysqlxx
|
||||
* max_connections Maximum number of connections in pool to each replica.
|
||||
* max_tries_ Max number of connection tries.
|
||||
*/
|
||||
PoolWithFailover(const std::string & config_name,
|
||||
unsigned default_connections = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS,
|
||||
unsigned max_connections = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS,
|
||||
size_t max_tries = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES);
|
||||
PoolWithFailover(const std::string & config_name_,
|
||||
unsigned default_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS,
|
||||
unsigned max_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS,
|
||||
size_t max_tries_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES);
|
||||
|
||||
PoolWithFailover(const Poco::Util::AbstractConfiguration & config,
|
||||
const std::string & config_name,
|
||||
unsigned default_connections = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS,
|
||||
unsigned max_connections = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS,
|
||||
size_t max_tries = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES);
|
||||
PoolWithFailover(const Poco::Util::AbstractConfiguration & config_,
|
||||
const std::string & config_name_,
|
||||
unsigned default_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS,
|
||||
unsigned max_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS,
|
||||
size_t max_tries_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_TRIES);
|
||||
|
||||
PoolWithFailover(const PoolWithFailover & other);
|
||||
|
||||
|
@ -68,10 +68,10 @@ int main(int, char **)
|
||||
Queries queries;
|
||||
queries.push_back(query);
|
||||
|
||||
for (auto & query : queries)
|
||||
for (auto & q : queries)
|
||||
{
|
||||
std::cerr << query.str() << std::endl;
|
||||
std::cerr << query.store().at(0) << std::endl;
|
||||
std::cerr << q.str() << std::endl;
|
||||
std::cerr << q.store().at(0) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
165
cmake/warnings.cmake
Normal file
165
cmake/warnings.cmake
Normal file
@ -0,0 +1,165 @@
|
||||
# Our principle is to enable as many warnings as possible and always do it with "warnings as errors" flag.
|
||||
#
|
||||
# But it comes with some cost:
|
||||
# - we have to disable some warnings in 3rd party libraries (they are located in "contrib" directory)
|
||||
# - we have to include headers of these libraries as -isystem to avoid warnings from headers
|
||||
# (this is the same behaviour as if these libraries were located in /usr/include)
|
||||
# - sometimes warnings from 3rd party libraries may come from macro substitutions in our code
|
||||
# and we have to wrap them with #pragma GCC/clang diagnostic ignored
|
||||
|
||||
if (NOT MSVC)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
|
||||
endif ()
|
||||
|
||||
if (USE_DEBUG_HELPERS)
|
||||
set (INCLUDE_DEBUG_HELPERS "-I${ClickHouse_SOURCE_DIR}/base -include ${ClickHouse_SOURCE_DIR}/src/Core/iostream_debug_helpers.h")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INCLUDE_DEBUG_HELPERS}")
|
||||
endif ()
|
||||
|
||||
# Add some warnings that are not available even with -Wall -Wextra -Wpedantic.
|
||||
|
||||
option (WEVERYTHING "Enables -Weverything option with some exceptions. This is intended for exploration of new compiler warnings that may be found to be useful. Only makes sense for clang." ON)
|
||||
|
||||
if (COMPILER_CLANG)
|
||||
add_warning(pedantic)
|
||||
no_warning(vla-extension)
|
||||
no_warning(zero-length-array)
|
||||
|
||||
add_warning(comma)
|
||||
add_warning(conditional-uninitialized)
|
||||
add_warning(covered-switch-default)
|
||||
add_warning(deprecated)
|
||||
add_warning(embedded-directive)
|
||||
add_warning(empty-init-stmt) # linux-only
|
||||
add_warning(extra-semi-stmt) # linux-only
|
||||
add_warning(extra-semi)
|
||||
add_warning(gnu-case-range)
|
||||
add_warning(inconsistent-missing-destructor-override)
|
||||
add_warning(newline-eof)
|
||||
add_warning(old-style-cast)
|
||||
add_warning(range-loop-analysis)
|
||||
add_warning(redundant-parens)
|
||||
add_warning(reserved-id-macro)
|
||||
add_warning(shadow-field) # clang 8+
|
||||
add_warning(shadow-uncaptured-local)
|
||||
add_warning(shadow)
|
||||
add_warning(string-plus-int) # clang 8+
|
||||
add_warning(undef)
|
||||
add_warning(unreachable-code-return)
|
||||
add_warning(unreachable-code)
|
||||
add_warning(unused-exception-parameter)
|
||||
add_warning(unused-macros)
|
||||
add_warning(unused-member-function)
|
||||
add_warning(zero-as-null-pointer-constant)
|
||||
|
||||
if (WEVERYTHING)
|
||||
add_warning(everything)
|
||||
no_warning(c++98-compat-pedantic)
|
||||
no_warning(c++98-compat)
|
||||
no_warning(c99-extensions)
|
||||
no_warning(conversion)
|
||||
no_warning(ctad-maybe-unsupported) # clang 9+, linux-only
|
||||
no_warning(deprecated-dynamic-exception-spec)
|
||||
no_warning(disabled-macro-expansion)
|
||||
no_warning(documentation-unknown-command)
|
||||
no_warning(double-promotion)
|
||||
no_warning(exit-time-destructors)
|
||||
no_warning(float-equal)
|
||||
no_warning(global-constructors)
|
||||
no_warning(missing-prototypes)
|
||||
no_warning(missing-variable-declarations)
|
||||
no_warning(nested-anon-types)
|
||||
no_warning(packed)
|
||||
no_warning(padded)
|
||||
no_warning(return-std-move-in-c++11) # clang 7+
|
||||
no_warning(shift-sign-overflow)
|
||||
no_warning(sign-conversion)
|
||||
no_warning(switch-enum)
|
||||
no_warning(undefined-func-template)
|
||||
no_warning(unused-template)
|
||||
no_warning(vla)
|
||||
no_warning(weak-template-vtables)
|
||||
no_warning(weak-vtables)
|
||||
|
||||
# TODO Enable conversion, sign-conversion, double-promotion warnings.
|
||||
endif ()
|
||||
elseif (COMPILER_GCC)
|
||||
# Add compiler options only to c++ compiler
|
||||
function(add_cxx_compile_options option)
|
||||
add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${option}>")
|
||||
endfunction()
|
||||
# Warn about boolean expression compared with an integer value different from true/false
|
||||
add_cxx_compile_options(-Wbool-compare)
|
||||
# Warn whenever a pointer is cast such that the required alignment of the target is increased.
|
||||
add_cxx_compile_options(-Wcast-align)
|
||||
# Warn whenever a pointer is cast so as to remove a type qualifier from the target type.
|
||||
add_cxx_compile_options(-Wcast-qual)
|
||||
# Warn when deleting a pointer to incomplete type, which may cause undefined behavior at runtime
|
||||
add_cxx_compile_options(-Wdelete-incomplete)
|
||||
# Warn if a requested optimization pass is disabled. Code is too big or too complex
|
||||
add_cxx_compile_options(-Wdisabled-optimization)
|
||||
# Warn about duplicated conditions in an if-else-if chain
|
||||
add_cxx_compile_options(-Wduplicated-cond)
|
||||
# Warn about a comparison between values of different enumerated types
|
||||
add_cxx_compile_options(-Wenum-compare)
|
||||
# Warn about uninitialized variables that are initialized with themselves
|
||||
add_cxx_compile_options(-Winit-self)
|
||||
# Warn about logical not used on the left hand side operand of a comparison
|
||||
add_cxx_compile_options(-Wlogical-not-parentheses)
|
||||
# Warn about suspicious uses of logical operators in expressions
|
||||
add_cxx_compile_options(-Wlogical-op)
|
||||
# Warn if there exists a path from the function entry to a use of the variable that is uninitialized.
|
||||
add_cxx_compile_options(-Wmaybe-uninitialized)
|
||||
# Warn when the indentation of the code does not reflect the block structure
|
||||
add_cxx_compile_options(-Wmisleading-indentation)
|
||||
# Warn if a global function is defined without a previous declaration - disabled because of build times
|
||||
# add_cxx_compile_options(-Wmissing-declarations)
|
||||
# Warn if a user-supplied include directory does not exist
|
||||
add_cxx_compile_options(-Wmissing-include-dirs)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wnon-virtual-dtor)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wno-return-local-addr)
|
||||
# This warning is disabled due to false positives if compiled with libc++: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90037
|
||||
#add_cxx_compile_options(-Wnull-dereference)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wodr)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wold-style-cast)
|
||||
# Warn when a function declaration hides virtual functions from a base class
|
||||
# add_cxx_compile_options(-Woverloaded-virtual)
|
||||
# Warn about placement new expressions with undefined behavior
|
||||
add_cxx_compile_options(-Wplacement-new=2)
|
||||
# Warn about anything that depends on the “size of” a function type or of void
|
||||
add_cxx_compile_options(-Wpointer-arith)
|
||||
# Warn if anything is declared more than once in the same scope
|
||||
add_cxx_compile_options(-Wredundant-decls)
|
||||
# Member initialization reordering
|
||||
add_cxx_compile_options(-Wreorder)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wshadow)
|
||||
# Warn if left shifting a negative value
|
||||
add_cxx_compile_options(-Wshift-negative-value)
|
||||
# Warn about a definition of an unsized deallocation function
|
||||
add_cxx_compile_options(-Wsized-deallocation)
|
||||
# Warn when the sizeof operator is applied to a parameter that is declared as an array in a function definition
|
||||
add_cxx_compile_options(-Wsizeof-array-argument)
|
||||
# Warn for suspicious length parameters to certain string and memory built-in functions if the argument uses sizeof
|
||||
add_cxx_compile_options(-Wsizeof-pointer-memaccess)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
|
||||
# Warn about overriding virtual functions that are not marked with the override keyword
|
||||
add_cxx_compile_options(-Wsuggest-override)
|
||||
endif ()
|
||||
|
||||
# Warn whenever a switch statement has an index of boolean type and the case values are outside the range of a boolean type
|
||||
add_cxx_compile_options(-Wswitch-bool)
|
||||
# Warn if a self-comparison always evaluates to true or false
|
||||
add_cxx_compile_options(-Wtautological-compare)
|
||||
# Warn about trampolines generated for pointers to nested functions
|
||||
add_cxx_compile_options(-Wtrampolines)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wunused)
|
||||
# Warn if vector operation is not implemented via SIMD capabilities of the architecture
|
||||
add_cxx_compile_options(-Wvector-operation-performance)
|
||||
endif ()
|
@ -20,14 +20,14 @@ if (ENABLE_REPLXX)
|
||||
)
|
||||
|
||||
add_library (replxx ${SRCS})
|
||||
target_include_directories(replxx PUBLIC ${LIBRARY_DIR}/include)
|
||||
target_include_directories(replxx SYSTEM PUBLIC ${LIBRARY_DIR}/include)
|
||||
else ()
|
||||
find_library(LIBRARY_REPLXX NAMES replxx replxx-static)
|
||||
find_path(INCLUDE_REPLXX replxx.hxx)
|
||||
|
||||
add_library(replxx UNKNOWN IMPORTED)
|
||||
set_property(TARGET replxx PROPERTY IMPORTED_LOCATION ${LIBRARY_REPLXX})
|
||||
target_include_directories(replxx PUBLIC ${INCLUDE_REPLXX})
|
||||
target_include_directories(replxx SYSTEM PUBLIC ${INCLUDE_REPLXX})
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES replxx)
|
||||
check_cxx_source_compiles(
|
||||
|
@ -1837,6 +1837,8 @@ UInt64 ClusterCopier::executeQueryOnCluster(
|
||||
ClusterExecutionMode execution_mode,
|
||||
UInt64 max_successful_executions_per_shard) const
|
||||
{
|
||||
Settings current_settings = settings ? *settings : task_cluster->settings_common;
|
||||
|
||||
auto num_shards = cluster->getShardsInfo().size();
|
||||
std::vector<UInt64> per_shard_num_successful_replicas(num_shards, 0);
|
||||
|
||||
@ -1844,8 +1846,7 @@ UInt64 ClusterCopier::executeQueryOnCluster(
|
||||
if (query_ast_ == nullptr)
|
||||
{
|
||||
ParserQuery p_query(query.data() + query.size());
|
||||
const auto & settings = context.getSettingsRef();
|
||||
query_ast = parseQuery(p_query, query, settings.max_query_size, settings.max_parser_depth);
|
||||
query_ast = parseQuery(p_query, query, current_settings.max_query_size, current_settings.max_parser_depth);
|
||||
}
|
||||
else
|
||||
query_ast = query_ast_;
|
||||
@ -1888,7 +1889,6 @@ UInt64 ClusterCopier::executeQueryOnCluster(
|
||||
/// Will try to make as many as possible queries
|
||||
if (shard.hasRemoteConnections())
|
||||
{
|
||||
Settings current_settings = settings ? *settings : task_cluster->settings_common;
|
||||
current_settings.max_parallel_replicas = num_remote_replicas ? num_remote_replicas : 1;
|
||||
|
||||
auto timeouts = ConnectionTimeouts::getTCPTimeoutsWithFailover(current_settings).getSaturated(current_settings.max_execution_time);
|
||||
|
@ -24,7 +24,7 @@ private:
|
||||
std::vector<Poco::Net::HTTPRequestHandlerFactory *> child_factories;
|
||||
public:
|
||||
|
||||
~HTTPRequestHandlerFactoryMain();
|
||||
~HTTPRequestHandlerFactoryMain() override;
|
||||
|
||||
HTTPRequestHandlerFactoryMain(const std::string & name_);
|
||||
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
LOG_TRACE(log, "TCP Request. Address: " << socket.peerAddress().toString());
|
||||
return new TCPHandler(server, socket);
|
||||
}
|
||||
catch (const Poco::Net::NetException & e)
|
||||
catch (const Poco::Net::NetException &)
|
||||
{
|
||||
LOG_TRACE(log, "TCP Request. Client is not connected (most likely RST packet was sent).");
|
||||
return new DummyTCPHandler(socket);
|
||||
|
@ -27,163 +27,6 @@ configure_file (Common/config.h.in ${CONFIG_COMMON})
|
||||
configure_file (Common/config_version.h.in ${CONFIG_VERSION})
|
||||
configure_file (Core/config_core.h.in ${CMAKE_CURRENT_BINARY_DIR}/Core/include/config_core.h)
|
||||
|
||||
if (NOT MSVC)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
|
||||
endif ()
|
||||
|
||||
if (USE_DEBUG_HELPERS)
|
||||
set (INCLUDE_DEBUG_HELPERS "-I${ClickHouse_SOURCE_DIR}/base -include ${ClickHouse_SOURCE_DIR}/src/Core/iostream_debug_helpers.h")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INCLUDE_DEBUG_HELPERS}")
|
||||
endif ()
|
||||
|
||||
# Add some warnings that are not available even with -Wall -Wextra -Wpedantic.
|
||||
|
||||
option (WEVERYTHING "Enables -Weverything option with some exceptions. This is intended for exploration of new compiler warnings that may be found to be useful. Only makes sense for clang." ON)
|
||||
|
||||
if (COMPILER_CLANG)
|
||||
add_warning(pedantic)
|
||||
no_warning(vla-extension)
|
||||
no_warning(zero-length-array)
|
||||
|
||||
add_warning(comma)
|
||||
add_warning(conditional-uninitialized)
|
||||
add_warning(covered-switch-default)
|
||||
add_warning(deprecated)
|
||||
add_warning(embedded-directive)
|
||||
add_warning(empty-init-stmt) # linux-only
|
||||
add_warning(extra-semi-stmt) # linux-only
|
||||
add_warning(extra-semi)
|
||||
add_warning(gnu-case-range)
|
||||
add_warning(inconsistent-missing-destructor-override)
|
||||
add_warning(newline-eof)
|
||||
add_warning(old-style-cast)
|
||||
add_warning(range-loop-analysis)
|
||||
add_warning(redundant-parens)
|
||||
add_warning(reserved-id-macro)
|
||||
add_warning(shadow-field) # clang 8+
|
||||
add_warning(shadow-uncaptured-local)
|
||||
add_warning(shadow)
|
||||
add_warning(string-plus-int) # clang 8+
|
||||
add_warning(undef)
|
||||
add_warning(unreachable-code-return)
|
||||
add_warning(unreachable-code)
|
||||
add_warning(unused-exception-parameter)
|
||||
add_warning(unused-macros)
|
||||
add_warning(unused-member-function)
|
||||
add_warning(zero-as-null-pointer-constant)
|
||||
|
||||
if (WEVERYTHING)
|
||||
add_warning(everything)
|
||||
no_warning(c++98-compat-pedantic)
|
||||
no_warning(c++98-compat)
|
||||
no_warning(c99-extensions)
|
||||
no_warning(conversion)
|
||||
no_warning(ctad-maybe-unsupported) # clang 9+, linux-only
|
||||
no_warning(deprecated-dynamic-exception-spec)
|
||||
no_warning(disabled-macro-expansion)
|
||||
no_warning(documentation-unknown-command)
|
||||
no_warning(double-promotion)
|
||||
no_warning(exit-time-destructors)
|
||||
no_warning(float-equal)
|
||||
no_warning(global-constructors)
|
||||
no_warning(missing-prototypes)
|
||||
no_warning(missing-variable-declarations)
|
||||
no_warning(nested-anon-types)
|
||||
no_warning(packed)
|
||||
no_warning(padded)
|
||||
no_warning(return-std-move-in-c++11) # clang 7+
|
||||
no_warning(shift-sign-overflow)
|
||||
no_warning(sign-conversion)
|
||||
no_warning(switch-enum)
|
||||
no_warning(undefined-func-template)
|
||||
no_warning(unused-template)
|
||||
no_warning(vla)
|
||||
no_warning(weak-template-vtables)
|
||||
no_warning(weak-vtables)
|
||||
|
||||
# TODO Enable conversion, sign-conversion, double-promotion warnings.
|
||||
endif ()
|
||||
elseif (COMPILER_GCC)
|
||||
# Add compiler options only to c++ compiler
|
||||
function(add_cxx_compile_options option)
|
||||
add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${option}>")
|
||||
endfunction()
|
||||
# Warn about boolean expression compared with an integer value different from true/false
|
||||
add_cxx_compile_options(-Wbool-compare)
|
||||
# Warn whenever a pointer is cast such that the required alignment of the target is increased.
|
||||
add_cxx_compile_options(-Wcast-align)
|
||||
# Warn whenever a pointer is cast so as to remove a type qualifier from the target type.
|
||||
add_cxx_compile_options(-Wcast-qual)
|
||||
# Warn when deleting a pointer to incomplete type, which may cause undefined behavior at runtime
|
||||
add_cxx_compile_options(-Wdelete-incomplete)
|
||||
# Warn if a requested optimization pass is disabled. Code is too big or too complex
|
||||
add_cxx_compile_options(-Wdisabled-optimization)
|
||||
# Warn about duplicated conditions in an if-else-if chain
|
||||
add_cxx_compile_options(-Wduplicated-cond)
|
||||
# Warn about a comparison between values of different enumerated types
|
||||
add_cxx_compile_options(-Wenum-compare)
|
||||
# Warn about uninitialized variables that are initialized with themselves
|
||||
add_cxx_compile_options(-Winit-self)
|
||||
# Warn about logical not used on the left hand side operand of a comparison
|
||||
add_cxx_compile_options(-Wlogical-not-parentheses)
|
||||
# Warn about suspicious uses of logical operators in expressions
|
||||
add_cxx_compile_options(-Wlogical-op)
|
||||
# Warn if there exists a path from the function entry to a use of the variable that is uninitialized.
|
||||
add_cxx_compile_options(-Wmaybe-uninitialized)
|
||||
# Warn when the indentation of the code does not reflect the block structure
|
||||
add_cxx_compile_options(-Wmisleading-indentation)
|
||||
# Warn if a global function is defined without a previous declaration - disabled because of build times
|
||||
# add_cxx_compile_options(-Wmissing-declarations)
|
||||
# Warn if a user-supplied include directory does not exist
|
||||
add_cxx_compile_options(-Wmissing-include-dirs)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wnon-virtual-dtor)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wno-return-local-addr)
|
||||
# This warning is disabled due to false positives if compiled with libc++: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90037
|
||||
#add_cxx_compile_options(-Wnull-dereference)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wodr)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wold-style-cast)
|
||||
# Warn when a function declaration hides virtual functions from a base class
|
||||
# add_cxx_compile_options(-Woverloaded-virtual)
|
||||
# Warn about placement new expressions with undefined behavior
|
||||
add_cxx_compile_options(-Wplacement-new=2)
|
||||
# Warn about anything that depends on the “size of” a function type or of void
|
||||
add_cxx_compile_options(-Wpointer-arith)
|
||||
# Warn if anything is declared more than once in the same scope
|
||||
add_cxx_compile_options(-Wredundant-decls)
|
||||
# Member initialization reordering
|
||||
add_cxx_compile_options(-Wreorder)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wshadow)
|
||||
# Warn if left shifting a negative value
|
||||
add_cxx_compile_options(-Wshift-negative-value)
|
||||
# Warn about a definition of an unsized deallocation function
|
||||
add_cxx_compile_options(-Wsized-deallocation)
|
||||
# Warn when the sizeof operator is applied to a parameter that is declared as an array in a function definition
|
||||
add_cxx_compile_options(-Wsizeof-array-argument)
|
||||
# Warn for suspicious length parameters to certain string and memory built-in functions if the argument uses sizeof
|
||||
add_cxx_compile_options(-Wsizeof-pointer-memaccess)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
|
||||
# Warn about overriding virtual functions that are not marked with the override keyword
|
||||
add_cxx_compile_options(-Wsuggest-override)
|
||||
endif ()
|
||||
|
||||
# Warn whenever a switch statement has an index of boolean type and the case values are outside the range of a boolean type
|
||||
add_cxx_compile_options(-Wswitch-bool)
|
||||
# Warn if a self-comparison always evaluates to true or false
|
||||
add_cxx_compile_options(-Wtautological-compare)
|
||||
# Warn about trampolines generated for pointers to nested functions
|
||||
add_cxx_compile_options(-Wtrampolines)
|
||||
# Obvious
|
||||
add_cxx_compile_options(-Wunused)
|
||||
# Warn if vector operation is not implemented via SIMD capabilities of the architecture
|
||||
add_cxx_compile_options(-Wvector-operation-performance)
|
||||
endif ()
|
||||
|
||||
if (COMPILER_GCC)
|
||||
# If we leave this optimization enabled, gcc-7 replaces a pair of SSE intrinsics (16 byte load, store) with a call to memcpy.
|
||||
# It leads to slow code. This is compiler bug. It looks like this:
|
||||
|
@ -26,54 +26,7 @@ namespace DB
|
||||
}
|
||||
|
||||
|
||||
/// Read and check header of compressed block. Print size of decompressed and compressed data.
|
||||
std::pair<UInt32, UInt32> stat(DB::ReadBuffer & in, DB::WriteBuffer & out)
|
||||
{
|
||||
if (in.eof())
|
||||
return {};
|
||||
|
||||
in.ignore(16); /// checksum
|
||||
|
||||
char header[COMPRESSED_BLOCK_HEADER_SIZE];
|
||||
in.readStrict(header, COMPRESSED_BLOCK_HEADER_SIZE);
|
||||
|
||||
UInt32 size_compressed = unalignedLoad<UInt32>(&header[1]);
|
||||
|
||||
if (size_compressed > DBMS_MAX_COMPRESSED_SIZE)
|
||||
throw DB::Exception("Too large size_compressed. Most likely corrupted data.", DB::ErrorCodes::TOO_LARGE_SIZE_COMPRESSED);
|
||||
|
||||
UInt32 size_decompressed = unalignedLoad<UInt32>(&header[5]);
|
||||
|
||||
return {size_compressed, size_decompressed};
|
||||
}
|
||||
|
||||
|
||||
void checkCompressedHeaders(const std::string & mrk_path, const std::string & bin_path)
|
||||
{
|
||||
DB::ReadBufferFromFile mrk_in(mrk_path);
|
||||
DB::ReadBufferFromFile bin_in(bin_path, 4096); /// Small buffer size just to check header of compressed block.
|
||||
|
||||
DB::WriteBufferFromFileDescriptor out(STDOUT_FILENO);
|
||||
|
||||
for (size_t mark_num = 0; !mrk_in.eof(); ++mark_num)
|
||||
{
|
||||
UInt64 offset_in_compressed_file = 0;
|
||||
UInt64 offset_in_decompressed_block = 0;
|
||||
|
||||
DB::readBinary(offset_in_compressed_file, mrk_in);
|
||||
DB::readBinary(offset_in_decompressed_block, mrk_in);
|
||||
|
||||
out << "Mark " << mark_num << ", points to " << offset_in_compressed_file << ", " << offset_in_decompressed_block << ". ";
|
||||
|
||||
bin_in.seek(offset_in_compressed_file, SEEK_SET);
|
||||
auto sizes = stat(bin_in, out);
|
||||
|
||||
out << "Block sizes: " << sizes.first << ", " << sizes.second << '\n' << DB::flush;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void checkByCompressedReadBuffer(const std::string & mrk_path, const std::string & bin_path)
|
||||
static void checkByCompressedReadBuffer(const std::string & mrk_path, const std::string & bin_path)
|
||||
{
|
||||
DB::ReadBufferFromFile mrk_in(mrk_path);
|
||||
DB::CompressedReadBufferFromFile bin_in(bin_path, 0, 0, 0);
|
||||
@ -125,7 +78,6 @@ int main(int argc, char ** argv)
|
||||
|
||||
try
|
||||
{
|
||||
/// checkCompressedHeaders(argv[1], argv[2]);
|
||||
checkByCompressedReadBuffer(argv[1], argv[2]);
|
||||
}
|
||||
catch (const DB::Exception & e)
|
||||
|
@ -119,8 +119,8 @@ protected:
|
||||
|
||||
public:
|
||||
/// 'compressed_in' could be initialized lazily, but before first call of 'readCompressedData'.
|
||||
FasterCompressedReadBufferBase(ReadBuffer * in, ssize_t variant)
|
||||
: compressed_in(in), own_compressed_buffer(COMPRESSED_BLOCK_HEADER_SIZE), variant(variant), perf_stat(variant)
|
||||
FasterCompressedReadBufferBase(ReadBuffer * in, ssize_t variant_)
|
||||
: compressed_in(in), own_compressed_buffer(COMPRESSED_BLOCK_HEADER_SIZE), variant(variant_), perf_stat(variant)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,12 @@
|
||||
#include <IO/WriteBufferValidUTF8.h>
|
||||
#include <IO/copyData.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int, char **)
|
||||
{
|
||||
DB::ReadBufferFromFileDescriptor rb(STDIN_FILENO);
|
||||
DB::WriteBufferFromFileDescriptor wb(STDOUT_FILENO);
|
||||
DB::WriteBufferValidUTF8 utf8_b(wb);
|
||||
DB::copyData(rb, utf8_b);
|
||||
using namespace DB;
|
||||
ReadBufferFromFileDescriptor rb(STDIN_FILENO);
|
||||
WriteBufferFromFileDescriptor wb(STDOUT_FILENO);
|
||||
WriteBufferValidUTF8 utf8_b(wb);
|
||||
copyData(rb, utf8_b);
|
||||
return 0;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ int mainImpl(int argc, char ** argv)
|
||||
{
|
||||
using namespace DB;
|
||||
|
||||
const char * file_name = 0;
|
||||
const char * file_name = nullptr;
|
||||
int mode = MODE_NONE;
|
||||
UInt64 min_offset = 0;
|
||||
UInt64 max_offset = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#if __APPLE__ || __FreeBSD__
|
||||
#if !OS_LINUX
|
||||
int main(int, char **) { return 0; }
|
||||
#else
|
||||
|
||||
@ -138,7 +138,7 @@ int mainImpl(int argc, char ** argv)
|
||||
{
|
||||
using namespace DB;
|
||||
|
||||
const char * file_name = 0;
|
||||
const char * file_name = nullptr;
|
||||
int mode = MODE_READ;
|
||||
UInt64 min_offset = 0;
|
||||
UInt64 max_offset = 0;
|
||||
|
@ -47,7 +47,7 @@ int mainImpl(int argc, char ** argv)
|
||||
{
|
||||
using namespace DB;
|
||||
|
||||
const char * file_name = 0;
|
||||
const char * file_name = nullptr;
|
||||
Mode mode = MODE_READ;
|
||||
UInt64 min_offset = 0;
|
||||
UInt64 max_offset = 0;
|
||||
|
@ -1,3 +1,5 @@
|
||||
add_compile_options(-Wno-zero-as-null-pointer-constant) # Protobuf generated files
|
||||
|
||||
if (USE_PROTOBUF)
|
||||
protobuf_generate_cpp(ProtobufDelimitedMessagesSerializer_Srcs ProtobufDelimitedMessagesSerializer_Hdrs ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/queries/0_stateless/00825_protobuf_format.proto)
|
||||
protobuf_generate_cpp(ProtobufDelimitedMessagesSerializer_Srcs2 ProtobufDelimitedMessagesSerializer_Hdrs2 ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/queries/0_stateless/00825_protobuf_format_syntax2.proto)
|
||||
|
@ -279,7 +279,7 @@ try
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (const Poco::Exception & e)
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << DB::getCurrentExceptionMessage(true) << '\n';
|
||||
throw;
|
||||
|
@ -108,13 +108,13 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
DB::ReadBufferFromString in(line);
|
||||
|
||||
std::string path;
|
||||
std::string path_ignored;
|
||||
std::string data;
|
||||
std::string mode;
|
||||
|
||||
DB::assertString("create", in);
|
||||
DB::skipWhitespaceIfAny(in);
|
||||
readMaybeQuoted(path, in);
|
||||
readMaybeQuoted(path_ignored, in);
|
||||
DB::skipWhitespaceIfAny(in);
|
||||
readMaybeQuoted(data, in);
|
||||
DB::skipWhitespaceIfAny(in);
|
||||
|
@ -40,7 +40,7 @@ try
|
||||
zookeeper.create(path + "/queue-", entry.toString(), zkutil::CreateMode::PersistentSequential);
|
||||
return 0;
|
||||
}
|
||||
catch (const Poco::Exception & e)
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << DB::getCurrentExceptionMessage(true) << '\n';
|
||||
throw;
|
||||
|
@ -59,7 +59,7 @@ try
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (const Poco::Exception & e)
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << DB::getCurrentExceptionMessage(true) << '\n';
|
||||
throw;
|
||||
|
Loading…
Reference in New Issue
Block a user