From 91346398770a93f23037f4dec9cf1e5273bb0634 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 20 Sep 2018 16:54:35 -0700 Subject: [PATCH] Warn on non-virtual destructor if class has virtual functions --- Makefile | 1 + build.yaml | 1 + test/cpp/microbenchmarks/fullstack_fixtures.h | 1 + test/cpp/microbenchmarks/helpers.h | 1 + 4 files changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 82454a54d88..65ff9972bf8 100644 --- a/Makefile +++ b/Makefile @@ -352,6 +352,7 @@ CXXFLAGS += -std=c++11 ifeq ($(SYSTEM),Darwin) CXXFLAGS += -stdlib=libc++ endif +CXXFLAGS += -Wnon-virtual-dtor CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1 -Wno-deprecated-declarations -Ithird_party/nanopb -DPB_FIELD_32BIT COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g diff --git a/build.yaml b/build.yaml index 98e315711ca..60600b7dcec 100644 --- a/build.yaml +++ b/build.yaml @@ -5860,6 +5860,7 @@ defaults: COREFLAGS: -fno-rtti -fno-exceptions CPPFLAGS: -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSATOMIC_USE_INLINED=1 -Wno-deprecated-declarations -Ithird_party/nanopb -DPB_FIELD_32BIT + CXXFLAGS: -Wnon-virtual-dtor LDFLAGS: -g zlib: CFLAGS: -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-implicit-function-declaration diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index 9d70277fbcd..d390ae08f61 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -48,6 +48,7 @@ namespace testing { class FixtureConfiguration { public: + virtual ~FixtureConfiguration() {} virtual void ApplyCommonChannelArguments(ChannelArguments* c) const { c->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX); c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX); diff --git a/test/cpp/microbenchmarks/helpers.h b/test/cpp/microbenchmarks/helpers.h index 4aabd4094a8..25d34b5f871 100644 --- a/test/cpp/microbenchmarks/helpers.h +++ b/test/cpp/microbenchmarks/helpers.h @@ -63,6 +63,7 @@ extern gpr_atm gpr_now_call_count; class TrackCounters { public: TrackCounters() { grpc_stats_collect(&stats_begin_); } + virtual ~TrackCounters() {} virtual void Finish(benchmark::State& state); virtual void AddLabel(const grpc::string& label); virtual void AddToLabel(std::ostream& out, benchmark::State& state);