Skip to content

Commit

Permalink
[Chore](build) enable -Wpedantic and update lowest gcc version to 11.1 (
Browse files Browse the repository at this point in the history
apache#16290)

enable -Wpedantic and update lowest gcc version to 11.1
  • Loading branch information
BiteTheDDDDt authored Feb 3, 2023
1 parent 7d5a10e commit 5e4bb98
Show file tree
Hide file tree
Showing 121 changed files with 246 additions and 321 deletions.
5 changes: 5 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@
Diagnostics:
UnusedIncludes: Strict

If:
PathMatch: be/test/.*

CompileFlags:
CompilationDatabase: be/ut_build_ASAN/
31 changes: 14 additions & 17 deletions be/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ endif ()
# Set boost/stacktrace use backtrace api to unwind
if (NOT OS_MACOSX)
add_definitions(-DBOOST_STACKTRACE_USE_BACKTRACE)
#add_definitions(-DPRINT_ALL_ERR_STATUS_STACKTRACE)
else()
add_definitions(-DBOOST_STACKTRACE_USE_NOOP)
endif()
Expand Down Expand Up @@ -118,8 +117,8 @@ option(WITH_MYSQL "Support access MySQL" ON)

# Check gcc
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.0")
message(FATAL_ERROR "Need GCC version at least 11.0")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.1")
message(FATAL_ERROR "Need GCC version at least 11.1")
endif()
endif()

Expand Down Expand Up @@ -490,27 +489,25 @@ if (NOT CUSTUM_LINKER_COMMAND STREQUAL "ld")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=${CUSTUM_LINKER_COMMAND}")
endif()

if (USE_LIBCPP AND COMPILER_CLANG)
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -stdlib=libc++")
if (NOT OS_MACOSX)
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -lstdc++")
endif()
add_definitions(-DUSE_LIBCPP)
endif()

if (COMPILER_GCC)
# Avoid GCC 11 false alarm
# https://stackoverflow.com/questions/67584073/gcc-11-false-array-subscript-is-partly-outside-array-bounds-warning
# https://stackoverflow.com/questions/69426070/gcc-11-order-of-arguments-triggers-false-positive-wstringop-overflow-is-this-bu
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-array-bounds -Wno-stringop-overread")
add_compile_options(-Wno-stringop-overflow -fdiagnostics-color=always)
add_compile_options(-fdiagnostics-color=always -Wno-array-bounds -Wno-stringop-overread)
endif ()

if (COMPILER_CLANG)
add_compile_options(-fcolor-diagnostics -fno-limit-debug-info)
add_compile_options(-fcolor-diagnostics -fno-limit-debug-info -Wpedantic)
add_compile_options(-Wno-zero-length-array -Wno-variadic-macros -Wno-gnu-zero-variadic-macro-arguments -Wno-vla-extension -Wno-c++20-designator -Wno-gnu-label-as-value -Wno-embedded-directive -Wno-array-bounds)
if(MAKE_TEST STREQUAL "OFF")
add_compile_options(-Qunused-arguments)
endif()
if (USE_LIBCPP)
add_compile_options(-stdlib=libc++)
if (NOT OS_MACOSX)
add_compile_options(-lstdc++)
endif()
add_definitions(-DUSE_LIBCPP)
else()
add_compile_options(-Wno-c++20-attribute-extensions)
endif()
endif ()

# https://github.com/boostorg/uuid/issues/92
Expand Down
6 changes: 3 additions & 3 deletions be/src/agent/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace doris {
class MasterServerClient {
public:
MasterServerClient(const TMasterInfo& master_info, FrontendServiceClientCache* client_cache);
virtual ~MasterServerClient() {};
virtual ~MasterServerClient() = default;

// Report finished task to the master server
//
Expand Down Expand Up @@ -59,8 +59,8 @@ class MasterServerClient {

class AgentUtils {
public:
AgentUtils() {};
virtual ~AgentUtils() {};
AgentUtils() = default;
virtual ~AgentUtils() = default;

// Execute shell cmd
virtual bool exec_cmd(const std::string& command, std::string* errmsg,
Expand Down
2 changes: 1 addition & 1 deletion be/src/common/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class TaggableLogger {
} else {
_stream << fmt::format(fmt, std::forward<Args>(args)...);
}
};
}

template <typename V>
TaggableLogger& tag(std::string_view key, const V& value) {
Expand Down
2 changes: 1 addition & 1 deletion be/src/common/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ E(INVERTED_INDEX_CLUCENE_ERROR, -6002);
E(INVERTED_INDEX_FILE_NOT_FOUND, -6003);
E(INVERTED_INDEX_FILE_HIT_LIMIT, -6004);
#undef E
}; // namespace ErrorCode
} // namespace ErrorCode

// clang-format off
// whether to capture stacktrace
Expand Down
2 changes: 1 addition & 1 deletion be/src/exec/data_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DataSink {
// Send a Block into this sink.
virtual Status send(RuntimeState* state, vectorized::Block* block, bool eos = false) {
return Status::NotSupported("Not support send block");
};
}
// Releases all resources that were allocated in prepare()/send().
// Further send() calls are illegal after calling close().
// It must be okay to call this multiple times. Subsequent calls should
Expand Down
2 changes: 1 addition & 1 deletion be/src/exec/olap_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class ColumnValueRange {
set_whole_value_range();
}
_contain_null = contain_null;
};
}

int precision() const { return _precision; }

Expand Down
2 changes: 1 addition & 1 deletion be/src/exec/tablet_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct VOlapTablePartition {
std::vector<OlapTableIndexTablets> indexes;

VOlapTablePartition(vectorized::Block* partition_block)
: start_key {partition_block, -1}, end_key {partition_block, -1} {};
: start_key {partition_block, -1}, end_key {partition_block, -1} {}
};

class VOlapTablePartKeyComparator {
Expand Down
2 changes: 1 addition & 1 deletion be/src/exprs/bitmapfilter_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BitmapFilterFuncBase {
virtual void insert_many(const std::vector<const BitmapValue*> bitmaps) = 0;
virtual bool empty() = 0;
virtual Status assign(BitmapValue* bitmap_value) = 0;
virtual void light_copy(BitmapFilterFuncBase* other) { _not_in = other->_not_in; };
virtual void light_copy(BitmapFilterFuncBase* other) { _not_in = other->_not_in; }
virtual uint16_t find_fixed_len_olap_engine(const char* data, const uint8* nullmap,
uint16_t* offsets, int number) = 0;
virtual void find_batch(const char* data, const uint8* nullmap, int number,
Expand Down
8 changes: 4 additions & 4 deletions be/src/exprs/create_predicate_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MinmaxFunctionTraits {
template <PrimitiveType type>
static BasePtr get_function() {
return new MinMaxNumFunc<typename PrimitiveTypeTraits<type>::CppType>();
};
}
};

class HybridSetTraits {
Expand All @@ -45,7 +45,7 @@ class HybridSetTraits {
using Set =
std::conditional_t<std::is_same_v<CppType, StringRef>, StringSet, HybridSet<type>>;
return new Set();
};
}
};

class BloomFilterTraits {
Expand All @@ -54,7 +54,7 @@ class BloomFilterTraits {
template <PrimitiveType type>
static BasePtr get_function() {
return new BloomFilterFunc<type>();
};
}
};

class BitmapFilterTraits {
Expand All @@ -63,7 +63,7 @@ class BitmapFilterTraits {
template <PrimitiveType type>
static BasePtr get_function() {
return new BitmapFilterFunc<type>();
};
}
};

template <class Traits>
Expand Down
2 changes: 1 addition & 1 deletion be/src/geo/geo_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class GeoShape {
virtual std::string as_wkt() const = 0;

virtual bool contains(const GeoShape* rhs) const { return false; }
virtual std::string to_string() const { return ""; };
virtual std::string to_string() const { return ""; }

protected:
virtual void encode(std::string* buf) = 0;
Expand Down
4 changes: 2 additions & 2 deletions be/src/glibc-compatibility/glibc-compatibility.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int __open_2(const char *path, int oflag)

/// No-ops.
int pthread_setname_np(pthread_t thread, const char *name) { return 0; }
int pthread_getname_np(pthread_t thread, char *name, size_t len) { name[0] = '\0'; return 0; };
int pthread_getname_np(pthread_t thread, char *name, size_t len) { name[0] = '\0'; return 0; }


#define SHMDIR "/dev/shm/"
Expand Down Expand Up @@ -172,7 +172,7 @@ void __attribute__((__weak__)) explicit_bzero(void * buf, size_t len)

void __explicit_bzero_chk(void * buf, size_t len, size_t unused)
{
return explicit_bzero(buf, len);
explicit_bzero(buf, len);
}


Expand Down
2 changes: 1 addition & 1 deletion be/src/glibc-compatibility/musl/sync_file_range.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ int sync_file_range(int fd, off_t pos, off_t len, unsigned flags)
#else
return __syscall_ret(-ENOSYS);
#endif
}
}
6 changes: 3 additions & 3 deletions be/src/glibc-compatibility/musl/x86_64/atomic_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ static inline void a_store(volatile int *p, int x)
}

#define a_barrier a_barrier
static inline void a_barrier()
static inline void a_barrier(void)
{
__asm__ __volatile__( "" : : : "memory" );
}

#define a_spin a_spin
static inline void a_spin()
static inline void a_spin(void)
{
__asm__ __volatile__( "pause" : : : "memory" );
}

#define a_crash a_crash
static inline void a_crash()
static inline void a_crash(void)
{
__asm__ __volatile__( "hlt" : : : "memory" );
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/http/action/health_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HealthAction : public HttpHandler {
public:
HealthAction();

virtual ~HealthAction() {};
~HealthAction() override = default;

void handle(HttpRequest* req) override;
};
Expand Down
2 changes: 1 addition & 1 deletion be/src/http/action/stream_load_2pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StreamLoad2PCAction : public HttpHandler {
public:
StreamLoad2PCAction(ExecEnv* exec_env);

virtual ~StreamLoad2PCAction() {};
~StreamLoad2PCAction() override = default;

void handle(HttpRequest* req) override;
std::string get_success_info(const std::string txn_id, const std::string txn_operation);
Expand Down
2 changes: 1 addition & 1 deletion be/src/http/action/version_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class VersionAction : public HttpHandler {
public:
VersionAction();

virtual ~VersionAction() {};
~VersionAction() override = default;

void handle(HttpRequest* req) override;
};
Expand Down
6 changes: 2 additions & 4 deletions be/src/io/cache/block/block_file_cache_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include <memory>

#include "http/http_common.h"

namespace doris {
namespace io {

Expand Down Expand Up @@ -106,10 +104,10 @@ void FileCacheProfile::update(int64_t table_id, int64_t partition_id, OlapReader
}
count = _profile[table_id][partition_id];
}
if (partition_metric) [[unlikely]] {
if (partition_metric) {
partition_metric->register_entity();
}
if (table_metric) [[unlikely]] {
if (table_metric) {
table_metric->register_entity();
}
count->num_io_total.fetch_add(stats->file_cache_stats.num_io_total, std::memory_order_relaxed);
Expand Down
2 changes: 1 addition & 1 deletion be/src/io/cache/dummy_file_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DummyFileCache final : public FileCache {

int64_t get_oldest_match_time() const override {
return _gc_lru_queue.empty() ? 0 : _gc_lru_queue.top().last_match_time;
};
}

bool is_gc_finish() const override { return _gc_lru_queue.empty(); }

Expand Down
2 changes: 1 addition & 1 deletion be/src/io/cache/file_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class FileCache : public FileReader {
struct SubFileLRUComparator {
bool operator()(const T& lhs, const T& rhs) const {
return lhs.last_match_time > rhs.last_match_time;
};
}
};

size_t _cache_file_size;
Expand Down
2 changes: 1 addition & 1 deletion be/src/io/cache/sub_file_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SubFileCache final : public FileCache {

int64_t get_oldest_match_time() const override {
return _gc_lru_queue.empty() ? 0 : _gc_lru_queue.top().last_match_time;
};
}

bool is_gc_finish() const override { return _gc_lru_queue.empty(); }

Expand Down
2 changes: 1 addition & 1 deletion be/src/io/fs/s3_file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class S3FileSystem final : public RemoteFileSystem {
std::shared_ptr<Aws::S3::S3Client> get_client() const {
std::lock_guard lock(_client_mu);
return _client;
};
}

// Guarded by external lock.
void set_conf(S3Conf s3_conf) { _s3_conf = std::move(s3_conf); }
Expand Down
8 changes: 4 additions & 4 deletions be/src/io/hdfs_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class HDFSCommonBuilder {
const std::map<std::string, std::string>& properties);

public:
HDFSCommonBuilder() : hdfs_builder(hdfsNewBuilder()) {};
~HDFSCommonBuilder() { hdfsFreeBuilder(hdfs_builder); };
HDFSCommonBuilder() : hdfs_builder(hdfsNewBuilder()) {}
~HDFSCommonBuilder() { hdfsFreeBuilder(hdfs_builder); }

hdfsBuilder* get() { return hdfs_builder; };
bool is_need_kinit() { return need_kinit; };
hdfsBuilder* get() { return hdfs_builder; }
bool is_need_kinit() const { return need_kinit; }
Status run_kinit();

private:
Expand Down
18 changes: 9 additions & 9 deletions be/src/olap/block_column_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,32 @@ class BlockColumnPredicate {
return selected_size;
}
virtual void evaluate_and(vectorized::MutableColumns& block, uint16_t* sel,
uint16_t selected_size, bool* flags) const {};
uint16_t selected_size, bool* flags) const {}
virtual void evaluate_or(vectorized::MutableColumns& block, uint16_t* sel,
uint16_t selected_size, bool* flags) const {};
uint16_t selected_size, bool* flags) const {}

virtual void evaluate_vec(vectorized::MutableColumns& block, uint16_t size,
bool* flags) const {};
virtual void evaluate_vec(vectorized::MutableColumns& block, uint16_t size, bool* flags) const {
}

virtual bool evaluate_and(const std::pair<WrapperField*, WrapperField*>& statistic) const {
LOG(FATAL) << "should not reach here";
return true;
};
}

virtual bool evaluate_and(const segment_v2::BloomFilter* bf) const {
LOG(FATAL) << "should not reach here";
return true;
};
}
virtual bool can_do_bloom_filter() const { return false; }
};

class SingleColumnBlockPredicate : public BlockColumnPredicate {
public:
explicit SingleColumnBlockPredicate(const ColumnPredicate* pre) : _predicate(pre) {};
explicit SingleColumnBlockPredicate(const ColumnPredicate* pre) : _predicate(pre) {}

void get_all_column_ids(std::set<ColumnId>& column_id_set) const override {
column_id_set.insert(_predicate->column_id());
};
}

void get_all_column_predicate(std::set<const ColumnPredicate*>& predicate_set) const override {
predicate_set.insert(_predicate);
Expand Down Expand Up @@ -115,7 +115,7 @@ class MutilColumnBlockPredicate : public BlockColumnPredicate {
for (auto child_block_predicate : _block_column_predicate_vec) {
child_block_predicate->get_all_column_ids(column_id_set);
}
};
}

void get_all_column_predicate(std::set<const ColumnPredicate*>& predicate_set) const override {
for (auto child_block_predicate : _block_column_predicate_vec) {
Expand Down
Loading

0 comments on commit 5e4bb98

Please sign in to comment.