Skip to content

Commit 1a8dafb

Browse files
committed
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 apache#1025 from wesm/ARROW-1447 and squashes the following commits: 67a2002 [Wes McKinney] Fix another include for Windows f6ec09a [Wes McKinney] Fix include error 5d77388 [Wes McKinney] Fix buglet 09b38b0 [Wes McKinney] Add arrow-specific mappings files, fix more things 4968845 [Wes McKinney] Fix a ton of include-what-you-use warnings
1 parent 848a0f7 commit 1a8dafb

75 files changed

Lines changed: 292 additions & 240 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cpp/build-support/iwyu/iwyu-filter.awk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ BEGIN {
6767
# suggestions are addressed and invalid ones are taken care either by proper
6868
# IWYU pragmas or adding special mappings (e.g. like boost mappings).
6969
# muted["relative/path/to/file"]
70+
muted["arrow/util/bit-util-test.cc"]
71+
muted["arrow/util/rle-encoding-test.cc"]
72+
muted["include/hdfs.h"]
73+
muted["arrow/visitor.h"]
7074
}
7175

7276
# mute all suggestions for the auto-generated files

cpp/build-support/iwyu/iwyu.sh

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,15 @@ trap "rm -f $IWYU_LOG" EXIT
2626

2727
echo "Logging IWYU to $IWYU_LOG"
2828

29-
# Build the list of updated files which are of IWYU interest.
30-
file_list_tmp=$(git diff --name-only \
31-
$($ROOT/cpp/build-support/get-upstream-commit.sh) | grep -E '\.(c|cc|h)$')
32-
if [ -z "$file_list_tmp" ]; then
33-
echo "IWYU verification: no updates on related files, declaring success"
34-
exit 0
35-
fi
36-
37-
# Adjust the path for every element in the list. The iwyu_tool.py normalizes
38-
# paths (via realpath) to match the records from the compilation database.
39-
IWYU_FILE_LIST=
40-
for p in $file_list_tmp; do
41-
IWYU_FILE_LIST="$IWYU_FILE_LIST $ROOT/$p"
42-
done
43-
4429
IWYU_MAPPINGS_PATH="$ROOT/cpp/build-support/iwyu/mappings"
4530
IWYU_ARGS="\
4631
--mapping_file=$IWYU_MAPPINGS_PATH/boost-all.imp \
4732
--mapping_file=$IWYU_MAPPINGS_PATH/boost-all-private.imp \
4833
--mapping_file=$IWYU_MAPPINGS_PATH/boost-extra.imp \
4934
--mapping_file=$IWYU_MAPPINGS_PATH/gflags.imp \
5035
--mapping_file=$IWYU_MAPPINGS_PATH/glog.imp \
51-
--mapping_file=$IWYU_MAPPINGS_PATH/gtest.imp"
36+
--mapping_file=$IWYU_MAPPINGS_PATH/gtest.imp \
37+
--mapping_file=$IWYU_MAPPINGS_PATH/arrow-misc.imp"
5238

5339
set -e
5440

@@ -57,6 +43,21 @@ if [ "$1" == "all" ]; then
5743
$IWYU_ARGS | awk -f $ROOT/cpp/build-support/iwyu/iwyu-filter.awk | \
5844
tee $IWYU_LOG
5945
else
46+
# Build the list of updated files which are of IWYU interest.
47+
file_list_tmp=$(git diff --name-only \
48+
$($ROOT/cpp/build-support/get-upstream-commit.sh) | grep -E '\.(c|cc|h)$')
49+
if [ -z "$file_list_tmp" ]; then
50+
echo "IWYU verification: no updates on related files, declaring success"
51+
exit 0
52+
fi
53+
54+
# Adjust the path for every element in the list. The iwyu_tool.py normalizes
55+
# paths (via realpath) to match the records from the compilation database.
56+
IWYU_FILE_LIST=
57+
for p in $file_list_tmp; do
58+
IWYU_FILE_LIST="$IWYU_FILE_LIST $ROOT/$p"
59+
done
60+
6061
python $ROOT/cpp/build-support/iwyu/iwyu_tool.py -p . $IWYU_FILE_LIST -- \
6162
$IWYU_ARGS | awk -f $ROOT/cpp/build-support/iwyu/iwyu-filter.awk | \
6263
tee $IWYU_LOG
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
[
18+
{ symbol: ["bool", private, "<cstdint>", public ] },
19+
{ symbol: ["false", private, "<cstdint>", public ] },
20+
{ symbol: ["true", private, "<cstdint>", public ] },
21+
{ symbol: ["int64_t", private, "<cstdint>", public ] },
22+
{ symbol: ["int16_t", private, "<cstdint>", public ] },
23+
{ symbol: ["int32_t", private, "<cstdint>", public ] },
24+
{ symbol: ["uint8_t", private, "<cstdint>", public ] },
25+
{ symbol: ["_Node_const_iterator", private, "<flatbuffers/flatbuffers.h>", public ] },
26+
{ symbol: ["unordered_map<>::mapped_type", private, "<flatbuffers/flatbuffers.h>", public ] },
27+
{ symbol: ["__alloc_traits<>::value_type", private, "<vector>", public ] },
28+
{ symbol: ["move", private, "<utility>", public ] },
29+
{ symbol: ["pair", private, "<utility>", public ] },
30+
{ symbol: ["errno", private, "<cerrno>", public ] },
31+
{ symbol: ["posix_memalign", private, "<cstdlib>", public ] }
32+
]

cpp/src/arrow/allocator-test.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
#include "gtest/gtest.h"
18+
#include <cstdint>
19+
#include <limits>
20+
#include <new>
21+
22+
#include <gtest/gtest.h>
1923

2024
#include "arrow/allocator.h"
21-
#include "arrow/test-util.h"
25+
#include "arrow/memory_pool.h"
2226

2327
namespace arrow {
2428

cpp/src/arrow/array-decimal-test.cc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,28 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
#include "arrow/type.h"
19-
#include "gtest/gtest.h"
18+
#include <cstddef>
19+
#include <cstdint>
20+
#include <memory>
21+
#include <vector>
22+
23+
#include <gtest/gtest.h>
2024

25+
#include "arrow/array.h"
2126
#include "arrow/builder.h"
27+
#include "arrow/memory_pool.h"
28+
#include "arrow/status.h"
2229
#include "arrow/test-util.h"
30+
#include "arrow/type.h"
31+
#include "arrow/util/bit-util.h"
2332
#include "arrow/util/decimal.h"
2433

34+
using std::size_t;
35+
2536
namespace arrow {
37+
38+
class Buffer;
39+
2640
namespace decimal {
2741

2842
template <typename T>

cpp/src/arrow/buffer-test.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
// under the License.
1717

1818
#include <cstdint>
19+
#include <cstring>
1920
#include <limits>
21+
#include <memory>
2022
#include <string>
2123

22-
#include "gtest/gtest.h"
24+
#include <gtest/gtest.h>
2325

2426
#include "arrow/buffer.h"
27+
#include "arrow/memory_pool.h"
2528
#include "arrow/status.h"
2629
#include "arrow/test-util.h"
2730

cpp/src/arrow/buffer.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "arrow/buffer.h"
1919

2020
#include <cstdint>
21-
#include <limits>
2221

2322
#include "arrow/memory_pool.h"
2423
#include "arrow/status.h"

cpp/src/arrow/buffer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#ifndef ARROW_BUFFER_H
1919
#define ARROW_BUFFER_H
2020

21-
#include <algorithm>
2221
#include <cstdint>
2322
#include <cstring>
2423
#include <memory>
2524
#include <string>
25+
#include <type_traits>
2626

2727
#include "arrow/status.h"
2828
#include "arrow/util/bit-util.h"
@@ -32,7 +32,6 @@
3232
namespace arrow {
3333

3434
class MemoryPool;
35-
class Status;
3635

3736
// ----------------------------------------------------------------------
3837
// Buffer classes

cpp/src/arrow/io/file.cc

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,21 @@
4545
#include <sys/mman.h>
4646
#endif
4747

48+
#include <algorithm>
49+
#include <cerrno>
50+
#include <cstdint>
51+
#include <cstring>
52+
#include <mutex>
53+
#include <sstream> // IWYU pragma: keep
54+
55+
#if defined(_MSC_VER)
56+
#include <codecvt>
57+
#include <locale>
58+
#endif
59+
4860
#include <fcntl.h>
4961
#include <sys/stat.h>
50-
#include <sys/types.h>
62+
#include <sys/types.h> // IWYU pragma: keep
5163

5264
#ifndef _MSC_VER // POSIX-like platforms
5365

@@ -69,22 +81,6 @@
6981
#define ARROW_WRITE_SHMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
7082
#endif
7183

72-
// ----------------------------------------------------------------------
73-
// C++ standard library
74-
75-
#include <algorithm>
76-
#include <cstring>
77-
#include <iostream>
78-
#include <limits>
79-
#include <mutex>
80-
#include <sstream>
81-
#include <vector>
82-
83-
#if defined(_MSC_VER)
84-
#include <codecvt>
85-
#include <locale>
86-
#endif
87-
8884
// ----------------------------------------------------------------------
8985
// file compatibility stuff
9086

@@ -96,8 +92,6 @@
9692
// nothing
9793
#endif
9894

99-
#include <cstdio>
100-
10195
// POSIX systems do not have this
10296
#ifndef O_BINARY
10397
#define O_BINARY 0
@@ -113,7 +107,8 @@
113107
#include "arrow/status.h"
114108
#include "arrow/util/logging.h"
115109

116-
#include <boost/filesystem.hpp> // NOLINT
110+
#include <boost/filesystem.hpp> // NOLINT
111+
#include <boost/system/system_error.hpp> // NOLINT
117112

118113
namespace fs = boost::filesystem;
119114

cpp/src/arrow/io/file.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <string>
2626

2727
#include "arrow/io/interfaces.h"
28-
#include "arrow/util/macros.h"
2928
#include "arrow/util/visibility.h"
3029

3130
namespace arrow {

0 commit comments

Comments
 (0)