Skip to content

Commit b8dc87a

Browse files
wesmkou
authored andcommitted
ARROW-3420: [C++] include-what-you-use cleanups for most of src/arrow, add "iwyu" target to top level docker-compose
You can run IWYU now with `docker-compose run iwyu`. I fixed most of the obvious issues in src/arrow. There are some I couldn't quite figure out. I will leave cleaning src/parquet for a follow up patch. IWYU makes some spurious reports thinking that certain headers can be removed when they cannot. Not sure what's going on there. Author: Wes McKinney <wesm+git@apache.org> Author: Krisztián Szűcs <szucs.krisztian@gmail.com> Closes apache#2713 from wesm/ARROW-3420 and squashes the following commits: 5f1ddb6 <Krisztián Szűcs> check-format c34b707 <Wes McKinney> MSVC fixes 7e25eae <Wes McKinney> Fix more IWYU issues d2b4a66 <Wes McKinney> more IWYU b14d904 <Wes McKinney> Port IWYU setup to docker-compose, initial pass over src/arrow
1 parent c0822bc commit b8dc87a

114 files changed

Lines changed: 549 additions & 285 deletions

File tree

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/mappings/arrow-misc.imp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
[
18+
{ include: ["<ext/new_allocator.h>", private, "<cstddef>", public ] },
1819
{ include: ["<ext/alloc_traits.h>", private, "<memory>", public ] },
1920
{ include: ["<ext/alloc_traits.h>", private, "<condition_variable>", public ] },
2021
{ include: ["<ext/alloc_traits.h>", private, "<deque>", public ] },
@@ -29,6 +30,7 @@
2930
{ include: ["<bits/stdint-intn.h>", private, "<cstdint>", public ] },
3031
{ include: ["<bits/stdint-uintn.h>", private, "<cstdint>", public ] },
3132
{ include: ["<bits/shared_ptr.h>", private, "<memory>", public ] },
33+
{ include: ["<initializer_list>", public, "<vector>", public ] },
3234
{ symbol: ["bool", private, "<cstdint>", public ] },
3335
{ symbol: ["false", private, "<cstdint>", public ] },
3436
{ symbol: ["true", private, "<cstdint>", public ] },
@@ -40,6 +42,9 @@
4042
{ symbol: ["uint16_t", private, "<cstdint>", public ] },
4143
{ symbol: ["uint32_t", private, "<cstdint>", public ] },
4244
{ symbol: ["uint64_t", private, "<cstdint>", public ] },
45+
{ symbol: ["size_t", private, "<cstddef>", public ] },
46+
{ symbol: ["variant", private, "\"arrow/compute/kernel.h\"", public ] },
47+
{ symbol: ["Array", private, "\"arrow/type_fwd.h\"", public ] },
4348
{ symbol: ["make_shared", private, "<memory>", public ] },
4449
{ symbol: ["shared_ptr", private, "<memory>", public ] },
4550
{ symbol: ["_Node_const_iterator", private, "<flatbuffers/flatbuffers.h>", public ] },

cpp/cmake_modules/SetupCxxFlags.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,12 @@ else()
173173
endif()
174174
endif()
175175

176-
# Disable annoying "performance warning" about int-to-bool conversion
177176
if ("${COMPILER_FAMILY}" STREQUAL "msvc")
177+
# Disable annoying "performance warning" about int-to-bool conversion
178178
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /wd4800")
179+
180+
# Disable unchecked iterator warnings, equivalent to /D_SCL_SECURE_NO_WARNINGS
181+
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} /wd4996")
179182
endif()
180183

181184
if ("${COMPILER_FAMILY}" STREQUAL "gcc" AND

cpp/src/arrow/api.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
#ifndef ARROW_API_H
2121
#define ARROW_API_H
2222

23-
#include "arrow/array.h"
24-
#include "arrow/buffer.h"
25-
#include "arrow/builder.h"
26-
#include "arrow/compare.h"
27-
#include "arrow/memory_pool.h"
28-
#include "arrow/pretty_print.h"
29-
#include "arrow/record_batch.h"
30-
#include "arrow/status.h"
31-
#include "arrow/table.h"
32-
#include "arrow/table_builder.h"
33-
#include "arrow/tensor.h"
34-
#include "arrow/type.h"
35-
#include "arrow/visitor.h"
23+
#include "arrow/array.h" // IYWU pragma: export
24+
#include "arrow/buffer.h" // IYWU pragma: export
25+
#include "arrow/builder.h" // IYWU pragma: export
26+
#include "arrow/compare.h" // IYWU pragma: export
27+
#include "arrow/memory_pool.h" // IYWU pragma: export
28+
#include "arrow/pretty_print.h" // IYWU pragma: export
29+
#include "arrow/record_batch.h" // IYWU pragma: export
30+
#include "arrow/status.h" // IYWU pragma: export
31+
#include "arrow/table.h" // IYWU pragma: export
32+
#include "arrow/table_builder.h" // IYWU pragma: export
33+
#include "arrow/tensor.h" // IYWU pragma: export
34+
#include "arrow/type.h" // IYWU pragma: export
35+
#include "arrow/visitor.h" // IYWU pragma: export
3636

3737
/// \brief Top-level namespace for Apache Arrow C++ API
3838
namespace arrow {}

cpp/src/arrow/array-test.cc

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

18+
#include <algorithm>
19+
#include <array>
1820
#include <cstdint>
19-
#include <cstdlib>
21+
#include <cstring>
22+
#include <iterator>
23+
#include <limits>
2024
#include <memory>
2125
#include <numeric>
26+
#include <ostream>
27+
#include <string>
28+
#include <type_traits>
2229
#include <vector>
2330

24-
#include "gtest/gtest.h"
31+
#include <gtest/gtest.h>
2532

2633
#include "arrow/array.h"
2734
#include "arrow/buffer.h"
2835
#include "arrow/builder.h"
2936
#include "arrow/ipc/test-common.h"
3037
#include "arrow/memory_pool.h"
38+
#include "arrow/record_batch.h"
3139
#include "arrow/status.h"
3240
#include "arrow/test-common.h"
3341
#include "arrow/test-util.h"
3442
#include "arrow/type.h"
3543
#include "arrow/type_traits.h"
44+
#include "arrow/util/bit-util.h"
3645
#include "arrow/util/checked_cast.h"
3746
#include "arrow/util/decimal.h"
3847
#include "arrow/util/lazy.h"

cpp/src/arrow/array.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919

2020
#include <algorithm>
2121
#include <cstdint>
22-
#include <cstring>
2322
#include <limits>
24-
#include <set>
2523
#include <sstream>
2624
#include <utility>
2725

2826
#include "arrow/buffer.h"
2927
#include "arrow/compare.h"
3028
#include "arrow/pretty_print.h"
3129
#include "arrow/status.h"
30+
#include "arrow/type.h"
3231
#include "arrow/type_traits.h"
3332
#include "arrow/util/bit-util.h"
3433
#include "arrow/util/checked_cast.h"

cpp/src/arrow/array.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,28 @@
1818
#ifndef ARROW_ARRAY_H
1919
#define ARROW_ARRAY_H
2020

21-
#include <cmath>
21+
#include <cstddef>
2222
#include <cstdint>
23+
#include <iosfwd>
2324
#include <memory>
2425
#include <string>
26+
#include <type_traits>
2527
#include <utility>
2628
#include <vector>
2729

2830
#include "arrow/buffer.h"
2931
#include "arrow/type.h"
30-
#include "arrow/type_fwd.h"
3132
#include "arrow/type_traits.h"
3233
#include "arrow/util/bit-util.h"
3334
#include "arrow/util/checked_cast.h"
3435
#include "arrow/util/macros.h"
3536
#include "arrow/util/visibility.h"
36-
#include "arrow/visitor.h"
3737

3838
namespace arrow {
3939

40+
class Array;
41+
class ArrayVisitor;
42+
4043
using BufferVector = std::vector<std::shared_ptr<Buffer>>;
4144

4245
// When slicing, we do not know the null count of the sliced range without
@@ -48,9 +51,6 @@ constexpr int64_t kUnknownNullCount = -1;
4851
class MemoryPool;
4952
class Status;
5053

51-
template <typename T>
52-
struct Decimal;
53-
5454
// ----------------------------------------------------------------------
5555
// Generic array data container
5656

cpp/src/arrow/buffer-test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <limits>
2121
#include <memory>
2222
#include <string>
23+
#include <utility>
24+
#include <vector>
2325

2426
#include <gtest/gtest.h>
2527

cpp/src/arrow/buffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define ARROW_BUFFER_H
2020

2121
#include <algorithm>
22+
#include <array>
2223
#include <cstdint>
2324
#include <cstring>
2425
#include <memory>

cpp/src/arrow/builder.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@
1717

1818
#include "arrow/builder.h"
1919
#include <algorithm>
20+
#include <cstddef>
2021
#include <cstdint>
2122
#include <cstring>
22-
#include <limits>
2323
#include <numeric>
2424
#include <sstream>
2525
#include <utility>
2626
#include <vector>
2727

2828
#include "arrow/array.h"
2929
#include "arrow/buffer.h"
30-
#include "arrow/compare.h"
3130
#include "arrow/status.h"
3231
#include "arrow/type.h"
3332
#include "arrow/type_traits.h"

cpp/src/arrow/builder.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
#ifndef ARROW_BUILDER_H
1919
#define ARROW_BUILDER_H
2020

21-
#include <algorithm>
21+
#include <algorithm> // IWYU pragma: keep
2222
#include <array>
2323
#include <cstdint>
24-
#include <functional>
24+
#include <cstring>
25+
#include <iterator>
2526
#include <limits>
2627
#include <memory>
2728
#include <string>
29+
#include <type_traits>
2830
#include <vector>
2931

3032
#include "arrow/buffer.h"
@@ -35,22 +37,18 @@
3537
#include "arrow/util/bit-util.h"
3638
#include "arrow/util/hash.h"
3739
#include "arrow/util/macros.h"
40+
#include "arrow/util/type_traits.h"
3841
#include "arrow/util/visibility.h"
3942

4043
namespace arrow {
4144

4245
class Array;
46+
struct ArrayData;
4347
class Decimal128;
4448

4549
constexpr int64_t kBinaryMemoryLimit = std::numeric_limits<int32_t>::max() - 1;
4650
constexpr int64_t kListMaximumElements = std::numeric_limits<int32_t>::max() - 1;
4751

48-
namespace internal {
49-
50-
struct ArrayData;
51-
52-
} // namespace internal
53-
5452
constexpr int64_t kMinBuilderCapacity = 1 << 5;
5553

5654
/// Base class for all data array builders.

0 commit comments

Comments
 (0)