Skip to content

Commit 9f40d6d

Browse files
Abseil Teamcopybara-github
authored andcommitted
Enable clang-specific warnings on the clang-cl build
instead of just trying to be MSVC This also fixes the new warnings that are caught. These include: * Unreachable code after GTEST_SKIP (this is kind of ugly) * Some -Wundef warnings * A -Wshadow warning in vlog_config.cc PiperOrigin-RevId: 838046186 Change-Id: Ief48d6db2b8755d2173997d052560880593d5819
1 parent b20370e commit 9f40d6d

File tree

9 files changed

+43
-243
lines changed

9 files changed

+43
-243
lines changed

absl/base/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
755755
#ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE
756756
#error ABSL_INTERNAL_HAS_CXA_DEMANGLE cannot be directly set
757757
#elif defined(OS_ANDROID) && (defined(__i386__) || defined(__x86_64__))
758-
#undef ABSL_INTERNAL_HAS_CXA_DEMANGLE
758+
#define ABSL_INTERNAL_HAS_CXA_DEMANGLE 0
759759
#elif defined(__GNUC__)
760760
#define ABSL_INTERNAL_HAS_CXA_DEMANGLE 1
761761
#elif defined(__clang__) && !defined(_MSC_VER)

absl/container/btree_test.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,10 +2048,7 @@ TEST(Btree, ExtractAndGetNextEndIter) {
20482048

20492049
TEST(Btree, ExtractDoesntCauseExtraMoves) {
20502050
#ifdef _MSC_VER
2051-
// This conditional is to avoid an unreachable code warning.
2052-
if (_MSC_VER > 0) {
2053-
GTEST_SKIP() << "This test fails on MSVC.";
2054-
}
2051+
GTEST_SKIP() << "This test fails on MSVC.";
20552052
#endif
20562053

20572054
using Set = absl::btree_set<MovableOnlyInstance>;

absl/copts/GENERATED_AbseilCopts.cmake

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,6 @@ list(APPEND ABSL_CLANG_CL_FLAGS
1010
"/D_CRT_SECURE_NO_WARNINGS"
1111
"/D_SCL_SECURE_NO_WARNINGS"
1212
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE"
13-
"-Wmost"
14-
"-Wextra"
15-
"-Wc++98-compat-extra-semi"
16-
"-Wcast-qual"
17-
"-Wconversion"
18-
"-Wdeprecated-pragma"
19-
"-Wfloat-overflow-conversion"
20-
"-Wfloat-zero-conversion"
21-
"-Wfor-loop-analysis"
22-
"-Wformat-security"
23-
"-Wgnu-redeclared-enum"
24-
"-Winfinite-recursion"
25-
"-Winvalid-constexpr"
26-
"-Wliteral-conversion"
27-
"-Wmissing-declarations"
28-
"-Wnullability-completeness"
29-
"-Woverlength-strings"
30-
"-Wpointer-arith"
31-
"-Wself-assign"
32-
"-Wshadow-all"
33-
"-Wshorten-64-to-32"
34-
"-Wsign-conversion"
35-
"-Wstring-conversion"
36-
"-Wtautological-overlap-compare"
37-
"-Wtautological-unsigned-zero-compare"
38-
"-Wthread-safety"
39-
"-Wundef"
40-
"-Wuninitialized"
41-
"-Wunreachable-code"
42-
"-Wunused-comparison"
43-
"-Wunused-local-typedefs"
44-
"-Wunused-result"
45-
"-Wvla"
46-
"-Wwrite-strings"
47-
"-Wno-float-conversion"
48-
"-Wno-implicit-float-conversion"
49-
"-Wno-implicit-int-float-conversion"
50-
"-Wno-unknown-warning-option"
51-
"-Wno-unused-command-line-argument"
52-
"-DNOMINMAX"
5313
)
5414

5515
list(APPEND ABSL_CLANG_CL_TEST_FLAGS
@@ -59,43 +19,6 @@ list(APPEND ABSL_CLANG_CL_TEST_FLAGS
5919
"/D_CRT_SECURE_NO_WARNINGS"
6020
"/D_SCL_SECURE_NO_WARNINGS"
6121
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE"
62-
"-Wmost"
63-
"-Wextra"
64-
"-Wc++98-compat-extra-semi"
65-
"-Wcast-qual"
66-
"-Wconversion"
67-
"-Wdeprecated-pragma"
68-
"-Wfloat-overflow-conversion"
69-
"-Wfloat-zero-conversion"
70-
"-Wfor-loop-analysis"
71-
"-Wformat-security"
72-
"-Wgnu-redeclared-enum"
73-
"-Winfinite-recursion"
74-
"-Winvalid-constexpr"
75-
"-Wliteral-conversion"
76-
"-Wmissing-declarations"
77-
"-Woverlength-strings"
78-
"-Wpointer-arith"
79-
"-Wself-assign"
80-
"-Wshadow-all"
81-
"-Wstring-conversion"
82-
"-Wtautological-overlap-compare"
83-
"-Wtautological-unsigned-zero-compare"
84-
"-Wthread-safety"
85-
"-Wundef"
86-
"-Wuninitialized"
87-
"-Wunreachable-code"
88-
"-Wunused-comparison"
89-
"-Wunused-local-typedefs"
90-
"-Wunused-result"
91-
"-Wvla"
92-
"-Wwrite-strings"
93-
"-Wno-float-conversion"
94-
"-Wno-implicit-float-conversion"
95-
"-Wno-implicit-int-float-conversion"
96-
"-Wno-unknown-warning-option"
97-
"-Wno-unused-command-line-argument"
98-
"-DNOMINMAX"
9922
"-Wno-deprecated-declarations"
10023
"-Wno-implicit-int-conversion"
10124
"-Wno-missing-prototypes"
@@ -161,7 +84,6 @@ list(APPEND ABSL_GCC_TEST_FLAGS
16184

16285
list(APPEND ABSL_LLVM_FLAGS
16386
"-Wall"
164-
"-Wmost"
16587
"-Wextra"
16688
"-Wc++98-compat-extra-semi"
16789
"-Wcast-qual"
@@ -205,7 +127,6 @@ list(APPEND ABSL_LLVM_FLAGS
205127

206128
list(APPEND ABSL_LLVM_TEST_FLAGS
207129
"-Wall"
208-
"-Wmost"
209130
"-Wextra"
210131
"-Wc++98-compat-extra-semi"
211132
"-Wcast-qual"

absl/copts/GENERATED_copts.bzl

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,6 @@ ABSL_CLANG_CL_FLAGS = [
1111
"/D_CRT_SECURE_NO_WARNINGS",
1212
"/D_SCL_SECURE_NO_WARNINGS",
1313
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
14-
"-Wmost",
15-
"-Wextra",
16-
"-Wc++98-compat-extra-semi",
17-
"-Wcast-qual",
18-
"-Wconversion",
19-
"-Wdeprecated-pragma",
20-
"-Wfloat-overflow-conversion",
21-
"-Wfloat-zero-conversion",
22-
"-Wfor-loop-analysis",
23-
"-Wformat-security",
24-
"-Wgnu-redeclared-enum",
25-
"-Winfinite-recursion",
26-
"-Winvalid-constexpr",
27-
"-Wliteral-conversion",
28-
"-Wmissing-declarations",
29-
"-Wnullability-completeness",
30-
"-Woverlength-strings",
31-
"-Wpointer-arith",
32-
"-Wself-assign",
33-
"-Wshadow-all",
34-
"-Wshorten-64-to-32",
35-
"-Wsign-conversion",
36-
"-Wstring-conversion",
37-
"-Wtautological-overlap-compare",
38-
"-Wtautological-unsigned-zero-compare",
39-
"-Wthread-safety",
40-
"-Wundef",
41-
"-Wuninitialized",
42-
"-Wunreachable-code",
43-
"-Wunused-comparison",
44-
"-Wunused-local-typedefs",
45-
"-Wunused-result",
46-
"-Wvla",
47-
"-Wwrite-strings",
48-
"-Wno-float-conversion",
49-
"-Wno-implicit-float-conversion",
50-
"-Wno-implicit-int-float-conversion",
51-
"-Wno-unknown-warning-option",
52-
"-Wno-unused-command-line-argument",
53-
"-DNOMINMAX",
5414
]
5515

5616
ABSL_CLANG_CL_TEST_FLAGS = [
@@ -60,43 +20,6 @@ ABSL_CLANG_CL_TEST_FLAGS = [
6020
"/D_CRT_SECURE_NO_WARNINGS",
6121
"/D_SCL_SECURE_NO_WARNINGS",
6222
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
63-
"-Wmost",
64-
"-Wextra",
65-
"-Wc++98-compat-extra-semi",
66-
"-Wcast-qual",
67-
"-Wconversion",
68-
"-Wdeprecated-pragma",
69-
"-Wfloat-overflow-conversion",
70-
"-Wfloat-zero-conversion",
71-
"-Wfor-loop-analysis",
72-
"-Wformat-security",
73-
"-Wgnu-redeclared-enum",
74-
"-Winfinite-recursion",
75-
"-Winvalid-constexpr",
76-
"-Wliteral-conversion",
77-
"-Wmissing-declarations",
78-
"-Woverlength-strings",
79-
"-Wpointer-arith",
80-
"-Wself-assign",
81-
"-Wshadow-all",
82-
"-Wstring-conversion",
83-
"-Wtautological-overlap-compare",
84-
"-Wtautological-unsigned-zero-compare",
85-
"-Wthread-safety",
86-
"-Wundef",
87-
"-Wuninitialized",
88-
"-Wunreachable-code",
89-
"-Wunused-comparison",
90-
"-Wunused-local-typedefs",
91-
"-Wunused-result",
92-
"-Wvla",
93-
"-Wwrite-strings",
94-
"-Wno-float-conversion",
95-
"-Wno-implicit-float-conversion",
96-
"-Wno-implicit-int-float-conversion",
97-
"-Wno-unknown-warning-option",
98-
"-Wno-unused-command-line-argument",
99-
"-DNOMINMAX",
10023
"-Wno-deprecated-declarations",
10124
"-Wno-implicit-int-conversion",
10225
"-Wno-missing-prototypes",
@@ -162,7 +85,6 @@ ABSL_GCC_TEST_FLAGS = [
16285

16386
ABSL_LLVM_FLAGS = [
16487
"-Wall",
165-
"-Wmost",
16688
"-Wextra",
16789
"-Wc++98-compat-extra-semi",
16890
"-Wcast-qual",
@@ -206,7 +128,6 @@ ABSL_LLVM_FLAGS = [
206128

207129
ABSL_LLVM_TEST_FLAGS = [
208130
"-Wall",
209-
"-Wmost",
210131
"-Wextra",
211132
"-Wc++98-compat-extra-semi",
212133
"-Wcast-qual",

absl/copts/copts.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,8 @@
4141
"-Wno-unused-private-field",
4242
]
4343

44-
# https://github.com/llvm/llvm-project/issues/102982
45-
# A list of LLVM base flags without -Wall. This is because clang-cl
46-
# translates -Wall to -Weverything on Windows, mimicking MSVCs
47-
# behavior. On most other platforms, -Wall is just a set of very good
48-
# default flags.
49-
ABSL_LLVM_BASE_FLAGS = [
50-
"-Wmost",
44+
ABSL_LLVM_FLAGS = [
45+
"-Wall",
5146
"-Wextra",
5247
"-Wc++98-compat-extra-semi",
5348
"-Wcast-qual",
@@ -94,8 +89,6 @@
9489
"-DNOMINMAX",
9590
]
9691

97-
ABSL_LLVM_FLAGS = ["-Wall"] + ABSL_LLVM_BASE_FLAGS
98-
9992
ABSL_LLVM_TEST_ADDITIONAL_FLAGS = [
10093
"-Wno-deprecated-declarations",
10194
"-Wno-implicit-int-conversion",
@@ -171,15 +164,9 @@ def GccStyleFilterAndCombine(default_flags, test_flags):
171164
"ABSL_LLVM_TEST_FLAGS": GccStyleFilterAndCombine(
172165
ABSL_LLVM_FLAGS, ABSL_LLVM_TEST_ADDITIONAL_FLAGS
173166
),
174-
"ABSL_CLANG_CL_FLAGS": (
175-
MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + ABSL_LLVM_BASE_FLAGS
176-
),
167+
"ABSL_CLANG_CL_FLAGS": MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES,
177168
"ABSL_CLANG_CL_TEST_FLAGS": (
178-
MSVC_BIG_WARNING_FLAGS
179-
+ MSVC_DEFINES
180-
+ GccStyleFilterAndCombine(
181-
ABSL_LLVM_BASE_FLAGS, ABSL_LLVM_TEST_ADDITIONAL_FLAGS
182-
)
169+
MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + ABSL_LLVM_TEST_ADDITIONAL_FLAGS
183170
),
184171
"ABSL_MSVC_FLAGS": (
185172
MSVC_BIG_WARNING_FLAGS + MSVC_WARNING_FLAGS + MSVC_DEFINES

absl/debugging/internal/demangle.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "absl/base/config.h"
2929
#include "absl/debugging/internal/demangle_rust.h"
3030

31-
#ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE
31+
#if ABSL_INTERNAL_HAS_CXA_DEMANGLE
3232
#include <cxxabi.h>
3333
#endif
3434

@@ -2941,7 +2941,7 @@ std::string DemangleString(const char* mangled) {
29412941
std::string out;
29422942
int status = 0;
29432943
char* demangled = nullptr;
2944-
#ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE
2944+
#if ABSL_INTERNAL_HAS_CXA_DEMANGLE
29452945
demangled = abi::__cxa_demangle(mangled, nullptr, nullptr, &status);
29462946
#endif
29472947
if (status == 0 && demangled != nullptr) {

absl/debugging/stacktrace_test.cc

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,15 @@ TEST(StackTrace, HugeFrame) {
9494
// This is a separate function to avoid inlining.
9595
ABSL_ATTRIBUTE_NOINLINE static void FixupNoFixupEquivalenceNoInline() {
9696
#if !ABSL_HAVE_ATTRIBUTE_WEAK
97-
const char* kSkipReason = "Need weak symbol support";
98-
#elif defined(__riscv)
99-
const char* kSkipReason =
100-
"Skipping test on RISC-V due to pre-existing failure";
101-
#elif defined(_WIN32)
97+
GTEST_SKIP() << "Need weak symbol support";
98+
#endif
99+
#if defined(__riscv)
100+
GTEST_SKIP() << "Skipping test on RISC-V due to pre-existing failure";
101+
#endif
102+
#if defined(_WIN32)
102103
// TODO(b/434184677): Add support for fixups on Windows if needed
103-
const char* kSkipReason =
104-
"Skipping test on Windows due to lack of support for fixups";
105-
#else
106-
const char* kSkipReason = nullptr;
104+
GTEST_SKIP() << "Skipping test on Windows due to lack of support for fixups";
107105
#endif
108-
109-
// This conditional is to avoid an unreachable code warning.
110-
if (kSkipReason != nullptr) {
111-
GTEST_SKIP() << kSkipReason;
112-
}
113-
114106
bool can_rely_on_frame_pointers = false;
115107
if (!can_rely_on_frame_pointers) {
116108
GTEST_SKIP() << "Frame pointers are required, but not guaranteed in OSS";
@@ -241,20 +233,13 @@ TEST(StackTrace, FixupNoFixupEquivalence) { FixupNoFixupEquivalenceNoInline(); }
241233

242234
TEST(StackTrace, FixupLowStackUsage) {
243235
#if !ABSL_HAVE_ATTRIBUTE_WEAK
244-
const char* kSkipReason = "Skipping test on MSVC due to weak symbols";
245-
#elif defined(_WIN32)
236+
GTEST_SKIP() << "Skipping test on MSVC due to weak symbols";
237+
#endif
238+
#if defined(_WIN32)
246239
// TODO(b/434184677): Add support for fixups on Windows if needed
247-
const char* kSkipReason =
248-
"Skipping test on Windows due to lack of support for fixups";
249-
#else
250-
const char* kSkipReason = nullptr;
240+
GTEST_SKIP() << "Skipping test on Windows due to lack of support for fixups";
251241
#endif
252242

253-
// This conditional is to avoid an unreachable code warning.
254-
if (kSkipReason != nullptr) {
255-
GTEST_SKIP() << kSkipReason;
256-
}
257-
258243
const Cleanup restore_state([enable_fixup = g_enable_fixup,
259244
fixup_calls = g_fixup_calls,
260245
should_fixup_calls = g_should_fixup_calls]() {
@@ -291,20 +276,13 @@ TEST(StackTrace, FixupLowStackUsage) {
291276

292277
TEST(StackTrace, CustomUnwinderPerformsFixup) {
293278
#if !ABSL_HAVE_ATTRIBUTE_WEAK
294-
const char* kSkipReason = "Need weak symbol support";
295-
#elif defined(_WIN32)
279+
GTEST_SKIP() << "Need weak symbol support";
280+
#endif
281+
#if defined(_WIN32)
296282
// TODO(b/434184677): Add support for fixups on Windows if needed
297-
const char* kSkipReason =
298-
"Skipping test on Windows due to lack of support for fixups";
299-
#else
300-
const char* kSkipReason = nullptr;
283+
GTEST_SKIP() << "Skipping test on Windows due to lack of support for fixups";
301284
#endif
302285

303-
// This conditional is to avoid an unreachable code warning.
304-
if (kSkipReason != nullptr) {
305-
GTEST_SKIP() << kSkipReason;
306-
}
307-
308286
constexpr int kSkip = 1; // Skip our own frame, whose return PCs won't match
309287
constexpr auto kStackCount = 1;
310288

absl/hash/internal/low_level_hash_test.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,9 @@ TEST(LowLevelHashTest, VerifyGolden) {
361361
#if defined(ABSL_IS_BIG_ENDIAN) || !defined(ABSL_HAVE_INTRINSIC_INT128) || \
362362
UINTPTR_MAX != UINT64_MAX
363363
constexpr uint64_t kGolden[kNumGoldenOutputs] = {};
364-
// This conditional is to avoid an unreachable code warning.
365-
bool skip = true;
366-
if (skip) {
367-
GTEST_SKIP()
368-
<< "We only maintain golden data for little endian 64 bit systems with "
369-
"128 bit intristics.";
370-
}
364+
GTEST_SKIP()
365+
<< "We only maintain golden data for little endian 64 bit systems with "
366+
"128 bit intristics.";
371367
#elif defined(__SSE4_2__) && defined(__AES__)
372368
constexpr uint64_t kGolden[kNumGoldenOutputs] = {
373369
0xd6bdb2c9ba5e55f2, 0xffd3e23d4115a8ae, 0x2c3218ef486127de,

0 commit comments

Comments
 (0)