arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1447: [C++] Fix many include-what-you-use warnings
Date Sat, 02 Sep 2017 20:33:57 GMT
Repository: arrow
Updated Branches:
  refs/heads/master 848a0f782 -> 1a8dafb2b


ARROW-1447: [C++] Fix many include-what-you-use warnings

There's still some work to deal with some things that IWYU is reporting incorrectly, but we can do that later

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes #1025 from wesm/ARROW-1447 and squashes the following commits:

67a20026 [Wes McKinney] Fix another include for Windows
f6ec09a7 [Wes McKinney] Fix include error
5d77388a [Wes McKinney] Fix buglet
09b38b07 [Wes McKinney] Add arrow-specific mappings files, fix more things
49688450 [Wes McKinney] Fix a ton of include-what-you-use warnings


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/1a8dafb2
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/1a8dafb2
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/1a8dafb2

Branch: refs/heads/master
Commit: 1a8dafb2b7b5d4eff56cc4eb3de25b87fc41aead
Parents: 848a0f7
Author: Wes McKinney <wes.mckinney@twosigma.com>
Authored: Sat Sep 2 16:33:48 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Sat Sep 2 16:33:48 2017 -0400

----------------------------------------------------------------------
 cpp/build-support/iwyu/iwyu-filter.awk         |  4 +++
 cpp/build-support/iwyu/iwyu.sh                 | 33 +++++++++----------
 cpp/build-support/iwyu/mappings/arrow-misc.imp | 32 +++++++++++++++++++
 cpp/src/arrow/allocator-test.cc                |  8 +++--
 cpp/src/arrow/array-decimal-test.cc            | 18 +++++++++--
 cpp/src/arrow/buffer-test.cc                   |  5 ++-
 cpp/src/arrow/buffer.cc                        |  1 -
 cpp/src/arrow/buffer.h                         |  3 +-
 cpp/src/arrow/io/file.cc                       | 35 +++++++++------------
 cpp/src/arrow/io/file.h                        |  1 -
 cpp/src/arrow/io/hdfs-internal.cc              | 11 ++++---
 cpp/src/arrow/io/hdfs-internal.h               | 11 ++++---
 cpp/src/arrow/io/hdfs.cc                       |  5 +++
 cpp/src/arrow/io/hdfs.h                        |  2 +-
 cpp/src/arrow/io/interfaces.cc                 |  1 -
 cpp/src/arrow/io/interfaces.h                  |  1 -
 cpp/src/arrow/io/io-file-test.cc               | 20 ++++++++----
 cpp/src/arrow/io/io-hdfs-test.cc               | 11 +++++--
 cpp/src/arrow/io/io-memory-test.cc             | 10 +++---
 cpp/src/arrow/io/memory.cc                     |  6 +---
 cpp/src/arrow/io/memory.h                      |  4 +--
 cpp/src/arrow/ipc/dictionary.cc                |  3 +-
 cpp/src/arrow/ipc/dictionary.h                 | 11 -------
 cpp/src/arrow/ipc/feather-internal.h           |  1 +
 cpp/src/arrow/ipc/feather.cc                   |  9 +++---
 cpp/src/arrow/ipc/feather.h                    |  4 +--
 cpp/src/arrow/ipc/file-to-stream.cc            |  6 ++++
 cpp/src/arrow/ipc/json-integration-test.cc     | 11 ++++---
 cpp/src/arrow/ipc/json-internal.cc             |  8 +----
 cpp/src/arrow/ipc/json-internal.h              |  2 +-
 cpp/src/arrow/ipc/json.cc                      |  6 ++--
 cpp/src/arrow/ipc/json.h                       | 12 +++----
 cpp/src/arrow/ipc/message.cc                   |  8 ++---
 cpp/src/arrow/ipc/message.h                    |  6 ----
 cpp/src/arrow/ipc/metadata-internal.cc         | 12 +++++--
 cpp/src/arrow/ipc/metadata-internal.h          | 12 +------
 cpp/src/arrow/ipc/reader.cc                    |  6 ++++
 cpp/src/arrow/ipc/reader.h                     |  1 -
 cpp/src/arrow/ipc/stream-to-file.cc            |  7 ++++-
 cpp/src/arrow/memory_pool-test.cc              |  9 ++++--
 cpp/src/arrow/memory_pool-test.h               |  6 ++--
 cpp/src/arrow/memory_pool.cc                   |  5 +--
 cpp/src/arrow/python/pandas_to_arrow.cc        |  2 +-
 cpp/src/arrow/status-test.cc                   |  3 +-
 cpp/src/arrow/status.h                         |  2 +-
 cpp/src/arrow/table.h                          | 10 +-----
 cpp/src/arrow/tensor-test.cc                   |  4 ++-
 cpp/src/arrow/tensor.cc                        |  5 +--
 cpp/src/arrow/tensor.h                         |  5 ---
 cpp/src/arrow/type-test.cc                     |  4 ++-
 cpp/src/arrow/type.h                           |  2 +-
 cpp/src/arrow/util/bit-util-test.cc            | 12 ++++---
 cpp/src/arrow/util/compression-test.cc         |  7 +++--
 cpp/src/arrow/util/compression.cc              |  4 ---
 cpp/src/arrow/util/compression_brotli.cc       | 10 +++---
 cpp/src/arrow/util/compression_brotli.h        |  2 +-
 cpp/src/arrow/util/compression_lz4.cc          |  4 ---
 cpp/src/arrow/util/compression_lz4.h           |  2 +-
 cpp/src/arrow/util/compression_snappy.cc       |  8 ++---
 cpp/src/arrow/util/compression_snappy.h        |  2 +-
 cpp/src/arrow/util/compression_zlib.cc         |  2 ++
 cpp/src/arrow/util/compression_zlib.h          |  1 +
 cpp/src/arrow/util/compression_zstd.cc         |  7 ++---
 cpp/src/arrow/util/compression_zstd.h          |  2 +-
 cpp/src/arrow/util/cpu-info.cc                 |  5 ++-
 cpp/src/arrow/util/decimal-test.cc             |  7 +++--
 cpp/src/arrow/util/decimal.cc                  |  3 ++
 cpp/src/arrow/util/decimal.h                   |  7 ++---
 cpp/src/arrow/util/int128.cc                   |  3 +-
 cpp/src/arrow/util/int128.h                    |  2 ++
 cpp/src/arrow/util/key-value-metadata-test.cc  |  9 ++++--
 cpp/src/arrow/util/key_value_metadata.cc       |  4 +++
 cpp/src/arrow/util/rle-encoding-test.cc        | 16 +++++-----
 cpp/src/arrow/util/stl-util-test.cc            |  7 ++---
 cpp/src/arrow/visitor.cc                       |  2 ++
 75 files changed, 292 insertions(+), 240 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/build-support/iwyu/iwyu-filter.awk
----------------------------------------------------------------------
diff --git a/cpp/build-support/iwyu/iwyu-filter.awk b/cpp/build-support/iwyu/iwyu-filter.awk
index a325d0a..a1c9609 100644
--- a/cpp/build-support/iwyu/iwyu-filter.awk
+++ b/cpp/build-support/iwyu/iwyu-filter.awk
@@ -67,6 +67,10 @@ BEGIN {
   # suggestions are addressed and invalid ones are taken care either by proper
   # IWYU pragmas or adding special mappings (e.g. like boost mappings).
   # muted["relative/path/to/file"]
+  muted["arrow/util/bit-util-test.cc"]
+  muted["arrow/util/rle-encoding-test.cc"]
+  muted["include/hdfs.h"]
+  muted["arrow/visitor.h"]
 }
 
 # mute all suggestions for the auto-generated files

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/build-support/iwyu/iwyu.sh
----------------------------------------------------------------------
diff --git a/cpp/build-support/iwyu/iwyu.sh b/cpp/build-support/iwyu/iwyu.sh
index 3ee5a12..f3fadd6 100755
--- a/cpp/build-support/iwyu/iwyu.sh
+++ b/cpp/build-support/iwyu/iwyu.sh
@@ -26,21 +26,6 @@ trap "rm -f $IWYU_LOG" EXIT
 
 echo "Logging IWYU to $IWYU_LOG"
 
-# Build the list of updated files which are of IWYU interest.
-file_list_tmp=$(git diff --name-only \
-    $($ROOT/cpp/build-support/get-upstream-commit.sh) | grep -E '\.(c|cc|h)$')
-if [ -z "$file_list_tmp" ]; then
-  echo "IWYU verification: no updates on related files, declaring success"
-  exit 0
-fi
-
-# Adjust the path for every element in the list. The iwyu_tool.py normalizes
-# paths (via realpath) to match the records from the compilation database.
-IWYU_FILE_LIST=
-for p in $file_list_tmp; do
-  IWYU_FILE_LIST="$IWYU_FILE_LIST $ROOT/$p"
-done
-
 IWYU_MAPPINGS_PATH="$ROOT/cpp/build-support/iwyu/mappings"
 IWYU_ARGS="\
     --mapping_file=$IWYU_MAPPINGS_PATH/boost-all.imp \
@@ -48,7 +33,8 @@ IWYU_ARGS="\
     --mapping_file=$IWYU_MAPPINGS_PATH/boost-extra.imp \
     --mapping_file=$IWYU_MAPPINGS_PATH/gflags.imp \
     --mapping_file=$IWYU_MAPPINGS_PATH/glog.imp \
-    --mapping_file=$IWYU_MAPPINGS_PATH/gtest.imp"
+    --mapping_file=$IWYU_MAPPINGS_PATH/gtest.imp \
+    --mapping_file=$IWYU_MAPPINGS_PATH/arrow-misc.imp"
 
 set -e
 
@@ -57,6 +43,21 @@ if [ "$1" == "all" ]; then
        $IWYU_ARGS | awk -f $ROOT/cpp/build-support/iwyu/iwyu-filter.awk | \
        tee $IWYU_LOG
 else
+  # Build the list of updated files which are of IWYU interest.
+  file_list_tmp=$(git diff --name-only \
+      $($ROOT/cpp/build-support/get-upstream-commit.sh) | grep -E '\.(c|cc|h)$')
+  if [ -z "$file_list_tmp" ]; then
+    echo "IWYU verification: no updates on related files, declaring success"
+    exit 0
+  fi
+
+  # Adjust the path for every element in the list. The iwyu_tool.py normalizes
+  # paths (via realpath) to match the records from the compilation database.
+  IWYU_FILE_LIST=
+  for p in $file_list_tmp; do
+    IWYU_FILE_LIST="$IWYU_FILE_LIST $ROOT/$p"
+  done
+
   python $ROOT/cpp/build-support/iwyu/iwyu_tool.py -p . $IWYU_FILE_LIST  -- \
        $IWYU_ARGS | awk -f $ROOT/cpp/build-support/iwyu/iwyu-filter.awk | \
        tee $IWYU_LOG

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/build-support/iwyu/mappings/arrow-misc.imp
----------------------------------------------------------------------
diff --git a/cpp/build-support/iwyu/mappings/arrow-misc.imp b/cpp/build-support/iwyu/mappings/arrow-misc.imp
new file mode 100644
index 0000000..7d9f09c
--- /dev/null
+++ b/cpp/build-support/iwyu/mappings/arrow-misc.imp
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+[
+  { symbol: ["bool", private, "<cstdint>", public ] },
+  { symbol: ["false", private, "<cstdint>", public ] },
+  { symbol: ["true", private, "<cstdint>", public ] },
+  { symbol: ["int64_t", private, "<cstdint>", public ] },
+  { symbol: ["int16_t", private, "<cstdint>", public ] },
+  { symbol: ["int32_t", private, "<cstdint>", public ] },
+  { symbol: ["uint8_t", private, "<cstdint>", public ] },
+  { symbol: ["_Node_const_iterator", private, "<flatbuffers/flatbuffers.h>", public ] },
+  { symbol: ["unordered_map<>::mapped_type", private, "<flatbuffers/flatbuffers.h>", public ] },
+  { symbol: ["__alloc_traits<>::value_type", private, "<vector>", public ] },
+  { symbol: ["move", private, "<utility>", public ] },
+  { symbol: ["pair", private, "<utility>", public ] },
+  { symbol: ["errno", private, "<cerrno>", public ] },
+  { symbol: ["posix_memalign", private, "<cstdlib>", public ] }
+]

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/allocator-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/allocator-test.cc b/cpp/src/arrow/allocator-test.cc
index f3a80cd..e02741e 100644
--- a/cpp/src/arrow/allocator-test.cc
+++ b/cpp/src/arrow/allocator-test.cc
@@ -15,10 +15,14 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "gtest/gtest.h"
+#include <cstdint>
+#include <limits>
+#include <new>
+
+#include <gtest/gtest.h>
 
 #include "arrow/allocator.h"
-#include "arrow/test-util.h"
+#include "arrow/memory_pool.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/array-decimal-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/array-decimal-test.cc b/cpp/src/arrow/array-decimal-test.cc
index 37852a3..7bbf2f0 100644
--- a/cpp/src/arrow/array-decimal-test.cc
+++ b/cpp/src/arrow/array-decimal-test.cc
@@ -15,14 +15,28 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "arrow/type.h"
-#include "gtest/gtest.h"
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <vector>
+
+#include <gtest/gtest.h>
 
+#include "arrow/array.h"
 #include "arrow/builder.h"
+#include "arrow/memory_pool.h"
+#include "arrow/status.h"
 #include "arrow/test-util.h"
+#include "arrow/type.h"
+#include "arrow/util/bit-util.h"
 #include "arrow/util/decimal.h"
 
+using std::size_t;
+
 namespace arrow {
+
+class Buffer;
+
 namespace decimal {
 
 template <typename T>

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/buffer-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/buffer-test.cc b/cpp/src/arrow/buffer-test.cc
index 30c4672..334ad7b 100644
--- a/cpp/src/arrow/buffer-test.cc
+++ b/cpp/src/arrow/buffer-test.cc
@@ -16,12 +16,15 @@
 // under the License.
 
 #include <cstdint>
+#include <cstring>
 #include <limits>
+#include <memory>
 #include <string>
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
 #include "arrow/buffer.h"
+#include "arrow/memory_pool.h"
 #include "arrow/status.h"
 #include "arrow/test-util.h"
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/buffer.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/buffer.cc b/cpp/src/arrow/buffer.cc
index d60c829..cf533eb 100644
--- a/cpp/src/arrow/buffer.cc
+++ b/cpp/src/arrow/buffer.cc
@@ -18,7 +18,6 @@
 #include "arrow/buffer.h"
 
 #include <cstdint>
-#include <limits>
 
 #include "arrow/memory_pool.h"
 #include "arrow/status.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/buffer.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/buffer.h b/cpp/src/arrow/buffer.h
index 859fa80..ed128fd 100644
--- a/cpp/src/arrow/buffer.h
+++ b/cpp/src/arrow/buffer.h
@@ -18,11 +18,11 @@
 #ifndef ARROW_BUFFER_H
 #define ARROW_BUFFER_H
 
-#include <algorithm>
 #include <cstdint>
 #include <cstring>
 #include <memory>
 #include <string>
+#include <type_traits>
 
 #include "arrow/status.h"
 #include "arrow/util/bit-util.h"
@@ -32,7 +32,6 @@
 namespace arrow {
 
 class MemoryPool;
-class Status;
 
 // ----------------------------------------------------------------------
 // Buffer classes

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/file.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/file.cc b/cpp/src/arrow/io/file.cc
index 3957852..0abadbb 100644
--- a/cpp/src/arrow/io/file.cc
+++ b/cpp/src/arrow/io/file.cc
@@ -45,9 +45,21 @@
 #include <sys/mman.h>
 #endif
 
+#include <algorithm>
+#include <cerrno>
+#include <cstdint>
+#include <cstring>
+#include <mutex>
+#include <sstream>  // IWYU pragma: keep
+
+#if defined(_MSC_VER)
+#include <codecvt>
+#include <locale>
+#endif
+
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <sys/types.h>
+#include <sys/types.h>  // IWYU pragma: keep
 
 #ifndef _MSC_VER  // POSIX-like platforms
 
@@ -70,22 +82,6 @@
 #endif
 
 // ----------------------------------------------------------------------
-// C++ standard library
-
-#include <algorithm>
-#include <cstring>
-#include <iostream>
-#include <limits>
-#include <mutex>
-#include <sstream>
-#include <vector>
-
-#if defined(_MSC_VER)
-#include <codecvt>
-#include <locale>
-#endif
-
-// ----------------------------------------------------------------------
 // file compatibility stuff
 
 #if defined(__MINGW32__)  // MinGW
@@ -96,8 +92,6 @@
 // nothing
 #endif
 
-#include <cstdio>
-
 // POSIX systems do not have this
 #ifndef O_BINARY
 #define O_BINARY 0
@@ -113,7 +107,8 @@
 #include "arrow/status.h"
 #include "arrow/util/logging.h"
 
-#include <boost/filesystem.hpp>  // NOLINT
+#include <boost/filesystem.hpp>           // NOLINT
+#include <boost/system/system_error.hpp>  // NOLINT
 
 namespace fs = boost::filesystem;
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/file.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/file.h b/cpp/src/arrow/io/file.h
index f26d905..1b1bbe0 100644
--- a/cpp/src/arrow/io/file.h
+++ b/cpp/src/arrow/io/file.h
@@ -25,7 +25,6 @@
 #include <string>
 
 #include "arrow/io/interfaces.h"
-#include "arrow/util/macros.h"
 #include "arrow/util/visibility.h"
 
 namespace arrow {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/hdfs-internal.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/hdfs-internal.cc b/cpp/src/arrow/io/hdfs-internal.cc
index 35657df..e6d0487 100644
--- a/cpp/src/arrow/io/hdfs-internal.cc
+++ b/cpp/src/arrow/io/hdfs-internal.cc
@@ -30,17 +30,20 @@
 
 #include "arrow/io/hdfs-internal.h"
 
-#include <iostream>
+#include <cstdint>
+#include <cstdlib>
 #include <mutex>
-#include <sstream>
+#include <sstream>  // IWYU pragma: keep
 #include <string>
-#include <type_traits>
 #include <vector>
 
+#ifndef _WIN32
+#include <dlfcn.h>
+#endif
+
 #include <boost/filesystem.hpp>  // NOLINT
 
 #include "arrow/status.h"
-#include "arrow/util/visibility.h"
 
 namespace fs = boost::filesystem;
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/hdfs-internal.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/hdfs-internal.h b/cpp/src/arrow/io/hdfs-internal.h
index f2de00d..df925cf 100644
--- a/cpp/src/arrow/io/hdfs-internal.h
+++ b/cpp/src/arrow/io/hdfs-internal.h
@@ -18,15 +18,18 @@
 #ifndef ARROW_IO_HDFS_INTERNAL
 #define ARROW_IO_HDFS_INTERNAL
 
-#ifndef _WIN32
-#include <dlfcn.h>
-#endif
+#include <cstddef>
+#include <cstdint>
 
 #include <hdfs.h>
 
-#include "arrow/io/windows_compatibility.h"
+#include "arrow/io/windows_compatibility.h"  // IWYU pragma: keep
 #include "arrow/util/visibility.h"
 
+using std::size_t;
+
+struct hdfsBuilder;
+
 namespace arrow {
 
 class Status;

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/hdfs.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/hdfs.cc b/cpp/src/arrow/io/hdfs.cc
index 8b143c3..d9d4206 100644
--- a/cpp/src/arrow/io/hdfs.cc
+++ b/cpp/src/arrow/io/hdfs.cc
@@ -18,7 +18,10 @@
 #include <hdfs.h>
 
 #include <algorithm>
+#include <cerrno>
+#include <cstddef>
 #include <cstdint>
+#include <mutex>
 #include <sstream>
 #include <string>
 
@@ -29,6 +32,8 @@
 #include "arrow/status.h"
 #include "arrow/util/logging.h"
 
+using std::size_t;
+
 namespace arrow {
 namespace io {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/hdfs.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/hdfs.h b/cpp/src/arrow/io/hdfs.h
index 82e3f71..f5ed082 100644
--- a/cpp/src/arrow/io/hdfs.h
+++ b/cpp/src/arrow/io/hdfs.h
@@ -30,11 +30,11 @@
 namespace arrow {
 
 class Buffer;
+class MemoryPool;
 class Status;
 
 namespace io {
 
-class HadoopFileSystem;
 class HdfsReadableFile;
 class HdfsOutputStream;
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/interfaces.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/interfaces.cc b/cpp/src/arrow/io/interfaces.cc
index 57dc42d..694575b 100644
--- a/cpp/src/arrow/io/interfaces.cc
+++ b/cpp/src/arrow/io/interfaces.cc
@@ -21,7 +21,6 @@
 #include <memory>
 #include <mutex>
 
-#include "arrow/buffer.h"
 #include "arrow/status.h"
 
 namespace arrow {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/interfaces.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/interfaces.h b/cpp/src/arrow/io/interfaces.h
index 3388acb..dd3f32d 100644
--- a/cpp/src/arrow/io/interfaces.h
+++ b/cpp/src/arrow/io/interfaces.h
@@ -30,7 +30,6 @@
 namespace arrow {
 
 class Buffer;
-class MemoryPool;
 class Status;
 
 namespace io {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/io-file-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/io-file-test.cc b/cpp/src/arrow/io/io-file-test.cc
index 630356f..636fbd8 100644
--- a/cpp/src/arrow/io/io-file-test.cc
+++ b/cpp/src/arrow/io/io-file-test.cc
@@ -16,23 +16,31 @@
 // under the License.
 
 #include <atomic>
+#include <cerrno>
 #include <cstdint>
 #include <cstdio>
+#include <cstdlib>
 #include <cstring>
-#ifndef _MSC_VER
-#include <fcntl.h>
-#endif
-#include <fstream>
+#include <fstream>  // IWYU pragma: keep
 #include <memory>
-#include <sstream>
+#include <sstream>  // IWYU pragma: keep
 #include <string>
 #include <thread>
+#include <vector>
+
+#ifndef _MSC_VER
+#include <fcntl.h>
+#endif
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
+#include "arrow/buffer.h"
 #include "arrow/io/file.h"
+#include "arrow/io/interfaces.h"
 #include "arrow/io/test-common.h"
 #include "arrow/memory_pool.h"
+#include "arrow/status.h"
+#include "arrow/test-util.h"
 
 namespace arrow {
 namespace io {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/io-hdfs-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/io-hdfs-test.cc b/cpp/src/arrow/io/io-hdfs-test.cc
index b88ca8f..eaf638f 100644
--- a/cpp/src/arrow/io/io-hdfs-test.cc
+++ b/cpp/src/arrow/io/io-hdfs-test.cc
@@ -15,18 +15,25 @@
 // specific language governing permissions and limitations
 // under the License.
 
+#include <atomic>
+#include <cstdint>
 #include <cstdlib>
+#include <cstring>
 #include <iostream>
-#include <sstream>
+#include <memory>
+#include <sstream>  // IWYU pragma: keep
 #include <string>
 #include <thread>
+#include <vector>
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
 #include <boost/filesystem.hpp>  // NOLINT
 
+#include "arrow/buffer.h"
 #include "arrow/io/hdfs-internal.h"
 #include "arrow/io/hdfs.h"
+#include "arrow/io/interfaces.h"
 #include "arrow/status.h"
 #include "arrow/test-util.h"
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/io-memory-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/io-memory-test.cc b/cpp/src/arrow/io/io-memory-test.cc
index fadcfc3..117972f 100644
--- a/cpp/src/arrow/io/io-memory-test.cc
+++ b/cpp/src/arrow/io/io-memory-test.cc
@@ -16,17 +16,19 @@
 // under the License.
 
 #include <cstdint>
-#include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <memory>
 #include <string>
-#include <vector>
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
+#include "arrow/buffer.h"
+#include "arrow/io/interfaces.h"
 #include "arrow/io/memory.h"
-#include "arrow/io/test-common.h"
+#include "arrow/memory_pool.h"
+#include "arrow/status.h"
+#include "arrow/test-util.h"
 
 namespace arrow {
 namespace io {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/memory.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/memory.cc b/cpp/src/arrow/io/memory.cc
index 568d7b2..0b91ab5 100644
--- a/cpp/src/arrow/io/memory.cc
+++ b/cpp/src/arrow/io/memory.cc
@@ -18,17 +18,13 @@
 #include "arrow/io/memory.h"
 
 #include <algorithm>
-#include <cerrno>
 #include <cstdint>
-#include <cstdio>
 #include <cstring>
-#include <sstream>
-#include <string>
 
 #include "arrow/buffer.h"
-#include "arrow/io/interfaces.h"
 #include "arrow/status.h"
 #include "arrow/util/logging.h"
+#include "arrow/util/macros.h"
 #include "arrow/util/memory.h"
 
 namespace arrow {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/io/memory.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/memory.h b/cpp/src/arrow/io/memory.h
index ab8d103..563000f 100644
--- a/cpp/src/arrow/io/memory.h
+++ b/cpp/src/arrow/io/memory.h
@@ -23,16 +23,14 @@
 #include <cstdint>
 #include <memory>
 #include <mutex>
-#include <string>
 
 #include "arrow/io/interfaces.h"
-
-#include "arrow/util/macros.h"
 #include "arrow/util/visibility.h"
 
 namespace arrow {
 
 class Buffer;
+class MemoryPool;
 class ResizableBuffer;
 class Status;
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/dictionary.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/dictionary.cc b/cpp/src/arrow/ipc/dictionary.cc
index fcfb3e2..488bb75 100644
--- a/cpp/src/arrow/ipc/dictionary.cc
+++ b/cpp/src/arrow/ipc/dictionary.cc
@@ -20,10 +20,9 @@
 #include <cstdint>
 #include <memory>
 #include <sstream>
+#include <utility>
 
-#include "arrow/array.h"
 #include "arrow/status.h"
-#include "arrow/type.h"
 
 namespace arrow {
 namespace ipc {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/dictionary.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/dictionary.h b/cpp/src/arrow/ipc/dictionary.h
index 744ab64..13cf7a0 100644
--- a/cpp/src/arrow/ipc/dictionary.h
+++ b/cpp/src/arrow/ipc/dictionary.h
@@ -22,9 +22,7 @@
 
 #include <cstdint>
 #include <memory>
-#include <string>
 #include <unordered_map>
-#include <vector>
 
 #include "arrow/status.h"
 #include "arrow/util/macros.h"
@@ -33,17 +31,8 @@
 namespace arrow {
 
 class Array;
-class Buffer;
 class Field;
 
-namespace io {
-
-class InputStream;
-class OutputStream;
-class RandomAccessFile;
-
-}  // namespace io
-
 namespace ipc {
 
 using DictionaryMap = std::unordered_map<int64_t, std::shared_ptr<Array>>;

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/feather-internal.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/feather-internal.h b/cpp/src/arrow/ipc/feather-internal.h
index 1b5924e..90512dd 100644
--- a/cpp/src/arrow/ipc/feather-internal.h
+++ b/cpp/src/arrow/ipc/feather-internal.h
@@ -22,6 +22,7 @@
 #define ARROW_IPC_FEATHER_INTERNAL_H
 
 #include <cstdint>
+#include <iostream>
 #include <memory>
 #include <string>
 #include <vector>

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/feather.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/feather.cc b/cpp/src/arrow/ipc/feather.cc
index 54771d3..5c6e252 100644
--- a/cpp/src/arrow/ipc/feather.cc
+++ b/cpp/src/arrow/ipc/feather.cc
@@ -17,12 +17,10 @@
 
 #include "arrow/ipc/feather.h"
 
-#include <algorithm>
 #include <cstdint>
 #include <cstring>
-#include <iostream>
 #include <memory>
-#include <sstream>
+#include <sstream>  // IWYU pragma: keep
 #include <string>
 #include <vector>
 
@@ -30,13 +28,16 @@
 
 #include "arrow/array.h"
 #include "arrow/buffer.h"
-#include "arrow/io/file.h"
+#include "arrow/io/interfaces.h"
 #include "arrow/ipc/feather-internal.h"
 #include "arrow/ipc/feather_generated.h"
+#include "arrow/ipc/util.h"  // IWYU pragma: keep
 #include "arrow/status.h"
 #include "arrow/table.h"
+#include "arrow/type.h"
 #include "arrow/util/bit-util.h"
 #include "arrow/util/logging.h"
+#include "arrow/visitor.h"
 
 namespace arrow {
 namespace ipc {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/feather.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/feather.h b/cpp/src/arrow/ipc/feather.h
index 2ab35a9..83cd151 100644
--- a/cpp/src/arrow/ipc/feather.h
+++ b/cpp/src/arrow/ipc/feather.h
@@ -24,14 +24,12 @@
 #include <cstdint>
 #include <memory>
 #include <string>
-#include <vector>
 
-#include "arrow/type.h"
 #include "arrow/util/visibility.h"
 
 namespace arrow {
 
-class Buffer;
+class Array;
 class Column;
 class Status;
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/file-to-stream.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/file-to-stream.cc b/cpp/src/arrow/ipc/file-to-stream.cc
index e69444a..c5f0eb3 100644
--- a/cpp/src/arrow/ipc/file-to-stream.cc
+++ b/cpp/src/arrow/ipc/file-to-stream.cc
@@ -16,6 +16,9 @@
 // under the License.
 
 #include <iostream>
+#include <memory>
+#include <string>
+
 #include "arrow/io/file.h"
 #include "arrow/ipc/reader.h"
 #include "arrow/ipc/writer.h"
@@ -24,6 +27,9 @@
 #include "arrow/util/io-util.h"
 
 namespace arrow {
+
+class RecordBatch;
+
 namespace ipc {
 
 // Reads a file on the file system and prints to stdout the stream version of it.

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/json-integration-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/json-integration-test.cc b/cpp/src/arrow/ipc/json-integration-test.cc
index e0f01f9..4a3b2b3 100644
--- a/cpp/src/arrow/ipc/json-integration-test.cc
+++ b/cpp/src/arrow/ipc/json-integration-test.cc
@@ -15,16 +15,17 @@
 // specific language governing permissions and limitations
 // under the License.
 
+#include <cstdint>
 #include <cstdio>
-#include <cstdlib>
 #include <cstring>
-#include <fstream>
+#include <fstream>  // IWYU pragma: keep
 #include <iostream>
 #include <memory>
 #include <string>
+#include <vector>
 
-#include "gflags/gflags.h"
-#include "gtest/gtest.h"
+#include <gflags/gflags.h>
+#include <gtest/gtest.h>
 
 #include <boost/filesystem.hpp>  // NOLINT
 
@@ -50,6 +51,8 @@ namespace fs = boost::filesystem;
 
 namespace arrow {
 
+class Buffer;
+
 bool file_exists(const char* path) {
   std::ifstream handle(path);
   return handle.good();

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/json-internal.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/json-internal.cc b/cpp/src/arrow/ipc/json-internal.cc
index 80244f6..f0fb963 100644
--- a/cpp/src/arrow/ipc/json-internal.cc
+++ b/cpp/src/arrow/ipc/json-internal.cc
@@ -17,23 +17,17 @@
 
 #include "arrow/ipc/json-internal.h"
 
-#include <algorithm>
 #include <cstdint>
 #include <cstdlib>
-#include <iostream>
 #include <memory>
 #include <sstream>
 #include <string>
 #include <type_traits>
 #include <vector>
 
-#include "rapidjson/stringbuffer.h"
-#include "rapidjson/writer.h"
-
 #include "arrow/array.h"
 #include "arrow/builder.h"
-#include "arrow/ipc/metadata-internal.h"
-#include "arrow/memory_pool.h"
+#include "arrow/ipc/dictionary.h"
 #include "arrow/status.h"
 #include "arrow/table.h"
 #include "arrow/type.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/json-internal.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/json-internal.h b/cpp/src/arrow/ipc/json-internal.h
index 9b641cd..506fe68 100644
--- a/cpp/src/arrow/ipc/json-internal.h
+++ b/cpp/src/arrow/ipc/json-internal.h
@@ -30,7 +30,7 @@
 #include "rapidjson/stringbuffer.h"
 #include "rapidjson/writer.h"
 
-#include "arrow/type_fwd.h"
+#include "arrow/type_fwd.h"  // IWYU pragma: export
 #include "arrow/util/visibility.h"
 
 namespace rj = rapidjson;

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/json.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/json.cc b/cpp/src/arrow/ipc/json.cc
index f57101a..30a1bb8 100644
--- a/cpp/src/arrow/ipc/json.cc
+++ b/cpp/src/arrow/ipc/json.cc
@@ -17,12 +17,10 @@
 
 #include "arrow/ipc/json.h"
 
-#include <cstdint>
+#include <cstddef>
 #include <memory>
 #include <string>
-#include <vector>
 
-#include "arrow/array.h"
 #include "arrow/buffer.h"
 #include "arrow/ipc/json-internal.h"
 #include "arrow/memory_pool.h"
@@ -31,6 +29,8 @@
 #include "arrow/type.h"
 #include "arrow/util/logging.h"
 
+using std::size_t;
+
 namespace arrow {
 namespace ipc {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/json.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/json.h b/cpp/src/arrow/ipc/json.h
index be26f02..0391172 100644
--- a/cpp/src/arrow/ipc/json.h
+++ b/cpp/src/arrow/ipc/json.h
@@ -22,18 +22,16 @@
 
 #include <memory>
 #include <string>
-#include <vector>
 
-#include "arrow/type_fwd.h"
+#include "arrow/status.h"
 #include "arrow/util/visibility.h"
 
 namespace arrow {
-namespace io {
 
-class OutputStream;
-class RandomAccessFile;
-
-}  // namespace io
+class Buffer;
+class MemoryPool;
+class RecordBatch;
+class Schema;
 
 namespace ipc {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/message.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/message.cc b/cpp/src/arrow/ipc/message.cc
index 53f0203..082c925 100644
--- a/cpp/src/arrow/ipc/message.cc
+++ b/cpp/src/arrow/ipc/message.cc
@@ -22,17 +22,13 @@
 #include <memory>
 #include <sstream>
 #include <string>
-#include <vector>
 
-#include "arrow/array.h"
 #include "arrow/buffer.h"
 #include "arrow/io/interfaces.h"
+#include "arrow/ipc/Message_generated.h"
+#include "arrow/ipc/Schema_generated.h"
 #include "arrow/ipc/metadata-internal.h"
-#include "arrow/ipc/util.h"
 #include "arrow/status.h"
-#include "arrow/tensor.h"
-#include "arrow/type.h"
-#include "arrow/util/logging.h"
 
 namespace arrow {
 namespace ipc {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/message.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/message.h b/cpp/src/arrow/ipc/message.h
index dbc50d8..6fb8de7 100644
--- a/cpp/src/arrow/ipc/message.h
+++ b/cpp/src/arrow/ipc/message.h
@@ -23,8 +23,6 @@
 #include <cstdint>
 #include <memory>
 #include <string>
-#include <unordered_map>
-#include <vector>
 
 #include "arrow/status.h"
 #include "arrow/util/macros.h"
@@ -32,9 +30,7 @@
 
 namespace arrow {
 
-class Array;
 class Buffer;
-class Field;
 
 namespace io {
 
@@ -57,8 +53,6 @@ constexpr int kMaxNestingDepth = 64;
 // individual fields metadata can be retrieved from very large schema without
 //
 
-class Message;
-
 /// \brief An IPC message including metadata and body
 class ARROW_EXPORT Message {
  public:

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/metadata-internal.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/metadata-internal.cc b/cpp/src/arrow/ipc/metadata-internal.cc
index 928e889..1f2340d 100644
--- a/cpp/src/arrow/ipc/metadata-internal.cc
+++ b/cpp/src/arrow/ipc/metadata-internal.cc
@@ -17,22 +17,28 @@
 
 #include "arrow/ipc/metadata-internal.h"
 
-#include <algorithm>
 #include <cstdint>
+#include <cstring>
 #include <memory>
 #include <sstream>
 #include <string>
-#include <vector>
+#include <utility>
 
-#include "flatbuffers/flatbuffers.h"
+#include <flatbuffers/flatbuffers.h>
 
 #include "arrow/array.h"
 #include "arrow/buffer.h"
 #include "arrow/io/interfaces.h"
+#include "arrow/ipc/File_generated.h"
+#include "arrow/ipc/Message_generated.h"
+#include "arrow/ipc/Tensor_generated.h"
+#include "arrow/ipc/dictionary.h"
 #include "arrow/ipc/util.h"
 #include "arrow/status.h"
 #include "arrow/tensor.h"
 #include "arrow/type.h"
+#include "arrow/util/bit-util.h"
+#include "arrow/util/key_value_metadata.h"
 #include "arrow/util/logging.h"
 
 namespace arrow {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/metadata-internal.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/metadata-internal.h b/cpp/src/arrow/ipc/metadata-internal.h
index 738ed3c..83d1f13 100644
--- a/cpp/src/arrow/ipc/metadata-internal.h
+++ b/cpp/src/arrow/ipc/metadata-internal.h
@@ -23,23 +23,15 @@
 #include <cstdint>
 #include <memory>
 #include <string>
-#include <unordered_map>
 #include <vector>
 
-#include "arrow/ipc/File_generated.h"
-#include "arrow/ipc/Message_generated.h"
-#include "arrow/ipc/Tensor_generated.h"
+#include "arrow/ipc/Schema_generated.h"
 #include "arrow/ipc/dictionary.h"
-#include "arrow/ipc/message.h"
-#include "arrow/util/macros.h"
-#include "arrow/util/visibility.h"
 
 namespace arrow {
 
-class Array;
 class Buffer;
 class DataType;
-class Field;
 class Schema;
 class Status;
 class Tensor;
@@ -48,9 +40,7 @@ namespace flatbuf = org::apache::arrow::flatbuf;
 
 namespace io {
 
-class InputStream;
 class OutputStream;
-class RandomAccessFile;
 
 }  // namespace io
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/reader.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/reader.cc b/cpp/src/arrow/ipc/reader.cc
index 7d7acad..a4cac0b 100644
--- a/cpp/src/arrow/ipc/reader.cc
+++ b/cpp/src/arrow/ipc/reader.cc
@@ -21,13 +21,19 @@
 #include <cstring>
 #include <sstream>
 #include <string>
+#include <type_traits>
 #include <vector>
 
+#include <flatbuffers/flatbuffers.h>  // IWYU pragma: export
+
+#include "arrow/array.h"
 #include "arrow/buffer.h"
 #include "arrow/io/interfaces.h"
 #include "arrow/io/memory.h"
 #include "arrow/ipc/File_generated.h"
 #include "arrow/ipc/Message_generated.h"
+#include "arrow/ipc/Schema_generated.h"
+#include "arrow/ipc/dictionary.h"
 #include "arrow/ipc/message.h"
 #include "arrow/ipc/metadata-internal.h"
 #include "arrow/ipc/util.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/reader.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/reader.h b/cpp/src/arrow/ipc/reader.h
index f822a32..52b04ab 100644
--- a/cpp/src/arrow/ipc/reader.h
+++ b/cpp/src/arrow/ipc/reader.h
@@ -22,7 +22,6 @@
 
 #include <cstdint>
 #include <memory>
-#include <vector>
 
 #include "arrow/ipc/message.h"
 #include "arrow/util/visibility.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/ipc/stream-to-file.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/ipc/stream-to-file.cc b/cpp/src/arrow/ipc/stream-to-file.cc
index 96339c8..4f8cd80 100644
--- a/cpp/src/arrow/ipc/stream-to-file.cc
+++ b/cpp/src/arrow/ipc/stream-to-file.cc
@@ -16,7 +16,9 @@
 // under the License.
 
 #include <iostream>
-#include "arrow/io/file.h"
+#include <memory>
+#include <string>
+
 #include "arrow/ipc/reader.h"
 #include "arrow/ipc/writer.h"
 #include "arrow/status.h"
@@ -24,6 +26,9 @@
 #include "arrow/util/io-util.h"
 
 namespace arrow {
+
+class RecordBatch;
+
 namespace ipc {
 
 // Converts a stream from stdin to a file written to standard out.

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/memory_pool-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/memory_pool-test.cc b/cpp/src/arrow/memory_pool-test.cc
index 52e48db..552c79b 100644
--- a/cpp/src/arrow/memory_pool-test.cc
+++ b/cpp/src/arrow/memory_pool-test.cc
@@ -15,10 +15,13 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "arrow/memory_pool-test.h"
-
 #include <cstdint>
-#include <limits>
+
+#include <gtest/gtest.h>
+
+#include "arrow/memory_pool-test.h"
+#include "arrow/memory_pool.h"
+#include "arrow/status.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/memory_pool-test.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/memory_pool-test.h b/cpp/src/arrow/memory_pool-test.h
index b9f0337..ced59bf 100644
--- a/cpp/src/arrow/memory_pool-test.h
+++ b/cpp/src/arrow/memory_pool-test.h
@@ -15,11 +15,13 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "gtest/gtest.h"
-
+#include <cstdint>
 #include <limits>
 
+#include <gtest/gtest.h>
+
 #include "arrow/memory_pool.h"
+#include "arrow/status.h"
 #include "arrow/test-util.h"
 
 namespace arrow {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/memory_pool.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/memory_pool.cc b/cpp/src/arrow/memory_pool.cc
index 769fc10..b5b4461 100644
--- a/cpp/src/arrow/memory_pool.cc
+++ b/cpp/src/arrow/memory_pool.cc
@@ -17,12 +17,13 @@
 
 #include "arrow/memory_pool.h"
 
-#include <stdlib.h>
 #include <algorithm>
+#include <cerrno>
 #include <cstdlib>
+#include <cstring>
 #include <iostream>
 #include <mutex>
-#include <sstream>
+#include <sstream>  // IWYU pragma: keep
 
 #include "arrow/status.h"
 #include "arrow/util/logging.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/python/pandas_to_arrow.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/python/pandas_to_arrow.cc b/cpp/src/arrow/python/pandas_to_arrow.cc
index 8f6746a..435682c 100644
--- a/cpp/src/arrow/python/pandas_to_arrow.cc
+++ b/cpp/src/arrow/python/pandas_to_arrow.cc
@@ -515,7 +515,7 @@ inline Status PandasConverter::ConvertData<Date32Type>(std::shared_ptr<Buffer>*
       CopyStrided(input, length_, stride_elements, output);
     } else {
       // TODO(wesm): int32 overflow checks
-      for (int64_t i= 0; i < length_; ++i) {
+      for (int64_t i = 0; i < length_; ++i) {
         *output++ = static_cast<int32_t>(*input++);
       }
     }

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/status-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/status-test.cc b/cpp/src/arrow/status-test.cc
index f32eb15..d4f84e4 100644
--- a/cpp/src/arrow/status-test.cc
+++ b/cpp/src/arrow/status-test.cc
@@ -17,10 +17,9 @@
 
 #include <sstream>
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
 #include "arrow/status.h"
-#include "arrow/test-util.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/status.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/status.h b/cpp/src/arrow/status.h
index d52addf..7a39d0f 100644
--- a/cpp/src/arrow/status.h
+++ b/cpp/src/arrow/status.h
@@ -15,8 +15,8 @@
 #ifndef ARROW_STATUS_H_
 #define ARROW_STATUS_H_
 
-#include <cstdint>
 #include <cstring>
+#include <iosfwd>
 #include <string>
 
 #include "arrow/util/macros.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/table.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/table.h b/cpp/src/arrow/table.h
index 31ca97a..ceb564d 100644
--- a/cpp/src/arrow/table.h
+++ b/cpp/src/arrow/table.h
@@ -29,15 +29,7 @@
 
 namespace arrow {
 
-namespace internal {
-
-struct ArrayData;
-
-}  // namespace internal
-
-class Array;
-class Column;
-class Schema;
+class KeyValueMetadata;
 class Status;
 
 using ArrayVector = std::vector<std::shared_ptr<Array>>;

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/tensor-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/tensor-test.cc b/cpp/src/arrow/tensor-test.cc
index 3df0e6c..0681576 100644
--- a/cpp/src/arrow/tensor-test.cc
+++ b/cpp/src/arrow/tensor-test.cc
@@ -17,13 +17,15 @@
 
 // Unit tests for DataType (and subclasses), Field, and Schema
 
+#include <cstdint>
 #include <memory>
 #include <string>
 #include <vector>
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
 #include "arrow/buffer.h"
+#include "arrow/memory_pool.h"
 #include "arrow/tensor.h"
 #include "arrow/test-util.h"
 #include "arrow/type.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/tensor.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/tensor.cc b/cpp/src/arrow/tensor.cc
index 31b1a35..efadd7c 100644
--- a/cpp/src/arrow/tensor.cc
+++ b/cpp/src/arrow/tensor.cc
@@ -17,7 +17,6 @@
 
 #include "arrow/tensor.h"
 
-#include <algorithm>
 #include <cstdint>
 #include <functional>
 #include <memory>
@@ -25,11 +24,9 @@
 #include <string>
 #include <vector>
 
-#include "arrow/array.h"
-#include "arrow/buffer.h"
 #include "arrow/compare.h"
+#include "arrow/status.h"
 #include "arrow/type.h"
-#include "arrow/type_traits.h"
 #include "arrow/util/logging.h"
 
 namespace arrow {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/tensor.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/tensor.h b/cpp/src/arrow/tensor.h
index bbfd8ae..d1cd3cf 100644
--- a/cpp/src/arrow/tensor.h
+++ b/cpp/src/arrow/tensor.h
@@ -25,16 +25,11 @@
 
 #include "arrow/buffer.h"
 #include "arrow/type.h"
-#include "arrow/type_traits.h"
 #include "arrow/util/macros.h"
 #include "arrow/util/visibility.h"
 
 namespace arrow {
 
-class Buffer;
-class MemoryPool;
-class Status;
-
 static inline bool is_tensor_supported(Type::type type_id) {
   switch (type_id) {
     case Type::UINT8:

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/type-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/type-test.cc b/cpp/src/arrow/type-test.cc
index 4ac5c85..138f8dd 100644
--- a/cpp/src/arrow/type-test.cc
+++ b/cpp/src/arrow/type-test.cc
@@ -17,14 +17,16 @@
 
 // Unit tests for DataType (and subclasses), Field, and Schema
 
+#include <cstdint>
 #include <memory>
 #include <string>
 #include <vector>
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
 #include "arrow/test-util.h"
 #include "arrow/type.h"
+#include "arrow/util/key_value_metadata.h"
 
 using std::shared_ptr;
 using std::vector;

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/type.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/type.h b/cpp/src/arrow/type.h
index 4cd17bc..7026aee 100644
--- a/cpp/src/arrow/type.h
+++ b/cpp/src/arrow/type.h
@@ -27,7 +27,7 @@
 #include <vector>
 
 #include "arrow/status.h"
-#include "arrow/type_fwd.h"
+#include "arrow/type_fwd.h"  // IWYU pragma: export
 #include "arrow/util/key_value_metadata.h"
 #include "arrow/util/macros.h"
 #include "arrow/util/visibility.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/bit-util-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/bit-util-test.cc b/cpp/src/arrow/util/bit-util-test.cc
index bbe95cf..d838ab9 100644
--- a/cpp/src/arrow/util/bit-util-test.cc
+++ b/cpp/src/arrow/util/bit-util-test.cc
@@ -15,18 +15,20 @@
 // specific language governing permissions and limitations
 // under the License.
 
+#include <climits>
 #include <cstdint>
-#include <cstdio>
-#include <cstdlib>
-#include <iostream>
+#include <cstring>
 #include <limits>
+#include <memory>
 #include <vector>
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
-#include <boost/utility.hpp>
+#include <boost/utility.hpp>  // IWYU pragma: export
 
 #include "arrow/buffer.h"
+#include "arrow/memory_pool.h"
+#include "arrow/status.h"
 #include "arrow/test-util.h"
 #include "arrow/util/bit-stream-utils.h"
 #include "arrow/util/bit-util.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression-test.cc b/cpp/src/arrow/util/compression-test.cc
index 64896dd..6dd518a 100644
--- a/cpp/src/arrow/util/compression-test.cc
+++ b/cpp/src/arrow/util/compression-test.cc
@@ -15,13 +15,14 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include <gtest/gtest.h>
 #include <cstdint>
+#include <memory>
 #include <string>
 #include <vector>
 
-#include "arrow/status.h"
-#include "arrow/test-common.h"
+#include <gtest/gtest.h>
+
+#include "arrow/test-util.h"
 #include "arrow/util/compression.h"
 
 using std::string;

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression.cc b/cpp/src/arrow/util/compression.cc
index b4e5373..bead6ff 100644
--- a/cpp/src/arrow/util/compression.cc
+++ b/cpp/src/arrow/util/compression.cc
@@ -17,10 +17,7 @@
 
 #include "arrow/util/compression.h"
 
-#include <cstdint>
 #include <memory>
-#include <sstream>
-#include <string>
 
 #ifdef ARROW_WITH_BROTLI
 #include "arrow/util/compression_brotli.h"
@@ -43,7 +40,6 @@
 #endif
 
 #include "arrow/status.h"
-#include "arrow/util/logging.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_brotli.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_brotli.cc b/cpp/src/arrow/util/compression_brotli.cc
index e463908..1aaec11 100644
--- a/cpp/src/arrow/util/compression_brotli.cc
+++ b/cpp/src/arrow/util/compression_brotli.cc
@@ -17,16 +17,14 @@
 
 #include "arrow/util/compression_brotli.h"
 
+#include <cstddef>
 #include <cstdint>
-#include <memory>
-#include <sstream>
-#include <string>
 
 #include <brotli/decode.h>
 #include <brotli/encode.h>
+#include <brotli/types.h>
 
 #include "arrow/status.h"
-#include "arrow/util/logging.h"
 
 namespace arrow {
 
@@ -35,7 +33,7 @@ namespace arrow {
 
 Status BrotliCodec::Decompress(int64_t input_len, const uint8_t* input,
                                int64_t output_len, uint8_t* output_buffer) {
-  size_t output_size = output_len;
+  std::size_t output_size = output_len;
   if (BrotliDecoderDecompress(input_len, input, &output_size, output_buffer) !=
       BROTLI_DECODER_RESULT_SUCCESS) {
     return Status::IOError("Corrupt brotli compressed data.");
@@ -50,7 +48,7 @@ int64_t BrotliCodec::MaxCompressedLen(int64_t input_len, const uint8_t* input) {
 Status BrotliCodec::Compress(int64_t input_len, const uint8_t* input,
                              int64_t output_buffer_len, uint8_t* output_buffer,
                              int64_t* output_length) {
-  size_t output_len = output_buffer_len;
+  std::size_t output_len = output_buffer_len;
   // TODO: Make quality configurable. We use 8 as a default as it is the best
   //       trade-off for Parquet workload
   if (BrotliEncoderCompress(8, BROTLI_DEFAULT_WINDOW, BROTLI_DEFAULT_MODE, input_len,

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_brotli.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_brotli.h b/cpp/src/arrow/util/compression_brotli.h
index 9e92cb1..89e979d 100644
--- a/cpp/src/arrow/util/compression_brotli.h
+++ b/cpp/src/arrow/util/compression_brotli.h
@@ -19,10 +19,10 @@
 #define ARROW_UTIL_COMPRESSION_BROTLI_H
 
 #include <cstdint>
-#include <memory>
 
 #include "arrow/status.h"
 #include "arrow/util/compression.h"
+#include "arrow/util/visibility.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_lz4.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_lz4.cc b/cpp/src/arrow/util/compression_lz4.cc
index 295e9a4..cda40ad 100644
--- a/cpp/src/arrow/util/compression_lz4.cc
+++ b/cpp/src/arrow/util/compression_lz4.cc
@@ -18,14 +18,10 @@
 #include "arrow/util/compression_lz4.h"
 
 #include <cstdint>
-#include <memory>
-#include <sstream>
-#include <string>
 
 #include <lz4.h>
 
 #include "arrow/status.h"
-#include "arrow/util/logging.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_lz4.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_lz4.h b/cpp/src/arrow/util/compression_lz4.h
index 0af2289..4ef9c58 100644
--- a/cpp/src/arrow/util/compression_lz4.h
+++ b/cpp/src/arrow/util/compression_lz4.h
@@ -19,10 +19,10 @@
 #define ARROW_UTIL_COMPRESSION_LZ4_H
 
 #include <cstdint>
-#include <memory>
 
 #include "arrow/status.h"
 #include "arrow/util/compression.h"
+#include "arrow/util/visibility.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_snappy.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_snappy.cc b/cpp/src/arrow/util/compression_snappy.cc
index 947ffe5..542831f 100644
--- a/cpp/src/arrow/util/compression_snappy.cc
+++ b/cpp/src/arrow/util/compression_snappy.cc
@@ -22,15 +22,15 @@
 #undef DISALLOW_COPY_AND_ASSIGN
 #endif
 
+#include <cstddef>
 #include <cstdint>
-#include <memory>
-#include <sstream>
-#include <string>
 
 #include <snappy.h>
 
 #include "arrow/status.h"
-#include "arrow/util/logging.h"
+#include "arrow/util/macros.h"
+
+using std::size_t;
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_snappy.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_snappy.h b/cpp/src/arrow/util/compression_snappy.h
index 5cc10c4..1db2165 100644
--- a/cpp/src/arrow/util/compression_snappy.h
+++ b/cpp/src/arrow/util/compression_snappy.h
@@ -19,10 +19,10 @@
 #define ARROW_UTIL_COMPRESSION_SNAPPY_H
 
 #include <cstdint>
-#include <memory>
 
 #include "arrow/status.h"
 #include "arrow/util/compression.h"
+#include "arrow/util/visibility.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_zlib.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_zlib.cc b/cpp/src/arrow/util/compression_zlib.cc
index ae6627e..0656fd6 100644
--- a/cpp/src/arrow/util/compression_zlib.cc
+++ b/cpp/src/arrow/util/compression_zlib.cc
@@ -18,10 +18,12 @@
 #include "arrow/util/compression_zlib.h"
 
 #include <cstdint>
+#include <cstring>
 #include <memory>
 #include <sstream>
 #include <string>
 
+#include <zconf.h>
 #include <zlib.h>
 
 #include "arrow/status.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_zlib.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_zlib.h b/cpp/src/arrow/util/compression_zlib.h
index f55d668..a18af6e 100644
--- a/cpp/src/arrow/util/compression_zlib.h
+++ b/cpp/src/arrow/util/compression_zlib.h
@@ -23,6 +23,7 @@
 
 #include "arrow/status.h"
 #include "arrow/util/compression.h"
+#include "arrow/util/visibility.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_zstd.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_zstd.cc b/cpp/src/arrow/util/compression_zstd.cc
index ac6e906..d19ac43 100644
--- a/cpp/src/arrow/util/compression_zstd.cc
+++ b/cpp/src/arrow/util/compression_zstd.cc
@@ -17,15 +17,14 @@
 
 #include "arrow/util/compression_zstd.h"
 
+#include <cstddef>
 #include <cstdint>
-#include <memory>
-#include <sstream>
-#include <string>
 
 #include <zstd.h>
 
 #include "arrow/status.h"
-#include "arrow/util/logging.h"
+
+using std::size_t;
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/compression_zstd.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_zstd.h b/cpp/src/arrow/util/compression_zstd.h
index 6e40e19..946393d 100644
--- a/cpp/src/arrow/util/compression_zstd.h
+++ b/cpp/src/arrow/util/compression_zstd.h
@@ -19,10 +19,10 @@
 #define ARROW_UTIL_COMPRESSION_ZSTD_H
 
 #include <cstdint>
-#include <memory>
 
 #include "arrow/status.h"
 #include "arrow/util/compression.h"
+#include "arrow/util/visibility.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/cpu-info.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/cpu-info.cc b/cpp/src/arrow/util/cpu-info.cc
index d0a9a14..639f02e 100644
--- a/cpp/src/arrow/util/cpu-info.cc
+++ b/cpp/src/arrow/util/cpu-info.cc
@@ -38,14 +38,13 @@
 
 #endif
 
-#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/algorithm/string/trim.hpp>
 
 #include <algorithm>
 #include <cstdint>
 #include <fstream>
-#include <iostream>
 #include <mutex>
-#include <sstream>
 #include <string>
 
 #include "arrow/util/logging.h"

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/decimal-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/decimal-test.cc b/cpp/src/arrow/util/decimal-test.cc
index fb8833c..ea8962b 100644
--- a/cpp/src/arrow/util/decimal-test.cc
+++ b/cpp/src/arrow/util/decimal-test.cc
@@ -16,11 +16,14 @@
 // under the License.
 //
 
-#include "arrow/util/decimal.h"
+#include <cstdint>
+#include <string>
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
+#include "arrow/status.h"
 #include "arrow/test-util.h"
+#include "arrow/util/decimal.h"
 
 namespace arrow {
 namespace decimal {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/decimal.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/decimal.cc b/cpp/src/arrow/util/decimal.cc
index c195cf3..98768cf 100644
--- a/cpp/src/arrow/util/decimal.cc
+++ b/cpp/src/arrow/util/decimal.cc
@@ -15,9 +15,12 @@
 // specific language governing permissions and limitations
 // under the License.
 
+#include <cctype>
+#include <cmath>
 #include <sstream>
 
 #include "arrow/util/decimal.h"
+#include "arrow/util/int128.h"
 
 namespace arrow {
 namespace decimal {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/decimal.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/decimal.h b/cpp/src/arrow/util/decimal.h
index 88ac2f5..26595ec 100644
--- a/cpp/src/arrow/util/decimal.h
+++ b/cpp/src/arrow/util/decimal.h
@@ -18,15 +18,14 @@
 #ifndef ARROW_DECIMAL_H
 #define ARROW_DECIMAL_H
 
-#include <cmath>
+#include <cstdint>
 #include <cstdlib>
-#include <iterator>
 #include <string>
 
 #include "arrow/status.h"
-#include "arrow/util/bit-util.h"
-#include "arrow/util/int128.h"
+#include "arrow/util/int128.h"  // IWYU pragma: export
 #include "arrow/util/logging.h"
+#include "arrow/util/visibility.h"
 
 namespace arrow {
 namespace decimal {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/int128.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/int128.cc b/cpp/src/arrow/util/int128.cc
index 9d1d062..7102097 100644
--- a/cpp/src/arrow/util/int128.cc
+++ b/cpp/src/arrow/util/int128.cc
@@ -18,9 +18,8 @@
 
 #include <algorithm>
 #include <cmath>
-#include <iomanip>
+#include <cstring>
 #include <limits>
-#include <sstream>
 
 #ifdef _MSC_VER
 #include <intrin.h>

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/int128.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/int128.h b/cpp/src/arrow/util/int128.h
index 1d4bd40..19888ae 100644
--- a/cpp/src/arrow/util/int128.h
+++ b/cpp/src/arrow/util/int128.h
@@ -19,9 +19,11 @@
 #ifndef ARROW_INT128_H
 #define ARROW_INT128_H
 
+#include <cstdint>
 #include <string>
 
 #include "arrow/status.h"
+#include "arrow/util/visibility.h"
 
 namespace arrow {
 namespace decimal {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/key-value-metadata-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/key-value-metadata-test.cc b/cpp/src/arrow/util/key-value-metadata-test.cc
index 59cfdf5..4524b33 100644
--- a/cpp/src/arrow/util/key-value-metadata-test.cc
+++ b/cpp/src/arrow/util/key-value-metadata-test.cc
@@ -15,11 +15,14 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "gtest/gtest.h"
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
 
-#include "arrow/util/key_value_metadata.h"
+#include <gtest/gtest.h>
 
-#include "arrow/test-util.h"
+#include "arrow/util/key_value_metadata.h"
 
 namespace arrow {
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/key_value_metadata.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/key_value_metadata.cc b/cpp/src/arrow/util/key_value_metadata.cc
index 0497f65..cf74ddf 100644
--- a/cpp/src/arrow/util/key_value_metadata.cc
+++ b/cpp/src/arrow/util/key_value_metadata.cc
@@ -16,10 +16,14 @@
 // under the License.
 
 #include <algorithm>
+#include <cstddef>
+#include <utility>
 
 #include "arrow/util/key_value_metadata.h"
 #include "arrow/util/logging.h"
 
+using std::size_t;
+
 namespace arrow {
 
 static std::vector<std::string> UnorderedMapKeys(

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/rle-encoding-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/rle-encoding-test.cc b/cpp/src/arrow/util/rle-encoding-test.cc
index 7549b87..09bcb1a 100644
--- a/cpp/src/arrow/util/rle-encoding-test.cc
+++ b/cpp/src/arrow/util/rle-encoding-test.cc
@@ -15,21 +15,19 @@
 // specific language governing permissions and limitations
 // under the License.
 
-// From Apache Impala as of 2016-01-29
-
-#include <gtest/gtest.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <boost/utility.hpp>
+// From Apache Impala (incubating) as of 2016-01-29
 
 #include <cstdint>
-#include <iostream>
+#include <cstring>
 #include <random>
 #include <vector>
 
+#include <gtest/gtest.h>
+
+#include <boost/utility.hpp>  // IWYU pragma: export
+
 #include "arrow/util/bit-stream-utils.h"
+#include "arrow/util/bit-util.h"
 #include "arrow/util/rle-encoding.h"
 
 using std::vector;

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/util/stl-util-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/stl-util-test.cc b/cpp/src/arrow/util/stl-util-test.cc
index 629eb24..c492647 100644
--- a/cpp/src/arrow/util/stl-util-test.cc
+++ b/cpp/src/arrow/util/stl-util-test.cc
@@ -15,14 +15,11 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "arrow/util/stl.h"
-
-#include <cstdint>
 #include <vector>
 
-#include "gtest/gtest.h"
+#include <gtest/gtest.h>
 
-#include "arrow/test-util.h"
+#include "arrow/util/stl.h"
 
 namespace arrow {
 namespace internal {

http://git-wip-us.apache.org/repos/asf/arrow/blob/1a8dafb2/cpp/src/arrow/visitor.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/visitor.cc b/cpp/src/arrow/visitor.cc
index 203ed6d..53a0fee 100644
--- a/cpp/src/arrow/visitor.cc
+++ b/cpp/src/arrow/visitor.cc
@@ -17,6 +17,8 @@
 
 #include "arrow/visitor.h"
 
+#include <memory>
+
 #include "arrow/array.h"
 #include "arrow/status.h"
 #include "arrow/type.h"


Mime
View raw message