From 17464cb7b67352b25f108414bc946372b35dc3c3 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 26 Dec 2024 11:29:06 -0800 Subject: [PATCH] Improve importer.cc imports on windows This fixes that we accidentally imported absl ascii.h within the protobuf namespace, and avoids unused imports warnings for imports that are only used on windows. PiperOrigin-RevId: 709846366 --- src/google/protobuf/compiler/importer.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 4b38df4e04..7a84e7d604 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc @@ -11,6 +11,8 @@ #include "google/protobuf/compiler/importer.h" +#include + #ifdef _MSC_VER #include #else @@ -21,21 +23,27 @@ #include #include -#include #include #include #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" -#include "absl/strings/str_replace.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "google/protobuf/compiler/parser.h" -#include "google/protobuf/io/io_win32.h" #include "google/protobuf/io/tokenizer.h" #include "google/protobuf/io/zero_copy_stream_impl.h" +#ifdef _WIN32 +#include "absl/strings/str_replace.h" +#include "google/protobuf/io/io_win32.h" +#endif + +#if defined(_WIN32) || defined(__CYGWIN__) +#include "absl/strings/ascii.h" +#endif + namespace google { namespace protobuf { namespace compiler { @@ -47,10 +55,6 @@ using google::protobuf::io::win32::access; using google::protobuf::io::win32::open; #endif -#if defined(_WIN32) || defined(__CYGWIN__) -#include "absl/strings/ascii.h" -#endif - // Returns true if the text looks like a Windows-style absolute path, starting // with a drive letter. Example: "C:\foo". TODO: Share this with // copy in command_line_interface.cc?