summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--absl/copts/GENERATED_AbseilCopts.cmake2
-rw-r--r--absl/copts/GENERATED_copts.bzl2
-rw-r--r--absl/copts/copts.py1
-rw-r--r--absl/flags/commandlineflag.h11
-rw-r--r--absl/flags/internal/flag.h13
-rw-r--r--absl/flags/reflection.cc10
6 files changed, 37 insertions, 2 deletions
diff --git a/absl/copts/GENERATED_AbseilCopts.cmake b/absl/copts/GENERATED_AbseilCopts.cmake
index f90bff79..0079a719 100644
--- a/absl/copts/GENERATED_AbseilCopts.cmake
+++ b/absl/copts/GENERATED_AbseilCopts.cmake
@@ -44,6 +44,7 @@ list(APPEND ABSL_GCC_FLAGS
"-Wconversion-null"
"-Wformat-security"
"-Wmissing-declarations"
+ "-Wnon-virtual-dtor"
"-Woverlength-strings"
"-Wpointer-arith"
"-Wundef"
@@ -61,6 +62,7 @@ list(APPEND ABSL_GCC_TEST_FLAGS
"-Wcast-qual"
"-Wconversion-null"
"-Wformat-security"
+ "-Wnon-virtual-dtor"
"-Woverlength-strings"
"-Wpointer-arith"
"-Wundef"
diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl
index 3a659529..d9a9b375 100644
--- a/absl/copts/GENERATED_copts.bzl
+++ b/absl/copts/GENERATED_copts.bzl
@@ -45,6 +45,7 @@ ABSL_GCC_FLAGS = [
"-Wconversion-null",
"-Wformat-security",
"-Wmissing-declarations",
+ "-Wnon-virtual-dtor",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wundef",
@@ -62,6 +63,7 @@ ABSL_GCC_TEST_FLAGS = [
"-Wcast-qual",
"-Wconversion-null",
"-Wformat-security",
+ "-Wnon-virtual-dtor",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wundef",
diff --git a/absl/copts/copts.py b/absl/copts/copts.py
index 946ceb86..1170d005 100644
--- a/absl/copts/copts.py
+++ b/absl/copts/copts.py
@@ -18,6 +18,7 @@ ABSL_GCC_FLAGS = [
"-Wconversion-null",
"-Wformat-security",
"-Wmissing-declarations",
+ "-Wnon-virtual-dtor",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wundef",
diff --git a/absl/flags/commandlineflag.h b/absl/flags/commandlineflag.h
index c30aa609..26ec0e7d 100644
--- a/absl/flags/commandlineflag.h
+++ b/absl/flags/commandlineflag.h
@@ -59,6 +59,14 @@ class PrivateHandleAccessor;
// // Now you can get flag info from that reflection handle.
// std::string flag_location = my_flag_data->Filename();
// ...
+
+// These are only used as constexpr global objects.
+// They do not use a virtual destructor to simplify their implementation.
+// They are not destroyed except at program exit, so leaks do not matter.
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+#endif
class CommandLineFlag {
public:
constexpr CommandLineFlag() = default;
@@ -193,6 +201,9 @@ class CommandLineFlag {
// flag's value type.
virtual void CheckDefaultValueParsingRoundtrip() const = 0;
};
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/flags/internal/flag.h b/absl/flags/internal/flag.h
index 7b056382..602531b1 100644
--- a/absl/flags/internal/flag.h
+++ b/absl/flags/internal/flag.h
@@ -424,6 +424,13 @@ struct DynValueDeleter {
class FlagState;
+// These are only used as constexpr global objects.
+// They do not use a virtual destructor to simplify their implementation.
+// They are not destroyed except at program exit, so leaks do not matter.
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+#endif
class FlagImpl final : public CommandLineFlag {
public:
constexpr FlagImpl(const char* name, const char* filename, FlagOpFn op,
@@ -623,6 +630,9 @@ class FlagImpl final : public CommandLineFlag {
// problems.
alignas(absl::Mutex) mutable char data_guard_[sizeof(absl::Mutex)];
};
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
///////////////////////////////////////////////////////////////////////////////
// The Flag object parameterized by the flag's value type. This class implements
@@ -753,8 +763,7 @@ void* FlagOps(FlagOp op, const void* v1, void* v2, void* v3) {
// Round sizeof(FlagImp) to a multiple of alignof(FlagValue<T>) to get the
// offset of the data.
size_t round_to = alignof(FlagValue<T>);
- size_t offset =
- (sizeof(FlagImpl) + round_to - 1) / round_to * round_to;
+ size_t offset = (sizeof(FlagImpl) + round_to - 1) / round_to * round_to;
return reinterpret_cast<void*>(offset);
}
}
diff --git a/absl/flags/reflection.cc b/absl/flags/reflection.cc
index 841921a9..ea856ff9 100644
--- a/absl/flags/reflection.cc
+++ b/absl/flags/reflection.cc
@@ -217,6 +217,13 @@ void FinalizeRegistry() {
namespace {
+// These are only used as constexpr global objects.
+// They do not use a virtual destructor to simplify their implementation.
+// They are not destroyed except at program exit, so leaks do not matter.
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
+#endif
class RetiredFlagObj final : public CommandLineFlag {
public:
constexpr RetiredFlagObj(const char* name, FlagFastTypeId type_id)
@@ -276,6 +283,9 @@ class RetiredFlagObj final : public CommandLineFlag {
const char* const name_;
const FlagFastTypeId type_id_;
};
+#if defined(__GNUC__) && !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
} // namespace