Skip to content

Commit

Permalink
iwyu: codebase-wide fixes based on libcpp
Browse files Browse the repository at this point in the history
These were generated by running iwyu.py --fix --all followed by some
massaging of the IWYU mapping files.

Note: kudu/client/shared_ptr.h handling isn't great:
- IWYU removes shared_ptr.h unless it is annotated with a "keep" pragma.
- IWYU adds <memory> if the file references a class from kudu::client::sp.

This appears to be because IWYU, after processing the 'using' statements in
shared_ptr.h, considers the classes in kudu::client::sp to be exactly the same
as the equivalent std classes. As such, IWYU concludes that shared_ptr.h
offers nothing of value and should be removed, and that <memory> should be
added because e.g. kudu::client::sp::shared_ptr is actually std::shared_ptr.

One might think to address the second issue by adding an "export" pragma to
shared_ptr.h's inclusion of <memory>. Doing that creates another problem:
IWYU removes <memory> from any file that includes shared_ptr.h, which is
unsafe in non-libc++ builds where kudu::client::sp maps to std::tr1.

The only way I can think of safely addressing this is by copying a non-std
implementation of <memory> into shared_ptr.h, to be used only when running
IWYU. Excising the necessary STL bits and bringing them into Kudu just for
this problem seems like overkill, though, so we'll just live with the "keep"
pragmas and the extra inclusions of <memory>.

Change-Id: Ic248ba1511347d79cc6ea38140de888e5ac13354
Reviewed-on: http://gerrit.cloudera.org:8080/15543
Reviewed-by: Alexey Serbin <[email protected]>
Tested-by: Kudu Jenkins
  • Loading branch information
adembo committed Mar 27, 2020
1 parent 458e6ce commit 092cecc
Show file tree
Hide file tree
Showing 324 changed files with 623 additions and 329 deletions.
1 change: 1 addition & 0 deletions build-support/iwyu/mappings/boost-extra.imp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.
[
{ include: ["<boost/core/explicit_operator_bool.hpp>", private, "<boost/optional/optional.hpp>", public ] },
{ include: ["<boost/core/ref.hpp>", private, "<boost/ref.hpp>", public ] },
{ include: ["<boost/cstdint.hpp>", private, "<cstdint>", public ] },
{ include: ["<boost/container/detail/std_fwd.hpp>", private, "<utility>", public ] },
{ include: ["<boost/none.hpp>", private, "<boost/optional/optional.hpp>", public ] },
Expand Down
39 changes: 39 additions & 0 deletions build-support/iwyu/mappings/openssl.imp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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.

#
# This file contains OpenSSL-specific mappings for IWYU.
#
# The goal is of these mappings is to identify the "public" OpenSSL headers
# and to force their inclusion instead of the inclusion of various private
# headers. See the IWYU mapping documentation for additional details.
#

[
{ include: ["<openssl/bio.h>", private, "<openssl/ssl.h>", public ] },
{ include: ["<openssl/evp.h>", private, "<openssl/ssl3.h>", private ] },
{ include: ["<openssl/opensslconf.h>", private, "<openssl/ssl.h>", public ] },
{ include: ["<openssl/opensslv.h>", private, "<openssl/crypto.h>", public ] },
{ include: ["<openssl/ossl_typ.h>", private, "<openssl/ssl.h>", public ] },
{ include: ["<openssl/rsa.h>", private, "<openssl/x509.h>", public ] },
{ include: ["<openssl/safestack.h>", private, "<openssl/ssl.h>", public ] },
{ include: ["<openssl/ssl2.h>", private, "<openssl/ssl.h>", public ] },
{ include: ["<openssl/ssl23.h>", private, "<openssl/ssl.h>", public ] },
{ include: ["<openssl/ssl3.h>", private, "<openssl/ssl.h>", public ] },
{ include: ["<openssl/tls1.h>", private, "<openssl/ssl.h>", public ] },
{ include: ["<openssl/x509err.h>", private, "<openssl/x509.h>", public ] },
]
12 changes: 11 additions & 1 deletion build-support/iwyu/mappings/system-linux.imp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
{ include: ["<asm-generic/int-l64.h>", private, "<linux/types.h>", public] },
{ include: ["<asm/int-l64.h>", private, "<linux/types.h>", public] },
{ include: ["<asm/ioctl.h>", private, "<linux/ioctl.h>", public] },
{ include: ["<bits/types/__sigval_t.h>", private, "<signal.h>", public] },
{ include: ["<bits/types/siginfo_t.h>", private, "<signal.h>", public] },
{ include: ["<bits/types/struct_rusage.h>", private, "<sys/resource.h>", public] },
{ include: ["<bits/types/struct_tm.h>", private, "<time.h>", public] },
{ include: ["<linux/sysinfo.h>", private, "<linux/kernel.h>", public] },
{ symbol: ["statfs", private, "<sys/vfs.h>", public] }
{ symbol: ["clockid_t", private, "<time.h>", public] },
{ symbol: ["iovec", private, "<sys/socket.h>", public] },
{ symbol: ["iovec", private, "<sys/types.h>", public] },
{ symbol: ["strcasecmp", private, "<strings.h>", public] },
{ symbol: ["strncasecmp", private, "<strings.h>", public] },
{ symbol: ["statfs", private, "<sys/vfs.h>", public] },
{ symbol: ["IOV_MAX", private, "<limits.h>", public] },
]
1 change: 1 addition & 0 deletions src/kudu/benchmarks/tpch/rpc_line_item_dao-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include <boost/bind.hpp>
Expand Down
3 changes: 1 addition & 2 deletions src/kudu/cfile/binary_dict_block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@

#include <limits>
#include <ostream>
#include <string>
#include <vector>

#include <glog/logging.h>

#include "kudu/cfile/block_pointer.h"
#include "kudu/cfile/bshuf_block.h"
#include "kudu/cfile/cfile.pb.h"
#include "kudu/cfile/cfile_reader.h"
#include "kudu/cfile/cfile_util.h"
#include "kudu/cfile/cfile_writer.h"
#include "kudu/cfile/bshuf_block.h"
#include "kudu/common/column_materialization_context.h"
#include "kudu/common/column_predicate.h"
#include "kudu/common/columnblock.h"
Expand Down
1 change: 0 additions & 1 deletion src/kudu/cfile/binary_plain_block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <algorithm>
#include <cstdint>
#include <ostream>
#include <string>

#include <glog/logging.h>

Expand Down
2 changes: 1 addition & 1 deletion src/kudu/cfile/cfile-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.

#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <cstring>
Expand All @@ -24,7 +25,6 @@
#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#include <gflags/gflags.h>
Expand Down
1 change: 0 additions & 1 deletion src/kudu/cfile/cfile_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <cstddef>
#include <cstdint>
#include <memory>
#include <mutex>
#include <string>
#include <vector>

Expand Down
9 changes: 0 additions & 9 deletions src/kudu/cfile/cfile_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,9 @@
#include "kudu/util/slice.h"
#include "kudu/util/status.h"

namespace google {
namespace protobuf {
template <typename Element>
class RepeatedPtrField; // IWYU pragma: keep
}
}

namespace kudu {

class TypeInfo;
template <typename Buffer>
class KeyEncoder;

namespace cfile {

Expand Down
1 change: 1 addition & 0 deletions src/kudu/cfile/index-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <cstdio>
#include <cstring>
#include <memory>
#include <ostream>
#include <string>

#include <glog/logging.h>
Expand Down
4 changes: 2 additions & 2 deletions src/kudu/cfile/index_btree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
// specific language governing permissions and limitations
// under the License.

#include "kudu/cfile/index_btree.h"

#include <cstddef>
#include <memory>
#include <ostream>
#include <string>
#include <vector>

#include <glog/logging.h>
Expand All @@ -30,7 +31,6 @@
#include "kudu/cfile/cfile_util.h"
#include "kudu/cfile/cfile_writer.h"
#include "kudu/cfile/index_block.h"
#include "kudu/cfile/index_btree.h"
#include "kudu/fs/block_id.h"
#include "kudu/gutil/strings/substitute.h"
#include "kudu/util/debug-util.h"
Expand Down
7 changes: 4 additions & 3 deletions src/kudu/cfile/type_encodings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
#include <memory>
#include <unordered_map>
#include <utility>
#include <vector>

#include "kudu/cfile/binary_dict_block.h"
#include "kudu/cfile/binary_plain_block.h"
#include "kudu/cfile/binary_prefix_block.h"
#include "kudu/cfile/bshuf_block.h"
#include "kudu/cfile/plain_bitmap_block.h"
#include "kudu/cfile/plain_block.h"
#include "kudu/cfile/rle_block.h"
#include "kudu/cfile/binary_dict_block.h"
#include "kudu/cfile/binary_plain_block.h"
#include "kudu/cfile/binary_prefix_block.h"
#include "kudu/common/types.h"
#include "kudu/gutil/port.h"
#include "kudu/gutil/singleton.h"
Expand Down
2 changes: 2 additions & 0 deletions src/kudu/client/authz_token_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include "kudu/client/authz_token_cache.h"

#include <cstdint>
#include <functional>
#include <mutex>
#include <ostream>
#include <string>
#include <unordered_map>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion src/kudu/client/batcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "kudu/client/batcher.h"

#include <cstddef>
#include <memory>
#include <mutex>
#include <ostream>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion src/kudu/client/batcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#pragma once

#include <cstdint>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <utility>
#include <vector>

#include <sparsehash/dense_hash_set>
Expand Down
1 change: 0 additions & 1 deletion src/kudu/client/client-internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <mutex>
#include <ostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

Expand Down
14 changes: 4 additions & 10 deletions src/kudu/client/client-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@
// under the License.
#pragma once

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
Expand All @@ -33,12 +29,8 @@
#include "kudu/client/client.h"
#include "kudu/gutil/macros.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/master/master.pb.h"
#include "kudu/rpc/response_callback.h"
#include "kudu/rpc/rpc.h"
#include "kudu/rpc/rpc_controller.h"
#include "kudu/rpc/user_credentials.h"
#include "kudu/security/token.pb.h"
#include "kudu/util/atomic.h"
#include "kudu/util/locks.h"
#include "kudu/util/monotime.h"
Expand All @@ -57,13 +49,16 @@ class DnsResolver;
class PartitionSchema;
class Sockaddr;

namespace security {
class SignedTokenPB;
} // namespace security

namespace master {
class AlterTableRequestPB;
class AlterTableResponsePB;
class ConnectToMasterResponsePB;
class CreateTableRequestPB;
class CreateTableResponsePB;
class GetTableSchemaResponsePB;
class ListTabletServersRequestPB;
class ListTabletServersResponsePB;
class MasterServiceProxy;
Expand All @@ -80,7 +75,6 @@ namespace client {
class KuduSchema;

namespace internal {
class AuthzTokenCache;
class ConnectToClusterRpc;
class MetaCache;
class RemoteTablet;
Expand Down
1 change: 1 addition & 0 deletions src/kudu/client/client-test-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <algorithm>
#include <ostream>
#include <string>
#include <utility>
#include <vector>

#include <glog/logging.h>
Expand Down
1 change: 1 addition & 0 deletions src/kudu/client/client-test-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <vector>

Expand Down
21 changes: 16 additions & 5 deletions src/kudu/client/client-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
// specific language governing permissions and limitations
// under the License.

#include "kudu/client/client.h"

#include <algorithm>
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <map>
#include <memory>
Expand All @@ -36,16 +40,16 @@
#include <boost/function.hpp>
#include <boost/optional/optional.hpp>
#include <gflags/gflags.h>
#include <gflags/gflags_declare.h>
#include <glog/logging.h>
#include <glog/stl_logging.h>
#include <gmock/gmock-generated-matchers.h>
#include <gmock/gmock-matchers.h>
#include <google/protobuf/util/message_differencer.h>
#include <gtest/gtest.h>

#include "kudu/client/callbacks.h"
#include "kudu/client/client-internal.h"
#include "kudu/client/client-test-util.h"
#include "kudu/client/client.h"
#include "kudu/client/client.pb.h"
#include "kudu/client/error_collector.h"
#include "kudu/client/meta_cache.h"
Expand All @@ -62,6 +66,7 @@
#include "kudu/client/write_op.h"
#include "kudu/clock/clock.h"
#include "kudu/clock/hybrid_clock.h"
#include "kudu/common/common.pb.h"
#include "kudu/common/partial_row.h"
#include "kudu/common/row.h"
#include "kudu/common/schema.h"
Expand All @@ -84,11 +89,11 @@
#include "kudu/master/master.pb.h"
#include "kudu/master/mini_master.h"
#include "kudu/mini-cluster/internal_mini_cluster.h"
#include "kudu/mini-cluster/mini_cluster.h"
#include "kudu/rpc/messenger.h"
#include "kudu/rpc/service_pool.h"
#include "kudu/security/tls_context.h"
#include "kudu/security/token.pb.h"
#include "kudu/security/token_signer.h"
#include "kudu/server/rpc_server.h"
#include "kudu/tablet/tablet.h"
#include "kudu/tablet/tablet_metadata.h"
Expand All @@ -106,7 +111,7 @@
#include "kudu/util/metrics.h"
#include "kudu/util/monotime.h"
#include "kudu/util/net/sockaddr.h"
#include "kudu/util/pb_util.h"
#include "kudu/util/path_util.h"
#include "kudu/util/random.h"
#include "kudu/util/random_util.h"
#include "kudu/util/semaphore.h"
Expand All @@ -115,7 +120,6 @@
#include "kudu/util/stopwatch.h"
#include "kudu/util/test_macros.h"
#include "kudu/util/test_util.h"
#include "kudu/util/thread.h"
#include "kudu/util/thread_restrictions.h"

DECLARE_bool(allow_unsafe_replication_factor);
Expand Down Expand Up @@ -188,7 +192,14 @@ using std::unordered_set;
using std::vector;
using strings::Substitute;

namespace boost {
template <typename Signature> class function;
} // namespace boost

namespace kudu {

class RWMutex;

namespace client {

class ClientTest : public KuduTest {
Expand Down
Loading

0 comments on commit 092cecc

Please sign in to comment.