mirror of https://github.com/ByConity/ByConity
Enable clang-tidy for programs and utils
This commit is contained in:
parent
073dc2e1e3
commit
b0a5ce7743
14
.clang-tidy
14
.clang-tidy
|
@ -9,7 +9,7 @@ Checks: '-*,
|
||||||
misc-unused-alias-decls,
|
misc-unused-alias-decls,
|
||||||
misc-unused-parameters,
|
misc-unused-parameters,
|
||||||
misc-unused-using-decls,
|
misc-unused-using-decls,
|
||||||
|
|
||||||
modernize-avoid-bind,
|
modernize-avoid-bind,
|
||||||
modernize-loop-convert,
|
modernize-loop-convert,
|
||||||
modernize-make-shared,
|
modernize-make-shared,
|
||||||
|
@ -33,7 +33,7 @@ Checks: '-*,
|
||||||
performance-no-automatic-move,
|
performance-no-automatic-move,
|
||||||
performance-trivially-destructible,
|
performance-trivially-destructible,
|
||||||
performance-unnecessary-copy-initialization,
|
performance-unnecessary-copy-initialization,
|
||||||
|
|
||||||
readability-avoid-const-params-in-decls,
|
readability-avoid-const-params-in-decls,
|
||||||
readability-const-return-type,
|
readability-const-return-type,
|
||||||
readability-container-size-empty,
|
readability-container-size-empty,
|
||||||
|
@ -58,7 +58,7 @@ Checks: '-*,
|
||||||
readability-simplify-boolean-expr,
|
readability-simplify-boolean-expr,
|
||||||
readability-inconsistent-declaration-parameter-name,
|
readability-inconsistent-declaration-parameter-name,
|
||||||
readability-identifier-naming,
|
readability-identifier-naming,
|
||||||
|
|
||||||
bugprone-undelegated-constructor,
|
bugprone-undelegated-constructor,
|
||||||
bugprone-argument-comment,
|
bugprone-argument-comment,
|
||||||
bugprone-bad-signal-to-kill-thread,
|
bugprone-bad-signal-to-kill-thread,
|
||||||
|
@ -102,7 +102,7 @@ Checks: '-*,
|
||||||
bugprone-unused-return-value,
|
bugprone-unused-return-value,
|
||||||
bugprone-use-after-move,
|
bugprone-use-after-move,
|
||||||
bugprone-virtual-near-miss,
|
bugprone-virtual-near-miss,
|
||||||
|
|
||||||
cert-dcl21-cpp,
|
cert-dcl21-cpp,
|
||||||
cert-dcl50-cpp,
|
cert-dcl50-cpp,
|
||||||
cert-env33-c,
|
cert-env33-c,
|
||||||
|
@ -112,7 +112,7 @@ Checks: '-*,
|
||||||
cert-mem57-cpp,
|
cert-mem57-cpp,
|
||||||
cert-msc50-cpp,
|
cert-msc50-cpp,
|
||||||
cert-oop58-cpp,
|
cert-oop58-cpp,
|
||||||
|
|
||||||
google-build-explicit-make-pair,
|
google-build-explicit-make-pair,
|
||||||
google-build-namespaces,
|
google-build-namespaces,
|
||||||
google-default-arguments,
|
google-default-arguments,
|
||||||
|
@ -121,9 +121,9 @@ Checks: '-*,
|
||||||
google-readability-avoid-underscore-in-googletest-name,
|
google-readability-avoid-underscore-in-googletest-name,
|
||||||
google-runtime-int,
|
google-runtime-int,
|
||||||
google-runtime-operator,
|
google-runtime-operator,
|
||||||
|
|
||||||
hicpp-exception-baseclass,
|
hicpp-exception-baseclass,
|
||||||
|
|
||||||
clang-analyzer-core.CallAndMessage,
|
clang-analyzer-core.CallAndMessage,
|
||||||
clang-analyzer-core.DivideZero,
|
clang-analyzer-core.DivideZero,
|
||||||
clang-analyzer-core.NonNullParamChecker,
|
clang-analyzer-core.NonNullParamChecker,
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
if (USE_CLANG_TIDY)
|
||||||
|
set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
# 'clickhouse' binary is a multi purpose tool,
|
# 'clickhouse' binary is a multi purpose tool,
|
||||||
# that contain multiple execution modes (client, server, etc.)
|
# that contain multiple execution modes (client, server, etc.)
|
||||||
# each of them is built and linked as a separate library, defined below.
|
# each of them is built and linked as a separate library, defined below.
|
||||||
|
|
|
@ -24,8 +24,8 @@ namespace
|
||||||
query.table_id.table_name = table_name;
|
query.table_id.table_name = table_name;
|
||||||
query.columns = std::make_shared<ASTExpressionList>(',');
|
query.columns = std::make_shared<ASTExpressionList>(',');
|
||||||
query.children.push_back(query.columns);
|
query.children.push_back(query.columns);
|
||||||
for (size_t i = 0; i < columns.size(); ++i)
|
for (const auto & column : columns)
|
||||||
query.columns->children.emplace_back(std::make_shared<ASTIdentifier>(columns[i].name));
|
query.columns->children.emplace_back(std::make_shared<ASTIdentifier>(column.name));
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
IAST::FormatSettings settings(ss, true);
|
IAST::FormatSettings settings(ss, true);
|
||||||
|
|
|
@ -56,8 +56,8 @@ int main(int, char **)
|
||||||
MutableColumnPtr mut = IColumn::mutate(std::move(y));
|
MutableColumnPtr mut = IColumn::mutate(std::move(y));
|
||||||
mut->set(2);
|
mut->set(2);
|
||||||
|
|
||||||
std::cerr << "refcounts: " << x->use_count() << ", " << y->use_count() << ", " << mut->use_count() << "\n";
|
std::cerr << "refcounts: " << x->use_count() << ", " << mut->use_count() << "\n";
|
||||||
std::cerr << "addresses: " << x.get() << ", " << y.get() << ", " << mut.get() << "\n";
|
std::cerr << "addresses: " << x.get() << ", " << mut.get() << "\n";
|
||||||
y = std::move(mut);
|
y = std::move(mut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ int main(int, char **)
|
||||||
MutableColumnPtr mut = IColumn::mutate(std::move(y));
|
MutableColumnPtr mut = IColumn::mutate(std::move(y));
|
||||||
mut->set(3);
|
mut->set(3);
|
||||||
|
|
||||||
std::cerr << "refcounts: " << x->use_count() << ", " << y->use_count() << ", " << mut->use_count() << "\n";
|
std::cerr << "refcounts: " << x->use_count() << ", " << mut->use_count() << "\n";
|
||||||
std::cerr << "addresses: " << x.get() << ", " << y.get() << ", " << mut.get() << "\n";
|
std::cerr << "addresses: " << x.get() << ", " << mut.get() << "\n";
|
||||||
y = std::move(mut);
|
y = std::move(mut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ int main(int, char **)
|
||||||
MutableColumnPtr mut = IColumn::mutate(std::move(y));
|
MutableColumnPtr mut = IColumn::mutate(std::move(y));
|
||||||
mut->set(2);
|
mut->set(2);
|
||||||
|
|
||||||
std::cerr << "refcounts: " << x->use_count() << ", " << y->use_count() << ", " << mut->use_count() << "\n";
|
std::cerr << "refcounts: " << x->use_count() << ", " << mut->use_count() << "\n";
|
||||||
std::cerr << "addresses: " << x.get() << ", " << y.get() << ", " << mut.get() << "\n";
|
std::cerr << "addresses: " << x.get() << ", " << mut.get() << "\n";
|
||||||
y = std::move(mut);
|
y = std::move(mut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +94,8 @@ int main(int, char **)
|
||||||
MutableColumnPtr mut = IColumn::mutate(std::move(y));
|
MutableColumnPtr mut = IColumn::mutate(std::move(y));
|
||||||
mut->set(3);
|
mut->set(3);
|
||||||
|
|
||||||
std::cerr << "refcounts: " << x->use_count() << ", " << y->use_count() << ", " << mut->use_count() << "\n";
|
std::cerr << "refcounts: " << x->use_count() << ", " << mut->use_count() << "\n";
|
||||||
std::cerr << "addresses: " << x.get() << ", " << y.get() << ", " << mut.get() << "\n";
|
std::cerr << "addresses: " << x.get() << ", " << ", " << mut.get() << "\n";
|
||||||
y = std::move(mut);
|
y = std::move(mut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
if (USE_CLANG_TIDY)
|
||||||
|
set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
if(MAKE_STATIC_LIBRARIES)
|
if(MAKE_STATIC_LIBRARIES)
|
||||||
set(MAX_LINKER_MEMORY 3500)
|
set(MAX_LINKER_MEMORY 3500)
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -30,7 +30,7 @@ void run(String part_path, String date_column, String dest_path)
|
||||||
{
|
{
|
||||||
std::shared_ptr<IDisk> disk = std::make_shared<DiskLocal>("local", "/", 0);
|
std::shared_ptr<IDisk> disk = std::make_shared<DiskLocal>("local", "/", 0);
|
||||||
auto old_part_path = Poco::Path::forDirectory(part_path);
|
auto old_part_path = Poco::Path::forDirectory(part_path);
|
||||||
String old_part_name = old_part_path.directory(old_part_path.depth() - 1);
|
const String & old_part_name = old_part_path.directory(old_part_path.depth() - 1);
|
||||||
String old_part_path_str = old_part_path.toString();
|
String old_part_path_str = old_part_path.toString();
|
||||||
|
|
||||||
auto part_info = MergeTreePartInfo::fromPartName(old_part_name, MergeTreeDataFormatVersion(0));
|
auto part_info = MergeTreePartInfo::fromPartName(old_part_name, MergeTreeDataFormatVersion(0));
|
||||||
|
|
|
@ -59,9 +59,9 @@ void thread(int fd, int mode, size_t min_offset, size_t max_offset, size_t block
|
||||||
|
|
||||||
for (size_t i = 0; i < count; ++i)
|
for (size_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
long rand_result1 = rng();
|
uint64_t rand_result1 = rng();
|
||||||
long rand_result2 = rng();
|
uint64_t rand_result2 = rng();
|
||||||
long rand_result3 = rng();
|
uint64_t rand_result3 = rng();
|
||||||
|
|
||||||
size_t rand_result = rand_result1 ^ (rand_result2 << 22) ^ (rand_result3 << 43);
|
size_t rand_result = rand_result1 ^ (rand_result2 << 22) ^ (rand_result3 << 43);
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
@ -152,7 +152,7 @@ int mainImpl(int argc, char ** argv)
|
||||||
Stopwatch watch;
|
Stopwatch watch;
|
||||||
|
|
||||||
for (size_t i = 0; i < threads; ++i)
|
for (size_t i = 0; i < threads; ++i)
|
||||||
pool.scheduleOrThrowOnError(std::bind(thread, fd, mode, min_offset, max_offset, block_size, count));
|
pool.scheduleOrThrowOnError([=]{ thread(fd, mode, min_offset, max_offset, block_size, count); });
|
||||||
pool.wait();
|
pool.wait();
|
||||||
|
|
||||||
fsync(fd);
|
fsync(fd);
|
||||||
|
|
|
@ -13,6 +13,8 @@ int main(int, char **) { return 0; }
|
||||||
#include <Common/Exception.h>
|
#include <Common/Exception.h>
|
||||||
#include <Common/ThreadPool.h>
|
#include <Common/ThreadPool.h>
|
||||||
#include <Common/Stopwatch.h>
|
#include <Common/Stopwatch.h>
|
||||||
|
#include <Common/randomSeed.h>
|
||||||
|
#include <pcg_random.hpp>
|
||||||
#include <IO/BufferWithOwnMemory.h>
|
#include <IO/BufferWithOwnMemory.h>
|
||||||
#include <IO/ReadHelpers.h>
|
#include <IO/ReadHelpers.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -52,10 +54,7 @@ void thread(int fd, int mode, size_t min_offset, size_t max_offset, size_t block
|
||||||
for (size_t i = 0; i < buffers_count; ++i)
|
for (size_t i = 0; i < buffers_count; ++i)
|
||||||
buffers[i] = Memory<>(block_size, sysconf(_SC_PAGESIZE));
|
buffers[i] = Memory<>(block_size, sysconf(_SC_PAGESIZE));
|
||||||
|
|
||||||
drand48_data rand_data;
|
pcg64_fast rng(randomSeed());
|
||||||
timespec times;
|
|
||||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, ×);
|
|
||||||
srand48_r(times.tv_nsec, &rand_data);
|
|
||||||
|
|
||||||
size_t in_progress = 0;
|
size_t in_progress = 0;
|
||||||
size_t blocks_sent = 0;
|
size_t blocks_sent = 0;
|
||||||
|
@ -82,12 +81,9 @@ void thread(int fd, int mode, size_t min_offset, size_t max_offset, size_t block
|
||||||
|
|
||||||
char * buf = buffers[i].data();
|
char * buf = buffers[i].data();
|
||||||
|
|
||||||
long rand_result1 = 0;
|
uint64_t rand_result1 = rng();
|
||||||
long rand_result2 = 0;
|
uint64_t rand_result2 = rng();
|
||||||
long rand_result3 = 0;
|
uint64_t rand_result3 = rng();
|
||||||
lrand48_r(&rand_data, &rand_result1);
|
|
||||||
lrand48_r(&rand_data, &rand_result2);
|
|
||||||
lrand48_r(&rand_data, &rand_result3);
|
|
||||||
|
|
||||||
size_t rand_result = rand_result1 ^ (rand_result2 << 22) ^ (rand_result3 << 43);
|
size_t rand_result = rand_result1 ^ (rand_result2 << 22) ^ (rand_result3 << 43);
|
||||||
size_t offset = min_offset + rand_result % ((max_offset - min_offset) / block_size) * block_size;
|
size_t offset = min_offset + rand_result % ((max_offset - min_offset) / block_size) * block_size;
|
||||||
|
@ -172,7 +168,7 @@ int mainImpl(int argc, char ** argv)
|
||||||
Stopwatch watch;
|
Stopwatch watch;
|
||||||
|
|
||||||
for (size_t i = 0; i < threads_count; ++i)
|
for (size_t i = 0; i < threads_count; ++i)
|
||||||
pool.scheduleOrThrowOnError(std::bind(thread, fd, mode, min_offset, max_offset, block_size, buffers_count, count));
|
pool.scheduleOrThrowOnError([=]{ thread(fd, mode, min_offset, max_offset, block_size, buffers_count, count); });
|
||||||
pool.wait();
|
pool.wait();
|
||||||
|
|
||||||
watch.stop();
|
watch.stop();
|
||||||
|
|
|
@ -113,9 +113,9 @@ int mainImpl(int argc, char ** argv)
|
||||||
polls[i].revents = 0;
|
polls[i].revents = 0;
|
||||||
++ops;
|
++ops;
|
||||||
|
|
||||||
long rand_result1 = rng();
|
uint64_t rand_result1 = rng();
|
||||||
long rand_result2 = rng();
|
uint64_t rand_result2 = rng();
|
||||||
long rand_result3 = rng();
|
uint64_t rand_result3 = rng();
|
||||||
|
|
||||||
size_t rand_result = rand_result1 ^ (rand_result2 << 22) ^ (rand_result3 << 43);
|
size_t rand_result = rand_result1 ^ (rand_result2 << 22) ^ (rand_result3 << 43);
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# Disable clang-tidy for protobuf generated files
|
||||||
|
set (CMAKE_CXX_CLANG_TIDY "")
|
||||||
|
|
||||||
add_compile_options(-Wno-zero-as-null-pointer-constant -Wno-array-bounds) # Protobuf generated files
|
add_compile_options(-Wno-zero-as-null-pointer-constant -Wno-array-bounds) # Protobuf generated files
|
||||||
|
|
||||||
if (USE_PROTOBUF)
|
if (USE_PROTOBUF)
|
||||||
|
|
|
@ -102,7 +102,7 @@ std::unordered_map<std::string, Int64> getPartitionsNeedAdjustingBlockNumbers(
|
||||||
std::cout << "Shard: " << shard << std::endl;
|
std::cout << "Shard: " << shard << std::endl;
|
||||||
std::vector<std::string> use_tables = tables.empty() ? getAllTables(zk, root, shard) : removeNotExistingTables(zk, root, shard, tables);
|
std::vector<std::string> use_tables = tables.empty() ? getAllTables(zk, root, shard) : removeNotExistingTables(zk, root, shard, tables);
|
||||||
|
|
||||||
for (auto table : use_tables)
|
for (const auto & table : use_tables)
|
||||||
{
|
{
|
||||||
std::cout << "\tTable: " << table << std::endl;
|
std::cout << "\tTable: " << table << std::endl;
|
||||||
std::string table_path = root + "/" + shard + "/" + table;
|
std::string table_path = root + "/" + shard + "/" + table;
|
||||||
|
@ -121,7 +121,7 @@ std::unordered_map<std::string, Int64> getPartitionsNeedAdjustingBlockNumbers(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto partition : partitions)
|
for (const auto & partition : partitions)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,10 +97,8 @@ int main(int argc, char ** argv)
|
||||||
bool watch = w == "w";
|
bool watch = w == "w";
|
||||||
zkutil::EventPtr event = watch ? std::make_shared<Poco::Event>() : nullptr;
|
zkutil::EventPtr event = watch ? std::make_shared<Poco::Event>() : nullptr;
|
||||||
std::vector<std::string> v = zk.getChildren(path, nullptr, event);
|
std::vector<std::string> v = zk.getChildren(path, nullptr, event);
|
||||||
for (size_t i = 0; i < v.size(); ++i)
|
for (const auto & child : v)
|
||||||
{
|
std::cout << child << std::endl;
|
||||||
std::cout << v[i] << std::endl;
|
|
||||||
}
|
|
||||||
if (watch)
|
if (watch)
|
||||||
waitForWatch(event);
|
waitForWatch(event);
|
||||||
}
|
}
|
||||||
|
@ -193,7 +191,7 @@ int main(int argc, char ** argv)
|
||||||
zk.set(path, data, version, &stat);
|
zk.set(path, data, version, &stat);
|
||||||
printStat(stat);
|
printStat(stat);
|
||||||
}
|
}
|
||||||
else if (cmd != "")
|
else if (!cmd.empty())
|
||||||
{
|
{
|
||||||
std::cout << "commands:\n";
|
std::cout << "commands:\n";
|
||||||
std::cout << " q\n";
|
std::cout << " q\n";
|
||||||
|
|
Loading…
Reference in New Issue