Automated rollback of commit 9f40d6d6f3cfc1fb0325dd8637eb65f8299a4b00.
PiperOrigin-RevId: 838084272
Change-Id: I8b1b15618e12cc17d85a71b7f5062b66ceaaf04f
diff --git a/absl/base/config.h b/absl/base/config.h
index a38c582..e4518ca 100644
--- a/absl/base/config.h
+++ b/absl/base/config.h
@@ -755,7 +755,7 @@
#ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE
#error ABSL_INTERNAL_HAS_CXA_DEMANGLE cannot be directly set
#elif defined(OS_ANDROID) && (defined(__i386__) || defined(__x86_64__))
-#define ABSL_INTERNAL_HAS_CXA_DEMANGLE 0
+#undef ABSL_INTERNAL_HAS_CXA_DEMANGLE
#elif defined(__GNUC__)
#define ABSL_INTERNAL_HAS_CXA_DEMANGLE 1
#elif defined(__clang__) && !defined(_MSC_VER)
diff --git a/absl/container/btree_test.cc b/absl/container/btree_test.cc
index 1d2c2a6..a6438f5 100644
--- a/absl/container/btree_test.cc
+++ b/absl/container/btree_test.cc
@@ -2048,7 +2048,10 @@
TEST(Btree, ExtractDoesntCauseExtraMoves) {
#ifdef _MSC_VER
- GTEST_SKIP() << "This test fails on MSVC.";
+ // This conditional is to avoid an unreachable code warning.
+ if (_MSC_VER > 0) {
+ GTEST_SKIP() << "This test fails on MSVC.";
+ }
#endif
using Set = absl::btree_set<MovableOnlyInstance>;
diff --git a/absl/copts/GENERATED_AbseilCopts.cmake b/absl/copts/GENERATED_AbseilCopts.cmake
index 32b97fc..b08c34c 100644
--- a/absl/copts/GENERATED_AbseilCopts.cmake
+++ b/absl/copts/GENERATED_AbseilCopts.cmake
@@ -10,6 +10,46 @@
"/D_CRT_SECURE_NO_WARNINGS"
"/D_SCL_SECURE_NO_WARNINGS"
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE"
+ "-Wmost"
+ "-Wextra"
+ "-Wc++98-compat-extra-semi"
+ "-Wcast-qual"
+ "-Wconversion"
+ "-Wdeprecated-pragma"
+ "-Wfloat-overflow-conversion"
+ "-Wfloat-zero-conversion"
+ "-Wfor-loop-analysis"
+ "-Wformat-security"
+ "-Wgnu-redeclared-enum"
+ "-Winfinite-recursion"
+ "-Winvalid-constexpr"
+ "-Wliteral-conversion"
+ "-Wmissing-declarations"
+ "-Wnullability-completeness"
+ "-Woverlength-strings"
+ "-Wpointer-arith"
+ "-Wself-assign"
+ "-Wshadow-all"
+ "-Wshorten-64-to-32"
+ "-Wsign-conversion"
+ "-Wstring-conversion"
+ "-Wtautological-overlap-compare"
+ "-Wtautological-unsigned-zero-compare"
+ "-Wthread-safety"
+ "-Wundef"
+ "-Wuninitialized"
+ "-Wunreachable-code"
+ "-Wunused-comparison"
+ "-Wunused-local-typedefs"
+ "-Wunused-result"
+ "-Wvla"
+ "-Wwrite-strings"
+ "-Wno-float-conversion"
+ "-Wno-implicit-float-conversion"
+ "-Wno-implicit-int-float-conversion"
+ "-Wno-unknown-warning-option"
+ "-Wno-unused-command-line-argument"
+ "-DNOMINMAX"
)
list(APPEND ABSL_CLANG_CL_TEST_FLAGS
@@ -19,6 +59,43 @@
"/D_CRT_SECURE_NO_WARNINGS"
"/D_SCL_SECURE_NO_WARNINGS"
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE"
+ "-Wmost"
+ "-Wextra"
+ "-Wc++98-compat-extra-semi"
+ "-Wcast-qual"
+ "-Wconversion"
+ "-Wdeprecated-pragma"
+ "-Wfloat-overflow-conversion"
+ "-Wfloat-zero-conversion"
+ "-Wfor-loop-analysis"
+ "-Wformat-security"
+ "-Wgnu-redeclared-enum"
+ "-Winfinite-recursion"
+ "-Winvalid-constexpr"
+ "-Wliteral-conversion"
+ "-Wmissing-declarations"
+ "-Woverlength-strings"
+ "-Wpointer-arith"
+ "-Wself-assign"
+ "-Wshadow-all"
+ "-Wstring-conversion"
+ "-Wtautological-overlap-compare"
+ "-Wtautological-unsigned-zero-compare"
+ "-Wthread-safety"
+ "-Wundef"
+ "-Wuninitialized"
+ "-Wunreachable-code"
+ "-Wunused-comparison"
+ "-Wunused-local-typedefs"
+ "-Wunused-result"
+ "-Wvla"
+ "-Wwrite-strings"
+ "-Wno-float-conversion"
+ "-Wno-implicit-float-conversion"
+ "-Wno-implicit-int-float-conversion"
+ "-Wno-unknown-warning-option"
+ "-Wno-unused-command-line-argument"
+ "-DNOMINMAX"
"-Wno-deprecated-declarations"
"-Wno-implicit-int-conversion"
"-Wno-missing-prototypes"
@@ -84,6 +161,7 @@
list(APPEND ABSL_LLVM_FLAGS
"-Wall"
+ "-Wmost"
"-Wextra"
"-Wc++98-compat-extra-semi"
"-Wcast-qual"
@@ -127,6 +205,7 @@
list(APPEND ABSL_LLVM_TEST_FLAGS
"-Wall"
+ "-Wmost"
"-Wextra"
"-Wc++98-compat-extra-semi"
"-Wcast-qual"
diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl
index 8d72190..8c1d7a0 100644
--- a/absl/copts/GENERATED_copts.bzl
+++ b/absl/copts/GENERATED_copts.bzl
@@ -11,6 +11,46 @@
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
+ "-Wmost",
+ "-Wextra",
+ "-Wc++98-compat-extra-semi",
+ "-Wcast-qual",
+ "-Wconversion",
+ "-Wdeprecated-pragma",
+ "-Wfloat-overflow-conversion",
+ "-Wfloat-zero-conversion",
+ "-Wfor-loop-analysis",
+ "-Wformat-security",
+ "-Wgnu-redeclared-enum",
+ "-Winfinite-recursion",
+ "-Winvalid-constexpr",
+ "-Wliteral-conversion",
+ "-Wmissing-declarations",
+ "-Wnullability-completeness",
+ "-Woverlength-strings",
+ "-Wpointer-arith",
+ "-Wself-assign",
+ "-Wshadow-all",
+ "-Wshorten-64-to-32",
+ "-Wsign-conversion",
+ "-Wstring-conversion",
+ "-Wtautological-overlap-compare",
+ "-Wtautological-unsigned-zero-compare",
+ "-Wthread-safety",
+ "-Wundef",
+ "-Wuninitialized",
+ "-Wunreachable-code",
+ "-Wunused-comparison",
+ "-Wunused-local-typedefs",
+ "-Wunused-result",
+ "-Wvla",
+ "-Wwrite-strings",
+ "-Wno-float-conversion",
+ "-Wno-implicit-float-conversion",
+ "-Wno-implicit-int-float-conversion",
+ "-Wno-unknown-warning-option",
+ "-Wno-unused-command-line-argument",
+ "-DNOMINMAX",
]
ABSL_CLANG_CL_TEST_FLAGS = [
@@ -20,6 +60,43 @@
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
+ "-Wmost",
+ "-Wextra",
+ "-Wc++98-compat-extra-semi",
+ "-Wcast-qual",
+ "-Wconversion",
+ "-Wdeprecated-pragma",
+ "-Wfloat-overflow-conversion",
+ "-Wfloat-zero-conversion",
+ "-Wfor-loop-analysis",
+ "-Wformat-security",
+ "-Wgnu-redeclared-enum",
+ "-Winfinite-recursion",
+ "-Winvalid-constexpr",
+ "-Wliteral-conversion",
+ "-Wmissing-declarations",
+ "-Woverlength-strings",
+ "-Wpointer-arith",
+ "-Wself-assign",
+ "-Wshadow-all",
+ "-Wstring-conversion",
+ "-Wtautological-overlap-compare",
+ "-Wtautological-unsigned-zero-compare",
+ "-Wthread-safety",
+ "-Wundef",
+ "-Wuninitialized",
+ "-Wunreachable-code",
+ "-Wunused-comparison",
+ "-Wunused-local-typedefs",
+ "-Wunused-result",
+ "-Wvla",
+ "-Wwrite-strings",
+ "-Wno-float-conversion",
+ "-Wno-implicit-float-conversion",
+ "-Wno-implicit-int-float-conversion",
+ "-Wno-unknown-warning-option",
+ "-Wno-unused-command-line-argument",
+ "-DNOMINMAX",
"-Wno-deprecated-declarations",
"-Wno-implicit-int-conversion",
"-Wno-missing-prototypes",
@@ -85,6 +162,7 @@
ABSL_LLVM_FLAGS = [
"-Wall",
+ "-Wmost",
"-Wextra",
"-Wc++98-compat-extra-semi",
"-Wcast-qual",
@@ -128,6 +206,7 @@
ABSL_LLVM_TEST_FLAGS = [
"-Wall",
+ "-Wmost",
"-Wextra",
"-Wc++98-compat-extra-semi",
"-Wcast-qual",
diff --git a/absl/copts/copts.py b/absl/copts/copts.py
index e6c4385..c1d1f4a 100644
--- a/absl/copts/copts.py
+++ b/absl/copts/copts.py
@@ -41,8 +41,13 @@
"-Wno-unused-private-field",
]
-ABSL_LLVM_FLAGS = [
- "-Wall",
+# https://github.com/llvm/llvm-project/issues/102982
+# A list of LLVM base flags without -Wall. This is because clang-cl
+# translates -Wall to -Weverything on Windows, mimicking MSVCs
+# behavior. On most other platforms, -Wall is just a set of very good
+# default flags.
+ABSL_LLVM_BASE_FLAGS = [
+ "-Wmost",
"-Wextra",
"-Wc++98-compat-extra-semi",
"-Wcast-qual",
@@ -89,6 +94,8 @@
"-DNOMINMAX",
]
+ABSL_LLVM_FLAGS = ["-Wall"] + ABSL_LLVM_BASE_FLAGS
+
ABSL_LLVM_TEST_ADDITIONAL_FLAGS = [
"-Wno-deprecated-declarations",
"-Wno-implicit-int-conversion",
@@ -164,9 +171,15 @@
"ABSL_LLVM_TEST_FLAGS": GccStyleFilterAndCombine(
ABSL_LLVM_FLAGS, ABSL_LLVM_TEST_ADDITIONAL_FLAGS
),
- "ABSL_CLANG_CL_FLAGS": MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES,
+ "ABSL_CLANG_CL_FLAGS": (
+ MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + ABSL_LLVM_BASE_FLAGS
+ ),
"ABSL_CLANG_CL_TEST_FLAGS": (
- MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + ABSL_LLVM_TEST_ADDITIONAL_FLAGS
+ MSVC_BIG_WARNING_FLAGS
+ + MSVC_DEFINES
+ + GccStyleFilterAndCombine(
+ ABSL_LLVM_BASE_FLAGS, ABSL_LLVM_TEST_ADDITIONAL_FLAGS
+ )
),
"ABSL_MSVC_FLAGS": (
MSVC_BIG_WARNING_FLAGS + MSVC_WARNING_FLAGS + MSVC_DEFINES
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index 5f62ebb..a8d7511 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -28,7 +28,7 @@
#include "absl/base/config.h"
#include "absl/debugging/internal/demangle_rust.h"
-#if ABSL_INTERNAL_HAS_CXA_DEMANGLE
+#ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE
#include <cxxabi.h>
#endif
@@ -2941,7 +2941,7 @@
std::string out;
int status = 0;
char* demangled = nullptr;
-#if ABSL_INTERNAL_HAS_CXA_DEMANGLE
+#ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE
demangled = abi::__cxa_demangle(mangled, nullptr, nullptr, &status);
#endif
if (status == 0 && demangled != nullptr) {
diff --git a/absl/debugging/stacktrace_test.cc b/absl/debugging/stacktrace_test.cc
index c1d3d84..177db64 100644
--- a/absl/debugging/stacktrace_test.cc
+++ b/absl/debugging/stacktrace_test.cc
@@ -94,15 +94,23 @@
// This is a separate function to avoid inlining.
ABSL_ATTRIBUTE_NOINLINE static void FixupNoFixupEquivalenceNoInline() {
#if !ABSL_HAVE_ATTRIBUTE_WEAK
- GTEST_SKIP() << "Need weak symbol support";
-#endif
-#if defined(__riscv)
- GTEST_SKIP() << "Skipping test on RISC-V due to pre-existing failure";
-#endif
-#if defined(_WIN32)
+ const char* kSkipReason = "Need weak symbol support";
+#elif defined(__riscv)
+ const char* kSkipReason =
+ "Skipping test on RISC-V due to pre-existing failure";
+#elif defined(_WIN32)
// TODO(b/434184677): Add support for fixups on Windows if needed
- GTEST_SKIP() << "Skipping test on Windows due to lack of support for fixups";
+ const char* kSkipReason =
+ "Skipping test on Windows due to lack of support for fixups";
+#else
+ const char* kSkipReason = nullptr;
#endif
+
+ // This conditional is to avoid an unreachable code warning.
+ if (kSkipReason != nullptr) {
+ GTEST_SKIP() << kSkipReason;
+ }
+
bool can_rely_on_frame_pointers = false;
if (!can_rely_on_frame_pointers) {
GTEST_SKIP() << "Frame pointers are required, but not guaranteed in OSS";
@@ -233,13 +241,20 @@
TEST(StackTrace, FixupLowStackUsage) {
#if !ABSL_HAVE_ATTRIBUTE_WEAK
- GTEST_SKIP() << "Skipping test on MSVC due to weak symbols";
-#endif
-#if defined(_WIN32)
+ const char* kSkipReason = "Skipping test on MSVC due to weak symbols";
+#elif defined(_WIN32)
// TODO(b/434184677): Add support for fixups on Windows if needed
- GTEST_SKIP() << "Skipping test on Windows due to lack of support for fixups";
+ const char* kSkipReason =
+ "Skipping test on Windows due to lack of support for fixups";
+#else
+ const char* kSkipReason = nullptr;
#endif
+ // This conditional is to avoid an unreachable code warning.
+ if (kSkipReason != nullptr) {
+ GTEST_SKIP() << kSkipReason;
+ }
+
const Cleanup restore_state([enable_fixup = g_enable_fixup,
fixup_calls = g_fixup_calls,
should_fixup_calls = g_should_fixup_calls]() {
@@ -276,13 +291,20 @@
TEST(StackTrace, CustomUnwinderPerformsFixup) {
#if !ABSL_HAVE_ATTRIBUTE_WEAK
- GTEST_SKIP() << "Need weak symbol support";
-#endif
-#if defined(_WIN32)
+ const char* kSkipReason = "Need weak symbol support";
+#elif defined(_WIN32)
// TODO(b/434184677): Add support for fixups on Windows if needed
- GTEST_SKIP() << "Skipping test on Windows due to lack of support for fixups";
+ const char* kSkipReason =
+ "Skipping test on Windows due to lack of support for fixups";
+#else
+ const char* kSkipReason = nullptr;
#endif
+ // This conditional is to avoid an unreachable code warning.
+ if (kSkipReason != nullptr) {
+ GTEST_SKIP() << kSkipReason;
+ }
+
constexpr int kSkip = 1; // Skip our own frame, whose return PCs won't match
constexpr auto kStackCount = 1;
diff --git a/absl/hash/internal/low_level_hash_test.cc b/absl/hash/internal/low_level_hash_test.cc
index c8573b1..b4fe872 100644
--- a/absl/hash/internal/low_level_hash_test.cc
+++ b/absl/hash/internal/low_level_hash_test.cc
@@ -361,9 +361,13 @@
#if defined(ABSL_IS_BIG_ENDIAN) || !defined(ABSL_HAVE_INTRINSIC_INT128) || \
UINTPTR_MAX != UINT64_MAX
constexpr uint64_t kGolden[kNumGoldenOutputs] = {};
- GTEST_SKIP()
- << "We only maintain golden data for little endian 64 bit systems with "
- "128 bit intristics.";
+ // This conditional is to avoid an unreachable code warning.
+ bool skip = true;
+ if (skip) {
+ GTEST_SKIP()
+ << "We only maintain golden data for little endian 64 bit systems with "
+ "128 bit intristics.";
+ }
#elif defined(__SSE4_2__) && defined(__AES__)
constexpr uint64_t kGolden[kNumGoldenOutputs] = {
0xd6bdb2c9ba5e55f2, 0xffd3e23d4115a8ae, 0x2c3218ef486127de,
diff --git a/absl/log/internal/vlog_config.cc b/absl/log/internal/vlog_config.cc
index 97665a5..e9b4827 100644
--- a/absl/log/internal/vlog_config.cc
+++ b/absl/log/internal/vlog_config.cc
@@ -45,13 +45,25 @@
namespace log_internal {
namespace {
-bool ModuleIsPath(absl::string_view module_pattern) {
+
#ifdef _WIN32
- return module_pattern.find_first_of("/\\") != module_pattern.npos;
+constexpr char kPathSeparators[] = "/\\";
#else
- return module_pattern.find('/') != module_pattern.npos;
+constexpr char kPathSeparators[] = "/";
#endif
+
+bool ModuleIsPath(absl::string_view module_pattern) {
+ return module_pattern.find_first_of(kPathSeparators) != module_pattern.npos;
}
+
+absl::string_view Basename(absl::string_view file) {
+ auto sep = file.find_last_of(kPathSeparators);
+ if (sep != file.npos) {
+ file.remove_prefix(sep + 1);
+ }
+ return file;
+}
+
} // namespace
bool VLogSite::SlowIsEnabled(int stale_v, int level) {
@@ -129,21 +141,9 @@
// parsing flags). We can't allocate in `VLOG`, so we treat null as empty
// here and press on.
if (!infos || infos->empty()) return current_global_v;
- // Get basename for file
- absl::string_view basename = file;
- {
- const size_t sep = basename.rfind('/');
- if (sep != basename.npos) {
- basename.remove_prefix(sep + 1);
-#ifdef _WIN32
- } else {
- const size_t sep = basename.rfind('\\');
- if (sep != basename.npos) basename.remove_prefix(sep + 1);
-#endif
- }
- }
- absl::string_view stem = file, stem_basename = basename;
+ absl::string_view stem = file;
+ absl::string_view stem_basename = Basename(stem);
{
const size_t sep = stem_basename.find('.');
if (sep != stem_basename.npos) {