Skip to content

Commit

Permalink
Merge pull request #3333 from alexreinking/add-overrides
Browse files Browse the repository at this point in the history
Add `override` keyword to compile with `-Wsuggest-override`
  • Loading branch information
steven-johnson committed Oct 11, 2018
2 parents e173bff + f0cae9a commit 814a383
Show file tree
Hide file tree
Showing 94 changed files with 981 additions and 954 deletions.
13 changes: 8 additions & 5 deletions CMakeLists.txt
Expand Up @@ -206,11 +206,14 @@ else()
endif()

if (NOT MSVC)
add_compile_options(-Wall
-Wno-unused-function
-Wcast-qual
-Woverloaded-virtual
-Wignored-qualifiers)
add_compile_options(-Wall
-Wno-unused-function
-Wcast-qual
-Woverloaded-virtual
-Wignored-qualifiers)
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.1)
add_compile_options(-Wsuggest-override)
endif()
if (WARNINGS_AS_ERRORS)
add_compile_options(-Werror)
endif()
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Expand Up @@ -160,7 +160,15 @@ LLVM_HAS_NO_RTTI = $(findstring -fno-rtti, $(LLVM_CXX_FLAGS))
WITH_RTTI ?= $(if $(LLVM_HAS_NO_RTTI),, not-empty)
RTTI_CXX_FLAGS=$(if $(WITH_RTTI), , -fno-rtti )

CXX_VERSION = $(shell $(CXX) --version | head -n1)
CXX_WARNING_FLAGS = -Wall -Werror -Wno-unused-function -Wcast-qual -Wignored-qualifiers -Wno-comment -Wsign-compare -Wno-unknown-warning-option -Wno-psabi
ifneq (,$(findstring g++,$(CXX_VERSION)))
GCC_MAJOR_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion | cut -f1 -d.)
GCC_MINOR_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion | cut -f2 -d.)
ifeq (1,$(shell expr $(GCC_MAJOR_VERSION) \> 5 \| $(GCC_MAJOR_VERSION) = 5 \& $(GCC_MINOR_VERSION) \>= 1))
CXX_WARNING_FLAGS += -Wsuggest-override
endif
endif
CXX_FLAGS = $(CXX_WARNING_FLAGS) $(RTTI_CXX_FLAGS) -Woverloaded-virtual $(FPIC) $(OPTIMIZE) -fno-omit-frame-pointer -DCOMPILING_HALIDE

CXX_FLAGS += $(LLVM_CXX_FLAGS)
Expand Down Expand Up @@ -207,7 +215,6 @@ TEST_CXX_FLAGS ?= $(TUTORIAL_CXX_FLAGS) $(CXX_WARNING_FLAGS) -march=native
TEST_LD_FLAGS = -L$(BIN_DIR) -lHalide $(COMMON_LD_FLAGS)

# gcc 4.8 fires a bogus warning on old versions of png.h
CXX_VERSION = $(shell $(CXX) --version | head -n1)
ifneq (,$(findstring g++,$(CXX_VERSION)))
ifneq (,$(findstring 4.8,$(CXX_VERSION)))
TEST_CXX_FLAGS += -Wno-literal-suffix
Expand Down
17 changes: 16 additions & 1 deletion apps/linear_algebra/benchmarks/eigen_benchmarks.cpp
Expand Up @@ -26,8 +26,23 @@ std::string type_name<float>() {return "s";}
template<>
std::string type_name<double>() {return "d";}

struct BenchmarksBase {
virtual void bench_copy(int N) = 0;
virtual void bench_scal(int N) = 0;
virtual void bench_axpy(int N) = 0;
virtual void bench_dot(int N) = 0;
virtual void bench_asum(int N) = 0;
virtual void bench_gemv_notrans(int N) = 0;
virtual void bench_gemv_trans(int N) = 0;
virtual void bench_ger(int N) = 0;
virtual void bench_gemm_notrans(int N) = 0;
virtual void bench_gemm_transA(int N) = 0;
virtual void bench_gemm_transB(int N) = 0;
virtual void bench_gemm_transAB(int N) = 0;
};

template<class T>
struct Benchmarks {
struct Benchmarks : BenchmarksBase {
typedef T Scalar;
typedef Eigen::Matrix<T, Eigen::Dynamic, 1> Vector;
typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> Matrix;
Expand Down
6 changes: 3 additions & 3 deletions apps/linear_algebra/benchmarks/macros.h
Expand Up @@ -28,7 +28,7 @@ inline void set_math_flags() {

#define L1GFLOPS(N) 2.0 * N * 1e-3 / elapsed
#define L1Benchmark(benchmark, type, code) \
virtual void bench_##benchmark(int N) { \
virtual void bench_##benchmark(int N) override { \
Scalar alpha = random_scalar(); \
(void) alpha; \
Vector x(random_vector(N)); \
Expand All @@ -46,7 +46,7 @@ inline void set_math_flags() {

#define L2GFLOPS(N) (2.0 + N) * N * 1e-3 / elapsed
#define L2Benchmark(benchmark, type, code) \
virtual void bench_##benchmark(int N) { \
virtual void bench_##benchmark(int N) override { \
Scalar alpha = random_scalar(); \
Scalar beta = random_scalar(); \
(void) alpha; \
Expand All @@ -67,7 +67,7 @@ inline void set_math_flags() {

#define L3GFLOPS(N) (3.0 + N) * N * N * 1e-3 / elapsed
#define L3Benchmark(benchmark, type, code) \
virtual void bench_##benchmark(int N) { \
virtual void bench_##benchmark(int N) override { \
Scalar alpha = random_scalar(); \
Scalar beta = random_scalar(); \
Matrix A(random_matrix(N)); \
Expand Down
8 changes: 4 additions & 4 deletions src/AddImageChecks.cpp
Expand Up @@ -29,7 +29,7 @@ class FindBuffers : public IRGraphVisitor {

using IRGraphVisitor::visit;

void visit(const For *op) {
void visit(const For *op) override {
op->min.accept(this);
op->extent.accept(this);
bool old = in_device_loop;
Expand All @@ -41,7 +41,7 @@ class FindBuffers : public IRGraphVisitor {
in_device_loop = old;
}

void visit(const Call *op) {
void visit(const Call *op) override {
IRGraphVisitor::visit(op);
if (op->image.defined()) {
Result &r = buffers[op->name];
Expand All @@ -58,7 +58,7 @@ class FindBuffers : public IRGraphVisitor {
}
}

void visit(const Provide *op) {
void visit(const Provide *op) override {
IRGraphVisitor::visit(op);
if (op->values.size() == 1) {
auto it = buffers.find(op->name);
Expand All @@ -76,7 +76,7 @@ class FindBuffers : public IRGraphVisitor {
}
}

void visit(const Variable *op) {
void visit(const Variable *op) override {
if (op->param.defined() &&
op->param.is_buffer() &&
buffers.find(op->param.name()) == buffers.end()) {
Expand Down
2 changes: 1 addition & 1 deletion src/AddParameterChecks.cpp
Expand Up @@ -19,7 +19,7 @@ class FindParameters : public IRGraphVisitor {

using IRGraphVisitor::visit;

void visit(const Variable *op) {
void visit(const Variable *op) override {
if (op->param.defined()) {
params[op->name] = op->param;
}
Expand Down

0 comments on commit 814a383

Please sign in to comment.