diff options
author | Tom Hughes <tomhughes@google.com> | 2023-03-04 00:03:22 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-03-06 15:16:32 (GMT) |
commit | 16feffa8fa7cb6e061787ce345c16eb24326d2ce (patch) | |
tree | 96b4e5fce8cb287148427aa308c907e7c381edf6 | |
parent | dc10c3b5e55c1101e7759bdb7bf9790cebbf4ad2 (diff) | |
download | googletest-16feffa8fa7cb6e061787ce345c16eb24326d2ce.zip googletest-16feffa8fa7cb6e061787ce345c16eb24326d2ce.tar.gz googletest-16feffa8fa7cb6e061787ce345c16eb24326d2ce.tar.bz2 |
Replace "#if GTEST_HAS_ABSL" with "#ifdef GTEST_HAS_ABSL"
This allows compilation with "-Wundef" (#3267).
PiperOrigin-RevId: 513945230
Change-Id: I45ef19c7ff3d20e97216bd031d406a03365471da
-rw-r--r-- | googletest/include/gtest/gtest-printers.h | 2 | ||||
-rw-r--r-- | googletest/include/gtest/internal/gtest-port.h | 15 | ||||
-rw-r--r-- | googletest/src/gtest-internal-inl.h | 2 | ||||
-rw-r--r-- | googletest/src/gtest.cc | 12 | ||||
-rw-r--r-- | googletest/test/googletest-port-test.cc | 2 | ||||
-rw-r--r-- | googletest/test/gtest_unittest.cc | 10 |
6 files changed, 22 insertions, 21 deletions
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 739d545..b2d7b0a 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -857,7 +857,7 @@ class UniversalPrinter<Variant<T...>> { public: static void Print(const Variant<T...>& value, ::std::ostream* os) { *os << '('; -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL absl::visit(Visitor{os, value.index()}, value); #else std::visit(Visitor{os, value.index()}, value); diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 29503db..9a35de0 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -178,6 +178,7 @@ // define themselves. // GTEST_USES_SIMPLE_RE - our own simple regex is used; // the above RE\b(s) are mutually exclusive. +// GTEST_HAS_ABSL - Google Test is compiled with Abseil. // Misc public macros // ------------------ @@ -304,7 +305,7 @@ #include "gtest/internal/custom/gtest-port.h" #include "gtest/internal/gtest-port-arch.h" -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL #include "absl/flags/declare.h" #include "absl/flags/flag.h" #include "absl/flags/reflection.h" @@ -412,7 +413,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // Select the regular expression implementation. -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // When using Abseil, RE2 is required. #include "absl/strings/string_view.h" #include "re2/re2.h" @@ -2248,7 +2249,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. #endif // !defined(GTEST_FLAG) // Pick a command line flags implementation. -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Macros for defining flags. #define GTEST_DEFINE_bool_(name, default_val, doc) \ @@ -2359,7 +2360,7 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val); #endif // !defined(GTEST_INTERNAL_DEPRECATED) -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Always use absl::any for UniversalPrinter<> specializations if googletest // is built with absl support. #define GTEST_INTERNAL_HAS_ANY 1 @@ -2392,7 +2393,7 @@ using Any = ::std::any; #define GTEST_INTERNAL_HAS_ANY 0 #endif -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Always use absl::optional for UniversalPrinter<> specializations if // googletest is built with absl support. #define GTEST_INTERNAL_HAS_OPTIONAL 1 @@ -2428,7 +2429,7 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; } #define GTEST_INTERNAL_HAS_OPTIONAL 0 #endif -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Always use absl::string_view for Matcher<> specializations if googletest // is built with absl support. #define GTEST_INTERNAL_HAS_STRING_VIEW 1 @@ -2460,7 +2461,7 @@ using StringView = ::std::string_view; #define GTEST_INTERNAL_HAS_STRING_VIEW 0 #endif -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Always use absl::variant for UniversalPrinter<> specializations if googletest // is built with absl support. #define GTEST_INTERNAL_HAS_VARIANT 1 diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 007e049..16841b5 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -442,7 +442,7 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface { void UponLeavingGTest() override; private: -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL Mutex mutex_; // Protects all internal state. // We save the stack frame below the frame that calls user code. diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 7ffbf41..0dd3eba 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -135,7 +135,7 @@ #endif #endif -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL #include "absl/debugging/failure_signal_handler.h" #include "absl/debugging/stacktrace.h" #include "absl/debugging/symbolize.h" @@ -4958,7 +4958,7 @@ const char* const OsStackTraceGetterInterface::kElidedFramesMarker = std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count) GTEST_LOCK_EXCLUDED_(mutex_) { -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL std::string result; if (max_depth <= 0) { @@ -5007,7 +5007,7 @@ std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count) } void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) { -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL void* caller_frame = nullptr; if (absl::GetStackTrace(&caller_frame, 1, 3) <= 0) { caller_frame = nullptr; @@ -5686,7 +5686,7 @@ void UnitTestImpl::PostFlagParsingInit() { ConfigureStreamingOutput(); #endif // GTEST_CAN_STREAM_RESULTS_ -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL if (GTEST_FLAG_GET(install_failure_signal_handler)) { absl::FailureSignalHandlerOptions options; absl::InstallFailureSignalHandler(options); @@ -6668,7 +6668,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { // Parses the command line for Google Test flags, without initializing // other parts of Google Test. void ParseGoogleTestFlagsOnly(int* argc, char** argv) { -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL if (*argc > 0) { // absl::ParseCommandLine() requires *argc > 0. auto positional_args = absl::flags_internal::ParseCommandLineImpl( @@ -6720,7 +6720,7 @@ void InitGoogleTestImpl(int* argc, CharType** argv) { g_argvs.push_back(StreamableToString(argv[i])); } -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL absl::InitializeSymbolizer(g_argvs[0].c_str()); // When using the Abseil Flags library, set the program usage message to the diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index f3ebda9..d01ccaa 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -390,7 +390,7 @@ TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) { // the platform. The test will produce compiler errors in case of failure. // For simplicity, we only cover the most important platforms here. TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) { -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL EXPECT_TRUE(GTEST_USES_RE2); #elif GTEST_HAS_POSIX_RE EXPECT_TRUE(GTEST_USES_POSIX_RE); diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 2f137d2..aea8e1f 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -6178,12 +6178,12 @@ TEST_F(ParseFlagsTest, FilterBad) { const char* argv2[] = {"foo.exe", "--gtest_filter", nullptr}; -#if GTEST_HAS_ABSL && defined(GTEST_HAS_DEATH_TEST) +#if defined(GTEST_HAS_ABSL) && defined(GTEST_HAS_DEATH_TEST) // Invalid flag arguments are a fatal error when using the Abseil Flags. EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true), testing::ExitedWithCode(1), "ERROR: Missing the value for the flag 'gtest_filter'"); -#elif !GTEST_HAS_ABSL +#elif !defined(GTEST_HAS_ABSL) GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true); #else static_cast<void>(argv); @@ -6197,12 +6197,12 @@ TEST_F(ParseFlagsTest, OutputEmpty) { const char* argv2[] = {"foo.exe", "--gtest_output", nullptr}; -#if GTEST_HAS_ABSL && defined(GTEST_HAS_DEATH_TEST) +#if defined(GTEST_HAS_ABSL) && defined(GTEST_HAS_DEATH_TEST) // Invalid flag arguments are a fatal error when using the Abseil Flags. EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true), testing::ExitedWithCode(1), "ERROR: Missing the value for the flag 'gtest_output'"); -#elif !GTEST_HAS_ABSL +#elif !defined(GTEST_HAS_ABSL) GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true); #else static_cast<void>(argv); @@ -6210,7 +6210,7 @@ TEST_F(ParseFlagsTest, OutputEmpty) { #endif } -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL TEST_F(ParseFlagsTest, AbseilPositionalFlags) { const char* argv[] = {"foo.exe", "--gtest_throw_on_failure=1", "--", "--other_flag", nullptr}; |